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 2c55a54
Index: gdb-7.6.90.20140127/gdb/Makefile.in
Jan Kratochvil e00e5ea
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/Makefile.in	2014-02-06 17:37:54.555975958 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/Makefile.in	2014-02-06 17:38:52.110038415 +0100
Jan Kratochvil 2c55a54
@@ -1093,6 +1093,15 @@ install-only: install-gstack $(CONFIG_IN
Jan Kratochvil 2c55a54
 		  $(INSTALL_SCRIPT) gcore \
Jan Kratochvil cf0b61a
 			  $(DESTDIR)$(bindir)/$$transformed_name; \
Jan Kratochvil cf0b61a
 	fi
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 ; \
Jan Kratochvil 2c55a54
+		$(INSTALL_PROGRAM) $(srcdir)/contrib/gdb-add-index.sh \
20f9f67
+			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT)
20f9f67
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
Jan Kratochvil 254f0e9
 
Jan Kratochvil 2c55a54
 install-strip:
Jan Kratochvil 2c55a54
Index: gdb-7.6.90.20140127/gdb/doc/gdb.texinfo
Jan Kratochvil e00e5ea
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/doc/gdb.texinfo	2014-02-06 17:37:50.822971940 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/doc/gdb.texinfo	2014-02-06 17:37:54.565975968 +0100
Jan Kratochvil 2c55a54
@@ -17749,6 +17749,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 2c55a54
@@ -43878,6 +43886,7 @@ switch (die->tag)
Jan Kratochvil cf0b61a
 * gdbserver man::               Remote Server for the GNU Debugger man page
Jan Kratochvil cf0b61a
 * gcore man::                   Generate a core file of a running program
Jan Kratochvil cf0b61a
 * gdbinit man::                 gdbinit scripts
Jan Kratochvil cf0b61a
+* gdb-add-index man::           Add index files to speed up GDB
Jan Kratochvil cf0b61a
 @end menu
Jan Kratochvil cf0b61a
 
Jan Kratochvil cf0b61a
 @node gdb man
Jan Kratochvil 2c55a54
@@ -44530,6 +44539,54 @@ gdb(1), @code{info -f gdb -n Startup}
Jan Kratochvil cf0b61a
 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
Jan Kratochvil cf0b61a
 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
Jan Kratochvil cf0b61a
 documentation are properly installed at your site, the command
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@smallexample
Jan Kratochvil cf0b61a
+info gdb
Jan Kratochvil cf0b61a
+@end smallexample
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+should give you access to the complete manual.
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
Jan Kratochvil cf0b61a
+Richard M. Stallman and Roland H. Pesch, July 1991.
Jan Kratochvil cf0b61a
+@end ifset
Jan Kratochvil cf0b61a
+@c man end
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@node gdb-add-index man
Jan Kratochvil cf0b61a
+@heading gdb-add-index
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@c man title gdb-add-index Add index files to speed up GDB
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@c man begin SYNOPSIS gdb-add-index
Jan Kratochvil cf0b61a
+gdb-add-index @var{filename}
Jan Kratochvil cf0b61a
+@c man end
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@c man begin DESCRIPTION gdb-add-index
Jan Kratochvil cf0b61a
+When GDB finds a symbol file, it scans the symbols in the file in order
Jan Kratochvil cf0b61a
+to construct an internal symbol table.  This lets most GDB operations
Jan Kratochvil cf0b61a
+work quickly--at the cost of a delay early on.  For large programs,
Jan Kratochvil cf0b61a
+this delay can be quite lengthy, so GDB provides a way to build an
Jan Kratochvil cf0b61a
+index, which speeds up startup.
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+To determine whether a file contains such an index, use the command
Jan Kratochvil cf0b61a
+@command{readelf -S filename}: the index is stored in a section named
Jan Kratochvil cf0b61a
+@code{.gdb_index}.  Note that the index is never generated for files that do
Jan Kratochvil cf0b61a
+not contain DWARF debug information (sections named @code{.debug_*}).
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+See more in
Jan Kratochvil cf0b61a
+@ifset man
Jan Kratochvil cf0b61a
+the @value{GDBN} manual in node @code{Index Files}
Jan Kratochvil cf0b61a
+-- shell command @code{info -f gdb -n 'Index Files'}.
Jan Kratochvil cf0b61a
+@end ifset
Jan Kratochvil cf0b61a
+@ifclear man
Jan Kratochvil cf0b61a
+@ref{Index Files}.
Jan Kratochvil cf0b61a
+@end ifclear
Jan Kratochvil cf0b61a
+@c man end
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
+@c man begin SEEALSO gdb-add-index
Jan Kratochvil cf0b61a
+@ifset man
Jan Kratochvil cf0b61a
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
Jan Kratochvil cf0b61a
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
Jan Kratochvil cf0b61a
+documentation are properly installed at your site, the command
Jan Kratochvil cf0b61a
 
Jan Kratochvil cf0b61a
 @smallexample
Jan Kratochvil cf0b61a
 info gdb
Jan Kratochvil 2c55a54
Index: gdb-7.6.90.20140127/gdb/doc/Makefile.in
Jan Kratochvil e00e5ea
===================================================================
Jan Kratochvil 2c55a54
--- gdb-7.6.90.20140127.orig/gdb/doc/Makefile.in	2014-02-06 17:37:50.824971942 +0100
Jan Kratochvil 2c55a54
+++ gdb-7.6.90.20140127/gdb/doc/Makefile.in	2014-02-06 17:37:54.565975968 +0100
Jan Kratochvil 2c55a54
@@ -165,7 +165,7 @@ POD2MAN5 = pod2man --center="GNU Develop
Jan Kratochvil 872aab0
 		   --release="gdb-`sed q version.subst`" --section=5
Jan Kratochvil cf0b61a
 
Jan Kratochvil cf0b61a
 # List of man pages generated from gdb.texi
Jan Kratochvil cf0b61a
-MAN1S = gdb.1 gdbserver.1 gcore.1
Jan Kratochvil cf0b61a
+MAN1S = gdb.1 gdbserver.1 gcore.1 gdb-add-index.1
Jan Kratochvil cf0b61a
 MAN5S = gdbinit.5
Jan Kratochvil cf0b61a
 MANS = $(MAN1S) $(MAN5S)
Jan Kratochvil cf0b61a
 
Jan Kratochvil 2c55a54
@@ -590,6 +590,13 @@ gcore.1: $(GDB_DOC_FILES)
Jan Kratochvil cf0b61a
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
Jan Kratochvil cf0b61a
 	rm -f gcore.pod
Jan Kratochvil cf0b61a
 
Jan Kratochvil cf0b61a
+gdb-add-index.1: $(GDB_DOC_FILES)
Jan Kratochvil cf0b61a
+	touch $@
Jan Kratochvil cf0b61a
+	-$(TEXI2POD) $(MANCONF) -Dgdb-add-index < $(srcdir)/gdb.texinfo > gdb-add-index.pod
Jan Kratochvil cf0b61a
+	-($(POD2MAN1) gdb-add-index.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
Jan Kratochvil cf0b61a
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
Jan Kratochvil cf0b61a
+	rm -f gdb-add-index.pod
Jan Kratochvil cf0b61a
+
Jan Kratochvil cf0b61a
 gdbinit.5: $(GDB_DOC_FILES)
Jan Kratochvil cf0b61a
 	touch $@
Jan Kratochvil cf0b61a
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod