]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: fix gdb.multi/inferior-specific-bp.exp
authorGuinevere Larsen <guinevere@redhat.com>
Mon, 14 Oct 2024 13:13:13 +0000 (10:13 -0300)
committerGuinevere Larsen <guinevere@redhat.com>
Mon, 14 Oct 2024 14:55:38 +0000 (11:55 -0300)
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 <aburgess@redhat.com>
gdb/testsuite/gdb.multi/inferior-specific-bp-2.c

index bde6fbf8224db21b1c2cbbdb6eab55da72ddbd00..3a45c21034f66fd4cbd2fb2575e24c2ef3a99b52 100644 (file)
@@ -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