From: Tom de Vries Date: Fri, 18 Jul 2025 17:51:46 +0000 (+0200) Subject: [gdb/testsuite] Fix gdb.arch/amd64-disp-step-self-call.exp on freebsd X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfbf9925c1c34f9e9d47c8b29d165866557663e3;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix gdb.arch/amd64-disp-step-self-call.exp on freebsd On x86_64-freebsd, with test-case gdb.arch/amd64-disp-step-self-call.exp, I run into: ... (gdb) continue Continuing. Program received signal SIGBUS, Bus error. Object-specific hardware error. 0x000000080051492c in alarm () from /lib/libc.so.7 (gdb) FAIL: $exp: continue to breakpoint: test_call ... The behaviour is not specific to gdb, it can be reproduced by running the test-case executable: ... $ ./outputs/gdb.arch/amd64-disp-step-self-call/amd64-disp-step-self-call Bus error (core dumped) $ ... The bus error happens when executing this instruction in alarm: ... 0000000000093910 : ... 9392c: 0f 29 45 d0 movaps %xmm0, -0x30(%rbp) ... because $rbp is not 16-byte aligned. This can be fixed by adding the missing frame setup instructions at the start of main in amd64-disp-step-self-call.S: ... main: + pushq %rbp + movq %rsp, %rbp ... Instead, fix this by moving main from the assembly file to the c file, which has the same effect. Also remove the done label, which looks like a copy-past left-over. Instead, add an unreachable function and use it where appropriate. Do the same for i386 case (which makes the source files identical for the amd64 and i386 case, but I decided to leave it like that). Tested on x86_64-freebsd and x86_64-linux. --- diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c index 03b868c4abf..0fb2904a982 100644 --- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c +++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c @@ -16,9 +16,27 @@ along with this program. If not, see . */ #include +#include + +extern void test_call (void); + +void +unreachable (void) +{ + abort (); +} void setup_alarm (void) { alarm (300); } + +int +main () +{ + setup_alarm (); + test_call (); + unreachable (); + return 0; +} diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S index 78a6859f21f..20a8eb7b58c 100644 --- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S +++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S @@ -18,33 +18,12 @@ handling. */ .text - - .global main -main: - nop - - callq setup_alarm - - nop - -/***********************************************/ - -/* test call/ret */ - .global test_call test_call: call test_call - nop + call unreachable .global test_ret_end test_ret_end: nop -/***********************************************/ - -/* all done */ - -done: - mov $0,%rdi - call exit - hlt .section .note.GNU-stack,"",@progbits diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c b/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c index 03b868c4abf..0fb2904a982 100644 --- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c +++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c @@ -16,9 +16,27 @@ along with this program. If not, see . */ #include +#include + +extern void test_call (void); + +void +unreachable (void) +{ + abort (); +} void setup_alarm (void) { alarm (300); } + +int +main () +{ + setup_alarm (); + test_call (); + unreachable (); + return 0; +} diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S index 466e50ccf3e..20a8eb7b58c 100644 --- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S +++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S @@ -18,33 +18,12 @@ handling. */ .text - - .global main -main: - nop - - call setup_alarm - - nop - -/***********************************************/ - -/* test call/ret */ - .global test_call test_call: call test_call - nop + call unreachable .global test_ret_end test_ret_end: nop -/***********************************************/ - -/* all done */ - -done: - pushl $0 - call exit - hlt .section .note.GNU-stack,"",@progbits