From: Guinevere Larsen Date: Mon, 14 Oct 2024 13:13:13 +0000 (-0300) Subject: gdb/testsuite: fix gdb.multi/inferior-specific-bp.exp X-Git-Tag: gdb-16-branchpoint~666 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2dbb779c83f4825619ef171ccaee9a3f664d5a34;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: fix gdb.multi/inferior-specific-bp.exp A recent commit, "16a6f7d2ee3 gdb: avoid breakpoint::clear_locations calls in update_breakpoint_locations", started checking if GDB correctly relocates a breakpoint from inferior 1's declaration of the function "bar" to inferior 2's declaration. Unfortunately, inferior 2 never calls bar in its regular execution, and because of that, clang would optimize that whole function away, making it so there is no location for the breakpoint to be relocated to. This commit changes the .c file so that the function is not optimized away and the test fully passes with clang. It is important to actually call bar instead of using __attribute__((used)) because the latter causes the breakpoint locations to be inverted, 3.1 belongs to inferior 2 and 3.2 belongs to inferior 1, which will cause an unrelated failure. Approved-By: Andrew Burgess --- diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c b/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c index bde6fbf8224..3a45c21034f 100644 --- a/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c +++ b/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c @@ -30,7 +30,8 @@ main (void) { int ret = baz (); stop_breakpt (); - return ret; + /* We have to call bar here, otherwise it might be optimized away. */ + return ret + bar (); } static int