From d5bcff0343ae1a4a8be76fd8646b22f20f9ed94a Mon Sep 17 00:00:00 2001 From: Bruno Larsen Date: Tue, 13 Sep 2022 18:47:05 +0200 Subject: [PATCH] Change gdb.base/skip-solib.exp deal with lack of epilogue information When running gdb.base/skip-solib.exp, the backtrace tests could fail with compilers that associated epilogue instructions with the last statement line of the function, instead of associating it with the closing brace, despite the feature being fully functional. As an example, when testing skipping the function square, the testsuite would show Breakpoint 1, main () at (...)/binutils-gdb/gdb/testsuite/gdb.base/skip-solib-main.c:5 5 return square(0); (gdb) step 0x00007ffff7cef560 in __libc_start_call_main () from /lib64/libc.so.6 (gdb) PASS: gdb.base/skip-solib.exp: ignoring solib file: step bt #0 0x00007ffff7cef560 in __libc_start_call_main () from /lib64/libc.so.6 #1 0x00007ffff7cef60c in __libc_start_main_impl () from /lib64/libc.so.6 #2 0x0000000000401065 in _start () (gdb) FAIL: gdb.base/skip-solib.exp: ignoring solib file: bt Which means that the feature is working, the testsuite is just mis-identifying it. To avoid this problem, the skipped function calls have been sent to a line before `return`, so epilogues won't factor in. --- gdb/testsuite/gdb.base/skip-solib-lib.c | 3 ++- gdb/testsuite/gdb.base/skip-solib-main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/skip-solib-lib.c b/gdb/testsuite/gdb.base/skip-solib-lib.c index b2c4d86d703..341f1440a3b 100644 --- a/gdb/testsuite/gdb.base/skip-solib-lib.c +++ b/gdb/testsuite/gdb.base/skip-solib-lib.c @@ -7,5 +7,6 @@ int multiply(int a, int b) int square(int num) { - return multiply(num, num); + int res = multiply(num, num); + return res; } diff --git a/gdb/testsuite/gdb.base/skip-solib-main.c b/gdb/testsuite/gdb.base/skip-solib-main.c index 746bb5f36bb..a3b6d417935 100644 --- a/gdb/testsuite/gdb.base/skip-solib-main.c +++ b/gdb/testsuite/gdb.base/skip-solib-main.c @@ -2,5 +2,6 @@ int square(int num); int main() { - return square(0); + int s = square(0); + return s; } -- 2.30.2