This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] gdb-add-index tweaks
- From: dje at google dot com (Doug Evans)
- To: tromey at redhat dot com, gdb-patches at sourceware dot org
- Date: Fri, 3 Sep 2010 11:01:17 -0700 (PDT)
- Subject: [patch] gdb-add-index tweaks
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 <tromey@redhat.com>
Doug Evans <dje@google.com>
* 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 <http://www.gnu.org/licenses/>.
+# 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