Blame SOURCES/gdb-gdb-add-index-script.patch

861f93
http://sourceware.org/ml/gdb-patches/2010-07/msg00184.html
861f93
Subject: Re: [0/4] RFC: add DWARF index support
861f93
861f93
Jan Kratochvil: Fixed $d -> $dir.
861f93
Jan Kratochvil: Remove /dev/null redirection.
861f93
861f93
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
861f93
861f93
Tom> This patch series adds support for a DWARF index to gdb.
861f93
861f93
Roland suggested we wrap up the index-creation code into a helper
861f93
script.
861f93
861f93
I'm not sure if this is something people would want in gdb proper, but I
861f93
figured I would send it here just in case.
861f93
861f93
Tom
861f93
861f93
2010-07-09  Tom Tromey  <tromey@redhat.com>
861f93
861f93
	* Makefile.in (install-only): Install gdb-add-index.
861f93
	* gdb-add-index: New file.
861f93
861f93
2010-07-09  Tom Tromey  <tromey@redhat.com>
861f93
861f93
	* gdb.texinfo (Index Files): Mention gdb-add-index.
861f93
861f93
>From 30714fe719e61baea03d0dc5793eb0d564faebb7 Mon Sep 17 00:00:00 2001
861f93
From: Tom Tromey <tromey@redhat.com>
861f93
Date: Fri, 9 Jul 2010 11:17:54 -0600
861f93
Subject: [PATCH 4/4] add gdb-add-index
861f93
Subject: [PATCH 4/4] add gdb-add-index
861f93
861f93
---
861f93
 gdb/ChangeLog       |    5 +++++
861f93
 gdb/Makefile.in     |   11 ++++++++++-
861f93
 gdb/doc/ChangeLog   |    4 ++++
861f93
 gdb/doc/gdb.texinfo |    8 ++++++++
861f93
 gdb/gdb-add-index   |   30 ++++++++++++++++++++++++++++++
861f93
 5 files changed, 57 insertions(+), 1 deletions(-)
861f93
 create mode 100755 gdb/gdb-add-index
861f93
861f93
Index: gdb-7.5.91.20130407/gdb/Makefile.in
861f93
===================================================================
861f93
--- gdb-7.5.91.20130407.orig/gdb/Makefile.in	2013-04-11 16:52:51.000000000 +0200
861f93
+++ gdb-7.5.91.20130407/gdb/Makefile.in	2013-04-11 16:53:59.199279388 +0200
861f93
@@ -1053,6 +1053,15 @@ install-only: install-gstack $(CONFIG_IN
861f93
 		  $(INSTALL_PROGRAM) gcore \
861f93
 			  $(DESTDIR)$(bindir)/$$transformed_name; \
861f93
 	fi
861f93
+	transformed_name=`t='$(program_transform_name)'; \
861f93
+			  echo gdb-add-index | sed -e "$$t"` ; \
861f93
+		if test "x$$transformed_name" = x; then \
861f93
+		  transformed_name=gdb-add-index ; \
861f93
+		else \
861f93
+		  true ; \
861f93
+		fi ; \
861f93
+		$(INSTALL_PROGRAM) $(srcdir)/gdb-add-index \
861f93
+			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT)
861f93
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
861f93
 
861f93
 install-python:
861f93
Index: gdb-7.5.91.20130407/gdb/doc/gdb.texinfo
861f93
===================================================================
861f93
--- gdb-7.5.91.20130407.orig/gdb/doc/gdb.texinfo	2013-04-11 16:53:00.000000000 +0200
861f93
+++ gdb-7.5.91.20130407/gdb/doc/gdb.texinfo	2013-04-11 16:55:07.004278842 +0200
861f93
@@ -17159,6 +17159,14 @@ There are currently some limitation on i
861f93
 for DWARF debugging information, not stabs.  And, they do not
861f93
 currently work for programs using Ada.
861f93
 
861f93
+@value{GDBN} comes with a program, @command{gdb-add-index}, which can
861f93
+be used to add the index to a symbol file.  It takes the symbol file
861f93
+as its only argument:
861f93
+
861f93
+@smallexample
861f93
+$ gdb-add-index symfile
861f93
+@end smallexample
861f93
+
861f93
 @node Symbol Errors
861f93
 @section Errors Reading Symbol Files
861f93
 
861f93
@@ -41730,6 +41738,7 @@ switch (die->tag)
861f93
 * gdbserver man::               Remote Server for the GNU Debugger man page
861f93
 * gcore man::                   Generate a core file of a running program
861f93
 * gdbinit man::                 gdbinit scripts
861f93
+* gdb-add-index man::           Add index files to speed up GDB
861f93
 @end menu
861f93
 
861f93
 @node gdb man
861f93
@@ -42382,6 +42391,54 @@ gdb(1), @code{info -f gdb -n Startup}
861f93
 The full documentation for @value{GDBN} is maintained as a Texinfo manual.
861f93
 If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
861f93
 documentation are properly installed at your site, the command
