20f9f67
http://sourceware.org/ml/gdb-patches/2010-07/msg00184.html
20f9f67
Subject: Re: [0/4] RFC: add DWARF index support
20f9f67
44969d3
Jan Kratochvil: Fixed $d -> $dir.
44969d3
Jan Kratochvil: Remove /dev/null redirection.
44969d3
20f9f67
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
20f9f67
20f9f67
Tom> This patch series adds support for a DWARF index to gdb.
20f9f67
20f9f67
Roland suggested we wrap up the index-creation code into a helper
20f9f67
script.
20f9f67
20f9f67
I'm not sure if this is something people would want in gdb proper, but I
20f9f67
figured I would send it here just in case.
20f9f67
20f9f67
Tom
20f9f67
20f9f67
2010-07-09  Tom Tromey  <tromey@redhat.com>
20f9f67
20f9f67
	* Makefile.in (install-only): Install gdb-add-index.
20f9f67
	* gdb-add-index: New file.
20f9f67
20f9f67
2010-07-09  Tom Tromey  <tromey@redhat.com>
20f9f67
20f9f67
	* gdb.texinfo (Index Files): Mention gdb-add-index.
20f9f67
20f9f67
>From 30714fe719e61baea03d0dc5793eb0d564faebb7 Mon Sep 17 00:00:00 2001
20f9f67
From: Tom Tromey <tromey@redhat.com>
20f9f67
Date: Fri, 9 Jul 2010 11:17:54 -0600
20f9f67
Subject: [PATCH 4/4] add gdb-add-index
20f9f67
Subject: [PATCH 4/4] add gdb-add-index
20f9f67
20f9f67
---
20f9f67
 gdb/ChangeLog       |    5 +++++
20f9f67
 gdb/Makefile.in     |   11 ++++++++++-
20f9f67
 gdb/doc/ChangeLog   |    4 ++++
20f9f67
 gdb/doc/gdb.texinfo |    8 ++++++++
20f9f67
 gdb/gdb-add-index   |   30 ++++++++++++++++++++++++++++++
20f9f67
 5 files changed, 57 insertions(+), 1 deletions(-)
20f9f67
 create mode 100755 gdb/gdb-add-index
20f9f67
Jan Kratochvil e00e5ea
Index: gdb-7.2.50.20101116/gdb/Makefile.in
Jan Kratochvil e00e5ea
===================================================================
Jan Kratochvil e00e5ea
--- gdb-7.2.50.20101116.orig/gdb/Makefile.in	2010-11-16 08:03:17.000000000 +0100
Jan Kratochvil e00e5ea
+++ gdb-7.2.50.20101116/gdb/Makefile.in	2010-11-16 08:47:45.000000000 +0100
Jan Kratochvil e00e5ea
@@ -986,7 +986,16 @@ install-only: install-gstack $(CONFIG_IN
20f9f67
 		$(SHELL) $(srcdir)/../mkinstalldirs \
20f9f67
 			$(DESTDIR)$(man1dir) ; \
20f9f67
 		$(INSTALL_DATA) $(srcdir)/gdb.1 \
20f9f67
-			$(DESTDIR)$(man1dir)/$$transformed_name.1
20f9f67
+			$(DESTDIR)$(man1dir)/$$transformed_name.1; \
20f9f67
+	transformed_name=`t='$(program_transform_name)'; \
20f9f67
+			  echo gdb-add-index | sed -e "$$t"` ; \
20f9f67
+		if test "x$$transformed_name" = x; then \
20f9f67
+		  transformed_name=gdb-add-index ; \
20f9f67
+		else \
20f9f67
+		  true ; \
20f9f67
+		fi ; \
20f9f67
+		$(INSTALL_PROGRAM) $(srcdir)/gdb-add-index \
20f9f67
+			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT)
20f9f67
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
20f9f67
 .PHONY: install-tui
20f9f67
 install-tui:
Jan Kratochvil e00e5ea
Index: gdb-7.2.50.20101116/gdb/doc/gdb.texinfo
Jan Kratochvil e00e5ea
===================================================================
Jan Kratochvil e00e5ea
--- gdb-7.2.50.20101116.orig/gdb/doc/gdb.texinfo	2010-11-16 08:04:18.000000000 +0100
Jan Kratochvil e00e5ea
+++ gdb-7.2.50.20101116/gdb/doc/gdb.texinfo	2010-11-16 08:56:30.000000000 +0100
Jan Kratochvil e00e5ea
@@ -15500,6 +15500,14 @@ There are currently some limitation on i
20f9f67
 for DWARF debugging information, not stabs.  And, they do not
20f9f67
 currently work for programs using Ada.
20f9f67
 
20f9f67
+@value{GDBN} comes with a program, @command{gdb-add-index}, which can
20f9f67
+be used to add the index to a symbol file.  It takes the symbol file
20f9f67
+as its only argument:
20f9f67
+
20f9f67
+@smallexample
20f9f67
+$ gdb-add-index symfile
20f9f67
+@end smallexample
20f9f67
+
20f9f67
 @node Symbol Errors
20f9f67
 @section Errors Reading Symbol Files
Jan Kratochvil e00e5ea
 
Jan Kratochvil e00e5ea
Index: gdb-7.2.50.20101116/gdb/gdb-add-index
Jan Kratochvil e00e5ea
===================================================================
Jan Kratochvil e00e5ea
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil e00e5ea
+++ gdb-7.2.50.20101116/gdb/gdb-add-index	2010-11-16 08:47:45.000000000 +0100
20f9f67
@@ -0,0 +1,30 @@
20f9f67
+#! /bin/sh
20f9f67
+
20f9f67
+# Add a .gdb_index section to a file.
20f9f67
+
20f9f67
+# Copyright (C) 2010 Free Software Foundation, Inc.
20f9f67
+# This program is free software; you can redistribute it and/or modify
20f9f67
+# it under the terms of the GNU General Public License as published by
20f9f67
+# the Free Software Foundation; either version 3 of the License, or
20f9f67
+# (at your option) any later version.
20f9f67
+#
20f9f67
+# This program is distributed in the hope that it will be useful,
20f9f67
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20f9f67
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20f9f67
+# GNU General Public License for more details.
20f9f67
+#
20f9f67
+# You should have received a copy of the GNU General Public License
20f9f67
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20f9f67
+
20f9f67
+file="$1"
20f9f67
+dir="${file%/*}"
20f9f67
+
20f9f67
+# We don't care if gdb gives an error.
Jan Kratochvil 1bcf9b6
+gdb -nx --batch-silent -ex "file $file" -ex "save gdb-index $dir"
20f9f67
+
20f9f67
+if test -f "${file}.gdb-index"; then
20f9f67
+   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
20f9f67
+   rm -f "${file}.gdb-index"
20f9f67
+fi
20f9f67
+
20f9f67
+exit 0