public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/4] [gdb/testsuite] Fix build-ids in gdb.dwarf2/dwzbuildid.exp
@ 2023-09-08 10:28 Tom de Vries
  2023-09-08 10:28 ` [pushed 2/4] [gdb/testsuite] Add aranges " Tom de Vries
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom de Vries @ 2023-09-08 10:28 UTC (permalink / raw)
  To: gdb-patches

When looking at the execs from test-case gdb.dwarf2/dwzbuildid.exp using
readelf, I run into:
...
$ readelf -w dwzbuildid-ok > READELF
readelf: Warning: Corrupt debuglink section: .gnu_debugaltlink
readelf: Warning: Build-ID is too short (0x6 bytes)
...

Fix this by ensuring the Build-IDs are the required 20 bytes.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/dwzbuildid.exp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
index ba9db41ba61..1aad712e32c 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
@@ -90,11 +90,11 @@ if  { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
 
 # The values don't really matter, just whether they are equal.
 set ok_prefix 01
-set ok_suffix 0203040506
-set ok_suffix2 02030405ff
+set ok_suffix 02030405060708091011121314151617181920
+set ok_suffix2 020304050607080910111213141516171819ff
 set ok_buildid ${ok_prefix}${ok_suffix}
 set ok_buildid2 ${ok_prefix}${ok_suffix2}
-set bad_buildid ffffffffffff
+set bad_buildid [string repeat ff 20]
 
 set debugdir [standard_output_file {}]
 set basedir $debugdir/.build-id

base-commit: 932a49fff332ba4921dc9e38cf45bf65a301f2c6
-- 
2.35.3


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

* [pushed 2/4] [gdb/testsuite] Add aranges in gdb.dwarf2/dwzbuildid.exp
  2023-09-08 10:28 [pushed 1/4] [gdb/testsuite] Fix build-ids in gdb.dwarf2/dwzbuildid.exp Tom de Vries
@ 2023-09-08 10:28 ` Tom de Vries
  2023-09-08 10:28 ` [pushed 3/4] [gdb/testsuite] Add kfail " Tom de Vries
  2023-09-08 10:28 ` [pushed 4/4] [gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust Tom de Vries
  2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2023-09-08 10:28 UTC (permalink / raw)
  To: gdb-patches

While investigating the execs of gdb.dwarf2/dwzbuildid.exp using readelf I ran
into a warning:
...
$ readelf -w dwzbuildid-ok > READELF
readelf: Warning: .debug_info offset of 0x2e in .debug_aranges section does not
point to a CU header.
...

AFAICT, the warning is incorrect, I've filed PR binutils/30835 about that.

While looking at the .debug_aranges section, I noticed that the entries for
the CUs generated by the dwarf assembler are missing.

Fix this by adding the missing .debug_aranges entries.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/dwzbuildid.exp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
index 1aad712e32c..721aef8d344 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
@@ -46,10 +46,13 @@ proc write_just_debugaltlink {filename dwzname buildid} {
 
 	# Only the DWARF reader checks .gnu_debugaltlink, so make sure
 	# there is a bit of DWARF in here.
-	cu {} {
+	cu { label cu_start } {
 	    compile_unit {{language @DW_LANG_C}} {
 	    }
 	}
+	aranges {} cu_start {
+	    arange {} 0 0
+	}
     }
 }
 
@@ -65,7 +68,7 @@ proc write_dwarf_file {filename buildid {value 99}} {
 
 	build_id $buildid
 
-	cu {} {
+	cu { label cu_start } {
 	    compile_unit {{language @DW_LANG_C}} {
 		int_label2: base_type {
 		    {name int}
@@ -80,6 +83,10 @@ proc write_dwarf_file {filename buildid {value 99}} {
 		}
 	    }
 	}
+
+	aranges {} cu_start {
+	    arange {} 0 0
+	}
     }
 }
 
-- 
2.35.3


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

* [pushed 3/4] [gdb/testsuite] Add kfail in gdb.dwarf2/dwzbuildid.exp
  2023-09-08 10:28 [pushed 1/4] [gdb/testsuite] Fix build-ids in gdb.dwarf2/dwzbuildid.exp Tom de Vries
  2023-09-08 10:28 ` [pushed 2/4] [gdb/testsuite] Add aranges " Tom de Vries
@ 2023-09-08 10:28 ` Tom de Vries
  2023-09-08 10:28 ` [pushed 4/4] [gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust Tom de Vries
  2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2023-09-08 10:28 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.dwarf2/dwzbuildid.exp using target board readnow, I
get:
...
(gdb) file dwzbuildid-mismatch^M
Reading symbols from dwzbuildid-mismatch...^M
warning: File "dwzbuildid5.o" has a different build-id, file skipped^M
could not find '.gnu_debugaltlink' file for dwzbuildid-mismatch^M
(gdb) delete breakpoints^M
(gdb) info breakpoints^M
No breakpoints or watchpoints.^M
(gdb) break -qualified main^M
No symbol table is loaded.  Use the "file" command.^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.dwarf2/dwzbuildid.exp: mismatch: gdb_breakpoint: set breakpoint at main
...

This is PR symtab/26797: when using readnow, a failure in reading the dwarf
results in the minimal symbols not being available.

Add a corresponding KFAIL.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/dwzbuildid.exp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
index 721aef8d344..81cefc60dfc 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
@@ -160,6 +160,13 @@ foreach testname {ok mismatch fallback} {
 
 	gdb_load ${binfile}-${testname}
 
+	if { $testname == "mismatch" && [readnow] } {
+	    # Main is found in the minimal symbols.  When using readnow, a
+	    # failure to read the dwarf also causes the minimal symbols to be
+	    # unavailable.
+	    # Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
+	    setup_kfail "symtab/26797" *-*-*
+	}
 	if {[runto_main]} {
 	    if {$testname == "mismatch"} {
 		gdb_test "print the_int" \
-- 
2.35.3


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

* [pushed 4/4] [gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust
  2023-09-08 10:28 [pushed 1/4] [gdb/testsuite] Fix build-ids in gdb.dwarf2/dwzbuildid.exp Tom de Vries
  2023-09-08 10:28 ` [pushed 2/4] [gdb/testsuite] Add aranges " Tom de Vries
  2023-09-08 10:28 ` [pushed 3/4] [gdb/testsuite] Add kfail " Tom de Vries
@ 2023-09-08 10:28 ` Tom de Vries
  2 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2023-09-08 10:28 UTC (permalink / raw)
  To: gdb-patches

I ran test-case gdb.dwarf2/dwzbuildid.exp with target board cc-with-gdb-index,
and noticed that compilation failure for one exec prohibited testing of all
execs.

Fix this by restructuring the test-case, such that we have:
...
PASS: gdb.dwarf2/dwzbuildid.exp: testname=ok: set debug-file-directory
PASS: gdb.dwarf2/dwzbuildid.exp: testname=ok: print the_int
UNSUPPORTED: gdb.dwarf2/dwzbuildid.exp: testname=mismatch: compilation failed
UNSUPPORTED: gdb.dwarf2/dwzbuildid.exp: testname=fallback: compilation failed
...

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/dwzbuildid.exp | 70 ++++++++++++-------------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
index 81cefc60dfc..76e3a7d6e42 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
@@ -134,46 +134,46 @@ for {set i 2} {$i <= 8} {incr i} {
 # Copy a file into the .build-id place for the "fallback" test.
 file copy -force -- ${binfile}8.o $basedir/$ok_prefix/$ok_suffix2.debug
 
-# Link the executables.
-if {[gdb_compile [list ${binfile}1.o ${binfile}2.o] ${binfile}-ok \
-	 executable {}] != ""} {
-    return -1
-}
-
-if {[gdb_compile [list ${binfile}1.o ${binfile}4.o] ${binfile}-mismatch \
-	 executable {quiet}] != ""} {
-    return -1
-}
+proc do_test {} {
+    clean_restart
 
-if {[gdb_compile [list ${binfile}1.o ${binfile}6.o] ${binfile}-fallback \
-	 executable {}] != ""} {
-    return -1
-}
+    gdb_test_no_output "set debug-file-directory $::debugdir" \
+	"set debug-file-directory"
 
+    gdb_load ${::binfile}-${::testname}
 
-foreach testname {ok mismatch fallback} {
-    with_test_prefix $testname {
-	clean_restart
+    if { $::testname == "mismatch" && [readnow] } {
+	# Main is found in the minimal symbols.  When using readnow, a
+	# failure to read the dwarf also causes the minimal symbols to be
+	# unavailable.
+	# Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
+	setup_kfail "symtab/26797" *-*-*
+    }
+    if {![runto_main]} {
+	return
+    }
 
-	gdb_test_no_output "set debug-file-directory $debugdir" \
-	    "set debug-file-directory"
+    if {$::testname == "mismatch"} {
+	gdb_test "print the_int" \
+	    "(No symbol table is loaded|No symbol \"the_int\" in current context).*"
+    } else {
+	gdb_test "print the_int" " = 99"
+    }
+}
 
-	gdb_load ${binfile}-${testname}
+foreach_with_prefix testname { ok mismatch fallback } {
+    if { $testname == "ok" } {
+	set objs [list ${binfile}1.o ${binfile}2.o]
+    } elseif { $testname == "mismatch" } {
+	set objs [list ${binfile}1.o ${binfile}4.o]
+    } elseif { $testname == "fallback" } {
+	set objs [list ${binfile}1.o ${binfile}6.o]
+    }
 
-	if { $testname == "mismatch" && [readnow] } {
-	    # Main is found in the minimal symbols.  When using readnow, a
-	    # failure to read the dwarf also causes the minimal symbols to be
-	    # unavailable.
-	    # Setup a kfail for "FAIL: gdb_breakpoint: set breakpoint at main".
-	    setup_kfail "symtab/26797" *-*-*
-	}
-	if {[runto_main]} {
-	    if {$testname == "mismatch"} {
-		gdb_test "print the_int" \
-		    "(No symbol table is loaded|No symbol \"the_int\" in current context).*"
-	    } else {
-		gdb_test "print the_int" " = 99"
-	    }
-	}
+    if {[gdb_compile $objs ${binfile}-$testname executable {quiet}] != ""} {
+	unsupported "compilation failed"
+	continue
     }
+
+    do_test
 }
-- 
2.35.3


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

end of thread, other threads:[~2023-09-08 10:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 10:28 [pushed 1/4] [gdb/testsuite] Fix build-ids in gdb.dwarf2/dwzbuildid.exp Tom de Vries
2023-09-08 10:28 ` [pushed 2/4] [gdb/testsuite] Add aranges " Tom de Vries
2023-09-08 10:28 ` [pushed 3/4] [gdb/testsuite] Add kfail " Tom de Vries
2023-09-08 10:28 ` [pushed 4/4] [gdb/testsuite] Make gdb.dwarf2/dwzbuildid.exp more robust Tom de Vries

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