861f93
+
861f93
+@smallexample
861f93
+info gdb
861f93
+@end smallexample
861f93
+
861f93
+should give you access to the complete manual.
861f93
+
861f93
+@cite{Using GDB: A Guide to the GNU Source-Level Debugger},
861f93
+Richard M. Stallman and Roland H. Pesch, July 1991.
861f93
+@end ifset
861f93
+@c man end
861f93
+
861f93
+@node gdb-add-index man
861f93
+@heading gdb-add-index
861f93
+
861f93
+@c man title gdb-add-index Add index files to speed up GDB
861f93
+
861f93
+@c man begin SYNOPSIS gdb-add-index
861f93
+gdb-add-index @var{filename}
861f93
+@c man end
861f93
+
861f93
+@c man begin DESCRIPTION gdb-add-index
861f93
+When GDB finds a symbol file, it scans the symbols in the file in order
861f93
+to construct an internal symbol table.  This lets most GDB operations
861f93
+work quickly--at the cost of a delay early on.  For large programs,
861f93
+this delay can be quite lengthy, so GDB provides a way to build an
861f93
+index, which speeds up startup.
861f93
+
861f93
+To determine whether a file contains such an index, use the command
861f93
+@command{readelf -S filename}: the index is stored in a section named
861f93
+@code{.gdb_index}.  Note that the index is never generated for files that do
861f93
+not contain DWARF debug information (sections named @code{.debug_*}).
861f93
+
861f93
+See more in
861f93
+@ifset man
861f93
+the @value{GDBN} manual in node @code{Index Files}
861f93
+-- shell command @code{info -f gdb -n 'Index Files'}.
861f93
+@end ifset
861f93
+@ifclear man
861f93
+@ref{Index Files}.
861f93
+@end ifclear
861f93
+@c man end
861f93
+
861f93
+@c man begin SEEALSO gdb-add-index
861f93
+@ifset man
861f93
+The full documentation for @value{GDBN} is maintained as a Texinfo manual.
861f93
+If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
861f93
+documentation are properly installed at your site, the command
861f93
 
861f93
 @smallexample
861f93
 info gdb
861f93
Index: gdb-7.5.91.20130407/gdb/gdb-add-index
861f93
===================================================================
861f93
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
861f93
+++ gdb-7.5.91.20130407/gdb/gdb-add-index	2013-04-11 16:53:21.524279909 +0200
861f93
@@ -0,0 +1,30 @@
861f93
+#! /bin/sh
861f93
+
861f93
+# Add a .gdb_index section to a file.
861f93
+
861f93
+# Copyright (C) 2010 Free Software Foundation, Inc.
861f93
+# This program is free software; you can redistribute it and/or modify
861f93
+# it under the terms of the GNU General Public License as published by
861f93
+# the Free Software Foundation; either version 3 of the License, or
861f93
+# (at your option) any later version.
861f93
+#
861f93
+# This program is distributed in the hope that it will be useful,
861f93
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
861f93
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
861f93
+# GNU General Public License for more details.
861f93
+#
861f93
+# You should have received a copy of the GNU General Public License
861f93
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
861f93
+
861f93
+file="$1"
861f93
+dir="${file%/*}"
861f93
+
861f93
+# We don't care if gdb gives an error.
861f93
+gdb -nx -iex 'set auto-load no' --batch-silent -ex "file $file" -ex "save gdb-index $dir"
861f93
+
861f93
+if test -f "${file}.gdb-index"; then
861f93
+   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
861f93
+   rm -f "${file}.gdb-index"
861f93
+fi
861f93
+
861f93
+exit 0
861f93
Index: gdb-7.5.91.20130407/gdb/doc/Makefile.in
861f93
===================================================================
861f93
--- gdb-7.5.91.20130407.orig/gdb/doc/Makefile.in	2013-04-11 16:50:33.202286928 +0200
861f93
+++ gdb-7.5.91.20130407/gdb/doc/Makefile.in	2013-04-11 16:55:06.993279304 +0200
861f93
@@ -177,7 +177,7 @@ POD2MAN5 = pod2man --center="GNU Develop
861f93
 		   --release="gdb-`sed q $(srcdir)/../version.in`" --section=5
861f93
 
861f93
 # List of man pages generated from gdb.texi
861f93
-MAN1S = gdb.1 gdbserver.1 gcore.1
861f93
+MAN1S = gdb.1 gdbserver.1 gcore.1 gdb-add-index.1
861f93
 MAN5S = gdbinit.5
861f93
 MANS = $(MAN1S) $(MAN5S)
861f93
 
861f93
@@ -626,6 +626,13 @@ gcore.1: $(GDB_DOC_FILES)
861f93
 		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
861f93
 	rm -f gcore.pod
861f93
 
861f93
+gdb-add-index.1: $(GDB_DOC_FILES)
861f93
+	touch $@
861f93
+	-$(TEXI2POD) $(MANCONF) -Dgdb-add-index < $(srcdir)/gdb.texinfo > gdb-add-index.pod
861f93
+	-($(POD2MAN1) gdb-add-index.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \
861f93
+		mv -f $@.T$$$$ $@) || (rm -f $@.T$$$$ && exit 1)
861f93
+	rm -f gdb-add-index.pod
861f93
+
861f93
 gdbinit.5: $(GDB_DOC_FILES)
861f93
 	touch $@
861f93
 	-$(TEXI2POD) $(MANCONF) -Dgdbinit < $(srcdir)/gdb.texinfo > gdbinit.pod