From 2dbb779c83f4825619ef171ccaee9a3f664d5a34 Mon Sep 17 00:00:00 2001 From: Guinevere Larsen Date: Mon, 14 Oct 2024 10:13:13 -0300 Subject: 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 --- gdb/testsuite/gdb.multi/inferior-specific-bp-2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c b/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c index bde6fbf..3a45c21 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 -- cgit v1.1