[PATCH] [gdb/testsuite] Use -nostdlib in gdb.linespec/explicit.exp

Tom de Vries tdevries@suse.de
Wed Dec 18 19:39:04 GMT 2024


On openSUSE Leap 15.6 ppc64le-linux, with gdb.linespec/explicit.exp I run
into:
...
(gdb) b -source thread_pointer.h FAIL: $exp: complete after -source: tab complete "b -source thr"
Quit^M
...

The test-case already contains a related workaround:
...
	# Get rid of symbols from shared libraries, otherwise
	# "b -source thr<tab>" could find some system library's
	# source.
	gdb_test_no_output "nosharedlibrary"
...
but that doesn't work in this case because the debug info is in the executable
itself:
...
 The File Name Table (offset 0xb5):
  Entry Dir     Time    Size    Name
  1     0       0       0       abi-note.c
  2     1       0       0       types.h
  3     2       0       0       stdint-intn.h
  4     2       0       0       stdint-uintn.h
  5     3       0       0       elf.h
  6     4       0       0       thread_pointer.h
...
due to debug info in some glibc object file.

Fix this by:
- using -nostdlib, ensuring only debug info from the three test-case sources
  is present in the executable, and
- adding a _start wrapping main.

Tested on x86_64-linux and ppc64le-linux.

PR testsuite/31229
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31229
---
 gdb/testsuite/gdb.linespec/explicit.c   | 6 ++++++
 gdb/testsuite/gdb.linespec/explicit.exp | 7 ++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.linespec/explicit.c b/gdb/testsuite/gdb.linespec/explicit.c
index 7d232164dac..957de50b4d1 100644
--- a/gdb/testsuite/gdb.linespec/explicit.c
+++ b/gdb/testsuite/gdb.linespec/explicit.c
@@ -69,3 +69,9 @@ main (void)
 
   return myfunction2 (j);
 }
+
+void
+_start (void)
+{
+  main ();
+}
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index e8ae10a27df..b257a9808ea 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -20,8 +20,13 @@ load_lib completion-support.exp
 standard_testfile explicit.c explicit2.c 3explicit.c
 set exefile $testfile
 
+set opts {}
+lappend opts debug
+lappend opts nowarnings
+lappend opts additional_flags=-nostdlib
+
 if {[prepare_for_testing "failed to prepare" $exefile \
-	 [list $srcfile $srcfile2 $srcfile3] {debug nowarnings}]} {
+	 [list $srcfile $srcfile2 $srcfile3] $opts]} {
     return -1
 }
 

base-commit: c672efba42291fa43bf2238fb3b2c4b90f5c7fef
-- 
2.43.0



More information about the Gdb-patches mailing list