public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/31754] New: [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency on readelf
@ 2024-05-19  8:48 vries at gcc dot gnu.org
  2024-05-20  7:33 ` [Bug testsuite/31754] " vries at gcc dot gnu.org
  2024-05-22  6:05 ` vries at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2024-05-19  8:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31754

            Bug ID: 31754
           Summary: [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency
                    on readelf
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: testsuite
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I tried out test-case gdb.base/style.exp with target board fission and clang,
and ran into:
...
gdb compile failed, clang-15.0: warning: -Wl,--gdb-index: 'linker' input unused
[-Wunused-command-line-argument]
clang-15.0: warning: argument unused during compilation: '-fuse-ld=gold'
[-Wunused-command-line-argument]
...

So I tried dropping these from fission.exp, and that worked (using some gdb
patches attempting to fix some fission issues, so with current trunk YMMV).

Then I tried target board fission-dwp, and that also worked.

Then I changed the dwarf version from 4 to 5 in fission.exp.

That's gave FAILs, I'm not yet sure why.  Also dropping -ggnu-pubnames or
-fdebug-types-section or both didn't change that.

Anyway, now when running fission-dwp, I ran into:
...
Running /data/vries/gdb/src/gdb/testsuite/gdb.base/style.exp ...
gdb compile failed, dwp: error: cannot open clang: No such file or directory
dwp: fatal error: clang: can't open
...

So what happened?

cc-with-tweaks.sh uses readelf to find the .dwo files to put into the dwarf
package.

And it finds:
...
$ readelf -wi
/data/vries/gdb/leap-15-5/build/gdb/testsuite/outputs/gdb.base/style/style |
grep _dwo_name
    <c4>   DW_AT_dwo_name    : (indexed string: 0x1):
/data/vries/gdb/leap-15-5/build/gdb/testsuite/outputs/gdb.base/style/style0.dwo
    <19>   DW_AT_dwo_name    : (indexed string: 0x15): clang version 15.0.7
...

The first one is from the exec:
...
  Compilation Unit @ offset 0xa6:
   Length:        0x24 (32-bit)
   Version:       5
   Unit Type:     DW_UT_skeleton (4)
   Abbrev Offset: 0x66
   Pointer Size:  8
   DWO ID:        0x7eb7fb2d9334b72a
 <0><ba>: Abbrev Number: 1 (DW_TAG_skeleton_unit)
    <bb>   DW_AT_stmt_list   : 0xe3
    <bf>   DW_AT_str_offsets_base: 0x8
    <c3>   DW_AT_comp_dir    : (indexed string: 0):
/data/vries/gdb/leap-15-5/build/gdb/testsuite
    <c4>   DW_AT_GNU_pubnames: 1
    <c4>   DW_AT_dwo_name    : (indexed string: 0x1):
/data/vries/gdb/leap-15-5/build/gdb/testsuite/outputs/gdb.base/\
style/style0.dwo
    <c5>   DW_AT_low_pc      : (index: 0x3): 0x680
    <c6>   DW_AT_high_pc     : 0x31
    <ca>   DW_AT_addr_base   : 0x8
...
and the second one from the .dwo file:
...
  Compilation Unit @ offset 0:
   Length:        0xd9 (32-bit)
   Version:       5
   Unit Type:     DW_UT_split_compile (5)
   Abbrev Offset: 0
   Pointer Size:  8
   DWO ID:        0x7eb7fb2d9334b72a
 <0><14>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <15>   DW_AT_producer    : (indexed string: 0x13): argc
    <16>   DW_AT_language    : 12       (ANSI C99)
    <18>   DW_AT_name        : (indexed string: 0x14): argv
    <19>   DW_AT_dwo_name    : (indexed string: 0x15): clang version 15.0.7
    <1a>   DW_AT_macros      : 0
...

We see the same if we apply readelf just to the .dwo file, while with
llvm-dwarfdump we have:
...
0x00000014: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 15.0.7")
              DW_AT_language    (DW_LANG_C99)
              DW_AT_name       
("/data/vries/gdb/src/gdb/testsuite/gdb.base/style.c")
              DW_AT_dwo_name   
("/data/vries/gdb/leap-15-5/build/gdb/testsuite/outputs/gdb.base/style/style0.dwo")
              DW_AT_macros      (0x00000000)
...

Possibly a readelf issue that needs fixing.

BTW, this is with system readelf 2.41.0, but with a readelf built from current
trunk I see the same.

This can be worked around like so:
...
diff --git a/gdb/contrib/cc-with-tweaks.sh b/gdb/contrib/cc-with-tweaks.sh
index f760bd7c0a1..546e4fd20b9 100755
--- a/gdb/contrib/cc-with-tweaks.sh
+++ b/gdb/contrib/cc-with-tweaks.sh
@@ -280,7 +280,7 @@ elif [ "$want_multi" = true ]; then
 fi

 if [ "$want_dwp" = true ]; then
-    dwo_files=$($READELF -wi "${output_file}" | grep _dwo_name | \
+    dwo_files=$($READELF -wi --debug-dump=no-follow-links "${output_file}" |
grep _dwo_name | \
        sed -e 's/^.*: //' | sort | uniq)
     rc=0
     if [ -n "$dwo_files" ]; then
...

But I wonder if there's some way to just drop the dependency on readelf.  The
want_dwp option in cc-with-tweaks.sh is the only option using it.

Maybe just assume a .dwo file for each .o file in the link line?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug testsuite/31754] [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency on readelf
  2024-05-19  8:48 [Bug testsuite/31754] New: [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency on readelf vries at gcc dot gnu.org
@ 2024-05-20  7:33 ` vries at gcc dot gnu.org
  2024-05-22  6:05 ` vries at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2024-05-20  7:33 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31754

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> Possibly a readelf issue that needs fixing.

https://sourceware.org/pipermail/binutils/2024-May/134156.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug testsuite/31754] [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency on readelf
  2024-05-19  8:48 [Bug testsuite/31754] New: [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency on readelf vries at gcc dot gnu.org
  2024-05-20  7:33 ` [Bug testsuite/31754] " vries at gcc dot gnu.org
@ 2024-05-22  6:05 ` vries at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: vries at gcc dot gnu.org @ 2024-05-22  6:05 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31754

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/pipermail/gdb-patches/2024-May/209306.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2024-05-22  6:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19  8:48 [Bug testsuite/31754] New: [gdb/testsuite] Eliminate cc-with-tweaks.sh dependency on readelf vries at gcc dot gnu.org
2024-05-20  7:33 ` [Bug testsuite/31754] " vries at gcc dot gnu.org
2024-05-22  6:05 ` vries at gcc dot gnu.org

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