]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Stop on main in gdb.gdb/{python-helper,selftest}.exp
authorTom de Vries <tdevries@suse.de>
Thu, 14 Aug 2025 12:53:19 +0000 (14:53 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 14 Aug 2025 12:53:19 +0000 (14:53 +0200)
With a gdb build with gcc 15.1.1 and "-O2 -flto=auto -g", I run into:
...
UNTESTED: gdb.gdb/selftest.exp: \
  Cannot set breakpoint at captured_main, skipping testcase.
UNTESTED: gdb.gdb/python-helper.exp: \
  Cannot set breakpoint at captured_main, skipping testcase.
...

I don't know why we're trying to stop in captured_main.

Stopping in main also works, and main is more likely to be present in an lto
build.

Fix this by using main instead.

This requires us to update the expected file name from main.c to gdb.c in
selftest_setup.

After doing so, we get:
...
XFAIL: gdb.gdb/selftest.exp: \
  run until breakpoint at main (line numbers scrambled?)
XFAIL: gdb.gdb/python-helper.exp: \
run until breakpoint at main (line numbers scrambled?)
...
because main is reported to be in run-on-main-thread.c instead of gdb.c:
.
Breakpoint 1, main (...) at gdb/run-on-main-thread.c:120^M
...

This is due to picking the last line entry for pc == 0x455e40 that has
is_stmt == true:
...
File name                      Line number    Starting address    View    Stmt

gdb/gdb.c:
gdb.c                                   25            0x455e40               x
gdb.c                                   30            0x455e40       1       x

gdb/run-on-main-thread.c:
run-on-main-thread.c                   116            0x455e40       2       x
run-on-main-thread.c                   120            0x455e40       3       x

gdb/gdb.c:
gdb.c                                   25            0x455e40       4

/usr/include/c++/15/bits/std_thread.h:
std_thread.h                           366            0x455e4b
...

While we're at it, update the corresponding gdb_test_multiple in
selftest_setup using multi_line and -wrap.

Tested on x86_64-linux.

gdb/testsuite/gdb.gdb/python-helper.exp
gdb/testsuite/gdb.gdb/selftest.exp
gdb/testsuite/lib/selftest-support.exp

index 8126740c30175cb88db19ab70c76fa012b0f9ed2..7f91278c5933aa1ea208ecbc1dea4b77fdb191bb 100644 (file)
@@ -291,4 +291,4 @@ proc test_python_helper {} {
 }
 
 # Use the self-test framework to run the test.
-do_self_tests captured_main test_python_helper
+do_self_tests main test_python_helper
index 1cf92657e50ced747f15259273c313150fde9145..3948fce44a24d4884ad2c0aaac2525447b281caf 100644 (file)
@@ -167,5 +167,5 @@ proc test_with_self { } {
 
 save_vars { INTERNAL_GDBFLAGS } {
     set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS]
-    do_self_tests captured_main test_with_self
+    do_self_tests main test_with_self
 }
index e037664427c1ceb5c25ecd5513785e7d630701c4..97be023b04e7acf7b2efc9f9835885ea0cf01021 100644 (file)
@@ -72,21 +72,39 @@ proc selftest_setup { executable function } {
     # run yourself
 
     set description "run until breakpoint at $function"
+    set re_hs {[^\r\n]+}
+    set re_args [string cat \
+                    [string_to_regexp "("] \
+                    $re_hs \
+                    [string_to_regexp ")"]]
+    set re_pass \
+       [multi_line \
+            "Starting program: $re_hs" \
+            ".*" \
+            [string cat "Breakpoint $::decimal, $function $re_args at" \
+                 " ${re_hs}gdb.c:$re_hs"] \
+            ".*"]
+    set re_xfail \
+       [multi_line \
+            "Starting program: $re_hs" \
+            ".*" \
+            "Breakpoint $::decimal, $function $re_args$re_hs" \
+            ".*"]
     gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
-        -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).* at .*main.c:.*$gdb_prompt $" {
-            pass "$description"
-        }
-        -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).*$gdb_prompt $" {
-            xfail "$description (line numbers scrambled?)"
-        }
-        -re "vfork: No more processes.*$gdb_prompt $" {
-            fail "$description (out of virtual memory)"
-            return -1
-        }
-        -re ".*$gdb_prompt $" {
-            fail "$description"
-            return -1
-        }
+       -re -wrap $re_pass {
+           pass $description
+       }
+       -re -wrap $re_xfail {
+           xfail "$description (line numbers scrambled?)"
+       }
+       -re -wrap "vfork: No more processes.*" {
+           fail "$description (out of virtual memory)"
+           return -1
+       }
+       -re -wrap "" {
+           fail $description
+           return -1
+       }
     }
 
     return 0