public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch] gdb-add-index tweaks
@ 2010-09-03 18:27 Doug Evans
  2010-09-03 22:07 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Doug Evans @ 2010-09-03 18:27 UTC (permalink / raw)
  To: tromey, gdb-patches

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] gdb-add-index tweaks
  2010-09-03 18:27 [patch] gdb-add-index tweaks Doug Evans
@ 2010-09-03 22:07 ` Eli Zaretskii
  2010-09-04 13:45 ` Tom Tromey
  2010-09-06  9:48 ` Jan Kratochvil
  2 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2010-09-03 22:07 UTC (permalink / raw)
  To: Doug Evans; +Cc: tromey, gdb-patches

> Date: Fri,  3 Sep 2010 11:01:17 -0700 (PDT)
> From: dje@google.com (Doug Evans)
> 
> 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).

Thanks.

> @@ -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.

I see no reason for this hunk of changes.  There's nothing wrong with
the original text.

>  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.

This is okay, but I would lose the "not stabs" part, because we
support more than just DWARF and stabs.  I understand that only DWARF
will enable this feature.

> +@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:

We don't really explain what is a "symbol file".  But I guess this is
a problem with this entire chapter; feel free to fix that or leave it
as it is now.

> +@command{gdb-add-index} is a simple script, with minimal error checking.

If it's a script, why we say above that it's a program?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] gdb-add-index tweaks
  2010-09-03 18:27 [patch] gdb-add-index tweaks Doug Evans
  2010-09-03 22:07 ` Eli Zaretskii
@ 2010-09-04 13:45 ` Tom Tromey
  2010-11-16  7:46   ` Jan Kratochvil
  2010-09-06  9:48 ` Jan Kratochvil
  2 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-09-04 13:45 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> Tom, if you still want to delete gdb-add-index.sh, it's your call.

It is fine by me if you want to do this.  I only deleted it because I
could not address all your comments in a timely way.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] gdb-add-index tweaks
  2010-09-03 18:27 [patch] gdb-add-index tweaks Doug Evans
  2010-09-03 22:07 ` Eli Zaretskii
  2010-09-04 13:45 ` Tom Tromey
@ 2010-09-06  9:48 ` Jan Kratochvil
  2 siblings, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2010-09-06  9:48 UTC (permalink / raw)
  To: Doug Evans; +Cc: tromey, gdb-patches

On Fri, 03 Sep 2010 20:01:17 +0200, Doug Evans wrote:
> --- gdb-add-index.sh	30 Jul 2010 20:46:34 -0000	1.1
> +++ gdb-add-index.sh	3 Sep 2010 17:53:19 -0000
[...]
> +    echo "usage: $myname FILE" 1>&2
[...]
> +    echo "$myname: unable to access: $file" 1>&2
[...]
> +    echo "$myname: gdb error generating index"

If 1>&2 are above shouldn't 1>&2 be even here?


Thanks,
Jan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] gdb-add-index tweaks
  2010-09-04 13:45 ` Tom Tromey
@ 2010-11-16  7:46   ` Jan Kratochvil
  2010-11-16 17:27     ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2010-11-16  7:46 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Doug Evans, gdb-patches

On Fri, 03 Sep 2010 20:27:14 +0200, Tom Tromey wrote:
> >>>>> "Doug" == Doug Evans <dje@google.com> writes:
> 
> Doug> Tom, if you still want to delete gdb-add-index.sh, it's your call.
> 
> It is fine by me if you want to do this.  I only deleted it because I
> could not address all your comments in a timely way.

BTW currently by patch:
	FYI: revert gdb-add-index
	http://sourceware.org/ml/gdb-patches/2010-08/msg00127.html
	http://sourceware.org/ml/gdb-cvs/2010-08/msg00046.html
	8ca01eda577eb9639bffac4177e9743345fa3f93
gdb
	Revert gdb-add-index addition:
	* Makefile.in (install-only): Don't install gdb-add-index.
	* gdb-add-index.sh: Remove.
gdb/doc
	Revert gdb-add-index addition:
	* gdb.texinfo (Index Files): Don't document gdb-add-index.

was reverted gdb/Makefile.in + gdb/doc/gdb.texinfo change but sole
gdb/gdb-add-index.sh still remains in the tree.


Regards,
Jan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] gdb-add-index tweaks
  2010-11-16  7:46   ` Jan Kratochvil
@ 2010-11-16 17:27     ` Tom Tromey
  2010-11-16 17:38       ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2010-11-16 17:27 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Doug Evans, gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Doug> Tom, if you still want to delete gdb-add-index.sh, it's your call.

Tom> It is fine by me if you want to do this.  I only deleted it because I
Tom> could not address all your comments in a timely way.

[...]
Jan> was reverted gdb/Makefile.in + gdb/doc/gdb.texinfo change but sole
Jan> gdb/gdb-add-index.sh still remains in the tree.

Yeah, oops.  Doug pointed this out a while ago, but at the time I didn't
go ahead and delete it because I thought Doug was going to push in this
patch instead.

I will delete it now.  If anybody wants to resurrect it all, that is
still fine by me.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch] gdb-add-index tweaks
  2010-11-16 17:27     ` Tom Tromey
@ 2010-11-16 17:38       ` Tom Tromey
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2010-11-16 17:38 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Doug Evans, gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> I will delete it now.  If anybody wants to resurrect it all, that is
Tom> still fine by me.

Here's the patch.

Tom

2010-11-16  Tom Tromey  <tromey@redhat.com>

	* gdb-add-index.sh: Really remove.

Index: gdb-add-index.sh
===================================================================
RCS file: gdb-add-index.sh
diff -N gdb-add-index.sh
--- gdb-add-index.sh	30 Jul 2010 20:46:34 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-#! /bin/sh
-
-# Add a .gdb_index section to a file.
-
-# Copyright (C) 2010 Free Software Foundation, Inc.
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-file="$1"
-dir="${file%/*}"
-
-gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
-
-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"
-fi
-
-exit 0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-11-16 17:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-03 18:27 [patch] gdb-add-index tweaks Doug Evans
2010-09-03 22:07 ` Eli Zaretskii
2010-09-04 13:45 ` Tom Tromey
2010-11-16  7:46   ` Jan Kratochvil
2010-11-16 17:27     ` Tom Tromey
2010-11-16 17:38       ` Tom Tromey
2010-09-06  9:48 ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).