testsuite, mi: avoid a clang bug in 'user-selected-context-sync.exp'
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 29 Mar 2021 14:00:41 +0000 (16:00 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 29 Mar 2021 14:52:03 +0000 (16:52 +0200)
This test causes several timeouts for Clang, taking too long time to
finish.  The reason is, for an infinite loop of the form

   while(1); /* suppose this is line 30.  */

Clang generates code that looks like

   0x00000000004004d4 <+4>:     jmp    0x4004d9 <loop+9>
   0x00000000004004d9 <+9>:     jmp    0x4004d9 <loop+9>

So, the real loop is the instruction at address 0x4004d9.  But a
breakpoint that's defined at the loop line (assume line 30 in this
case) is inserted at address 0x4004d4.

  (gdb) break 30
  Breakpoint 1 at 0x4004d4: file test.c, line 30.

Therefore, continuing a thread that was spinning on the loop does not hit
the breakpoint.  The bug is reported at

  https://bugs.llvm.org/show_bug.cgi?id=49614

Tweak the infinite loop to spin on a variable to avoid this bug.  The
test is unrelated to the bug.

gdb/testsuite/ChangeLog:
2021-03-29  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.mi/user-selected-context-sync.exp: Spin on a variable in
the infinite loop to avoid a Clang bug.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.mi/user-selected-context-sync.c

index 01d781f1905a9000db14ec8f6a4b8cb2f90e53ff..628261b5fbe15ae0f783ccdfd0a899aed83d5c30 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-29  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       * gdb.mi/user-selected-context-sync.exp: Spin on a variable in
+       the infinite loop to avoid a Clang bug.
+
 2021-03-26  Will Schmidt  <will_schmidt@vnet.ibm.com>
 
        * gdb.arch/powerpc-disassembler-options.exp: Extend some test
index 500a118a2dcece66d9f6754349ddcb33c0f805fe..9818f30277fe1dde14b62d7eb7b177c59eedfedb 100644 (file)
@@ -27,7 +27,10 @@ static pthread_barrier_t barrier;
 static void
 child_sub_function (void)
 {
-  while (1); /* thread loop line */
+  /* Deliberately spin on a variable instead of plain 'while (1)' to
+     avoid the Clang bug https://bugs.llvm.org/show_bug.cgi?id=49614.  */
+  int spin = 1;
+  while (spin); /* thread loop line */
 }
 
 static void *
@@ -57,7 +60,10 @@ main (void)
 
   pthread_barrier_wait (&barrier);
 
-  while (1); /* main break line */
+  /* Deliberately spin on a variable instead of plain 'while (1)' to
+     avoid the Clang bug https://bugs.llvm.org/show_bug.cgi?id=49614.  */
+  int spin = 1;
+  while (spin); /* main break line */
 
   return 0;
 }
This page took 0.034438 seconds and 4 git commands to generate.