From: Tom de Vries Date: Thu, 14 Aug 2025 12:53:19 +0000 (+0200) Subject: [gdb/testsuite] Stop on main in gdb.gdb/{python-helper,selftest}.exp X-Git-Tag: gdb-17-branchpoint~327 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76060b138dbc0faa70a5da2af8519a0ae469caa2;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Stop on main in gdb.gdb/{python-helper,selftest}.exp 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. --- diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp index 8126740c301..7f91278c593 100644 --- a/gdb/testsuite/gdb.gdb/python-helper.exp +++ b/gdb/testsuite/gdb.gdb/python-helper.exp @@ -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 diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp index 1cf92657e50..3948fce44a2 100644 --- a/gdb/testsuite/gdb.gdb/selftest.exp +++ b/gdb/testsuite/gdb.gdb/selftest.exp @@ -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 } diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp index e037664427c..97be023b04e 100644 --- a/gdb/testsuite/lib/selftest-support.exp +++ b/gdb/testsuite/lib/selftest-support.exp @@ -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