From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4678 invoked by alias); 3 Sep 2010 18:01:39 -0000 Received: (qmail 4503 invoked by uid 22791); 3 Sep 2010 18:01:38 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_BJ,TW_JC,TW_YM,T_RP_MATCHES_RCVD,URIBL_RHS_DOB X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 03 Sep 2010 18:01:31 +0000 Received: from hpaq6.eem.corp.google.com (hpaq6.eem.corp.google.com [172.25.149.6]) by smtp-out.google.com with ESMTP id o83I1JJm030923; Fri, 3 Sep 2010 11:01:19 -0700 Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.118.116]) by hpaq6.eem.corp.google.com with ESMTP id o83I1HYY023106; Fri, 3 Sep 2010 11:01:18 -0700 Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id 42E9D841F7; Fri, 3 Sep 2010 11:01:17 -0700 (PDT) To: tromey@redhat.com, gdb-patches@sourceware.org Subject: [patch] gdb-add-index tweaks Message-Id: <20100903180117.42E9D841F7@ruffy.mtv.corp.google.com> Date: Fri, 03 Sep 2010 18:27:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00133.txt.bz2 Hi. This patch makes gdb-add-index.sh a (teensy) bit more robust and restores the Makefile.in/gdb.texinfo changes (the latter with a few tweaks). Tom, if you still want to delete gdb-add-index.sh, it's your call. 2010-09-03 Tom Tromey Doug Evans * Makefile.in (install-only): Install gdb-add-index. * gdb-add-index.sh: Verify correct number of parameters passed. Flag error if FILE isn't accessible. Catch error exit from gdb and objcopy. doc/ * gdb.texinfo (Index Files): Mention gdb-add-index. Index: Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.1133 diff -u -p -r1.1133 Makefile.in --- Makefile.in 2 Sep 2010 13:58:06 -0000 1.1133 +++ Makefile.in 3 Sep 2010 17:53:19 -0000 @@ -1019,7 +1019,16 @@ install-only: $(CONFIG_INSTALL) xml-sysc $(SHELL) $(srcdir)/../mkinstalldirs \ $(DESTDIR)$(man1dir) ; \ $(INSTALL_DATA) $(srcdir)/gdb.1 \ - $(DESTDIR)$(man1dir)/$$transformed_name.1 + $(DESTDIR)$(man1dir)/$$transformed_name.1; \ + transformed_name=`t='$(program_transform_name)'; \ + echo gdb-add-index | sed -e "$$t"` ; \ + if test "x$$transformed_name" = x; then \ + transformed_name=gdb-add-index ; \ + else \ + true ; \ + fi ; \ + $(INSTALL_PROGRAM) $(srcdir)/gdb-add-index.sh \ + $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) @$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do .PHONY: install-tui install-tui: Index: gdb-add-index.sh =================================================================== RCS file: /cvs/src/src/gdb/gdb-add-index.sh,v retrieving revision 1.1 diff -u -p -r1.1 gdb-add-index.sh --- gdb-add-index.sh 30 Jul 2010 20:46:34 -0000 1.1 +++ gdb-add-index.sh 3 Sep 2010 17:53:19 -0000 @@ -16,14 +16,47 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# This program assumes gdb and objcopy are in $PATH. +# For documentation: info -f gdb.info -n "Index Files" + +myname="${0##*/}" + +if test $# != 1; then + echo "usage: $myname FILE" 1>&2 + exit 1 +fi + file="$1" + +if test ! -r "$file"; then + echo "$myname: unable to access: $file" 1>&2 + exit 1 +fi + dir="${file%/*}" +test "$dir" = "$file" && dir="." +index="${file}.gdb-index" + +# Ensure intermediate index file is removed when we exit. +trap "rm -f $index" 0 + +gdb --batch-silent -nx -ex "file $file" -ex "save gdb-index $dir" || { + # Just in case. + status=$? + echo "$myname: gdb error generating index" + exit $status +} -gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" +# In some situations gdb can exit without creating an index. This is +# not an error. +# E.g., if $file is stripped. This behaviour is akin to stripping an +# already stripped binary, it's a no-op. -if test -f "${file}.gdb-index"; then - objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file" - rm -f "${file}.gdb-index" +status=0 +if test -f "$index"; then + objcopy --add-section .gdb_index="$index" \ + --set-section-flags .gdb_index=readonly "$file" "$file" + status=$? fi -exit 0 +exit $status Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.762 diff -u -p -r1.762 gdb.texinfo --- doc/gdb.texinfo 1 Sep 2010 19:03:51 -0000 1.762 +++ doc/gdb.texinfo 3 Sep 2010 17:53:22 -0000 @@ -15230,8 +15230,8 @@ This computation does not apply to the ` When @value{GDBN} finds a symbol file, it scans the symbols in the file in order to construct an internal symbol table. This lets most @value{GDBN} operations work quickly---at the cost of a delay early -on. For large programs, this delay can be quite lengthy, so -@value{GDBN} provides a way to build an index, which speeds up +on. For large programs this delay can be quite lengthy, so +@value{GDBN} provides a way to build an index which speeds up startup. The index is stored as a section in the symbol file. @value{GDBN} can @@ -15258,8 +15258,22 @@ $ objcopy --add-section .gdb_index=symfi @end smallexample There are currently some limitation on indices. They only work when -for DWARF debugging information, not stabs. And, they do not -currently work for programs using Ada. +using DWARF debugging information, not stabs. And, they do not +currently work for programs written in Ada. + +@pindex gdb-add-index +@value{GDBN} comes with a program, @command{gdb-add-index}, which can +be used to add the index to a symbol file. It takes the symbol file +as its only argument: + +@smallexample +$ gdb-add-index symfile +@end smallexample + +@command{gdb-add-index} is a simple script, with minimal error checking. +If @file{symfile} does not contain sufficient debugging information, +or no debugging information at all, it will exit without an error. + @node Symbol Errors @section Errors Reading Symbol Files