This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: find-debuginfo.sh change for gdb index
- From: Tom Tromey <tromey at redhat dot com>
- To: Roland McGrath <roland at redhat dot com>
- Cc: Panu Matilainen <pmatilai at redhat dot com>, Project Archer <archer at sourceware dot org>
- Date: Thu, 08 Jul 2010 09:56:30 -0600
- Subject: Re: find-debuginfo.sh change for gdb index
- References: <m3vd91tqpl.fsf@fleche.redhat.com><20100629232147.C019548255@magilla.sf.frob.com><m3r5joscvs.fsf@fleche.redhat.com><20100630181436.518364C33C@magilla.sf.frob.com><m31vbos7lc.fsf@fleche.redhat.com> <m3y6dws151.fsf@fleche.redhat.com><20100630204424.3DCE34C33C@magilla.sf.frob.com><m3lj9wrz60.fsf@fleche.redhat.com><20100630221406.254AC4C33E@magilla.sf.frob.com><m339w1lkuu.fsf@fleche.redhat.com><alpine.LFD.2.00.1007051223290.8757@localhost><m38w5ocvcj.fsf@fleche.redhat.com><20100706191407.535874824F@magilla.sf.frob.com>
Roland> So one approach would be to replace the debugedit invocation
Roland> with the use of another shell script.
Here is a patch to just do the work directly in find-debuginfo.sh. This
seemed simpler to me, but if you and Panu want a new script, I will do
that.
It would perhaps have been cleaner to make the gdb command simply
rewrite the objfile directly. However, this turns out to be relatively
hairy with BFD. So again, for simplicity I just stuck with invoking
objcopy directly. I also verified that objcopy will preserve hard
links.
Tom
--- find-debuginfo.sh.orig 2010-06-29 16:19:42.000000000 -0600
+++ find-debuginfo.sh 2010-07-08 09:36:03.000000000 -0600
@@ -96,6 +96,15 @@
chmod 444 "$1" || exit
}
+# Create a .gdb-index file for $1.
+make_gdb_index()
+{
+ local f="$1"
+ local d="${f%/*}"
+ # We don't care if gdb gives an error.
+ gdb --batch-silent -ex "file $f" -ex "maintenance save-gdb-index $d" > /dev/null 2>&1
+}
+
# Make a relative symlink to $1 called $3$2
shopt -s extglob
link_relative()
@@ -207,6 +216,12 @@
$strict && exit 2
fi
+ make_gdb_index "$f"
+ if [ -f "${f}.gdb-index" ]; then
+ objcopy --add-section .gdb_index="${f}.gdb-index" --set-section-flags .gdb_index=readonly "$f" "$f"
+ rm -f "${f}.gdb-index"
+ fi
+
# A binary already copied into /usr/lib/debug doesn't get stripped,
# just has its file names collected and adjusted.
case "$dn" in