Patchwork [RFC,gdb/contrib] Fix gdb/contrib/ for dwz-m-ed execs

mail settings
Submitter Simon Marchi
Date May 12, 2019, 7:49 p.m.
Message ID <>
Download mbox | patch
Permalink /patch/32655/
State New
Headers show


Simon Marchi - May 12, 2019, 7:49 p.m.
On 2019-05-07 12:13 p.m., Tom de Vries wrote:
> [ was: Re: [PATCH][gdb] Write index for dwz -m file ]
> Hi,
> This is a follow-up patch for "[gdb] Write index for dwz -m file".
> Any comments on the updated gdb/contrib/ script?
> In particular, I'd like some advice on whether I should add shell
> variables (as I've done for readelf) for grep, tail and sed.
> Thanks,
> - Tom

Hi Tom,

I think it can be useful to override gdb, readelf and objcopy, as it is likely
that people will want to use specific versions of these (either newer, or
specific to their architectures).

But it's not very likely for grep, tail and sed, as long as we make sure that
we are compatible with the BSD versions of these tools.  That would mean making
sure we only use features defined by POSIX.

One case that isn't handled correct by GDB and/or the script (with both my and
your patch applied) is running the script on two executables that share the same
external dwz file.  It will fail adding the index to the dwz file the second time.
This use case is kind of important, because the point of having dwz files is to
share it between multiple executables.

This is what I get the second time:

$ GDB="/home/simark/build/binutils-gdb/gdb/gdb --data-directory=/home/simark/build/binutils-gdb/gdb/data-directory" ~/src/binutils-gdb/gdb/contrib/ b
+ objcopy --add-section .gdb_index=shared-debug-info.dwz.gdb-index --set-section-flags .gdb_index=readonly shared-debug-info.dwz shared-debug-info.dwz
objcopy:std9IdCI: can't add section '.gdb_index': file in wrong format

I haven't looked in more details for this problem.

There's a buglet in the clean up code causing the dwz file's index
(shared-debug-info.dwz.gdb-index in my case) to be left in the current directory after
running the script (even successfully).  This fixes it:



diff --git a/gdb/contrib/ b/gdb/contrib/
index afedce0c848d..2b3af2e84f71 100755
--- a/gdb/contrib/
+++ b/gdb/contrib/
@@ -70,7 +70,7 @@  for f in "$file" "$dwz_file"; do
     if [ "$f" = "" ]; then
-    set_files "$file"
+    set_files "$f"
     tmp_files="$tmp_files $index4 $index5 $debugstr $debugstrmerge $debugstrerr"