This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix wp-replication.exp on llvm


Hi.

This test runs forever when compiled with llvm because the
breakpoint used to "runto main" is continually hit which
wp-replication.exp assumes doesn't happen.
This doesn't happen with at least relatively recent versions
of gcc due to different code generation.
With gcc note the jump over the call to empty_cycle.
gdb puts the breakpoint there serendipitously making the test pass.

(gdb) disas main
Dump of assembler code for function main:
   0x0000000000400a9c <+0>:	push   %rbp
   0x0000000000400a9d <+1>:	mov    %rsp,%rbp
   0x0000000000400aa0 <+4>:	sub    $0x60,%rsp
=> 0x0000000000400aa4 <+8>:	jmp    0x400aab <main+15>
   0x0000000000400aa6 <+10>:	callq  0x400a8c <empty_cycle>
   0x0000000000400aab <+15>:	mov    0x817(%rip),%eax        # 0x4012c8 <watch_count_done>
   0x0000000000400ab1 <+21>:	test   %eax,%eax
   0x0000000000400ab3 <+23>:	je     0x400aa6 <main+10>

int
main ()
{
  int res;
  pthread_t threads[NR_THREADS];
  int i;

  while (watch_count_done == 0)
    {
      /* GDB will modify the value of "i" at runtime and we will
	 get past this point.  */
      empty_cycle ();
    }

I first fixed this by adding an option to runto_main to use a
temporary breakpoint.  I'm sending that patch separately RFC -
I'm ambivalent on what The Right fix is, but this is simple and
straightforward enough.

I will check this in in a few days if there are no objections.
Tested with gcc,llvm on amd64-linux.

2013-05-21  Doug Evans  <dje@google.com>

	* gdb.threads/wp-replication.c (main): Insert some code at the start
	to ensure the breakpoint on main is only hit once.  Fix comment.

Index: testsuite/gdb.threads/wp-replication.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/wp-replication.c,v
retrieving revision 1.1
diff -u -p -r1.1 wp-replication.c
--- testsuite/gdb.threads/wp-replication.c	7 May 2013 07:43:33 -0000	1.1
+++ testsuite/gdb.threads/wp-replication.c	22 May 2013 00:21:18 -0000
@@ -75,10 +75,14 @@ main ()
   pthread_t threads[NR_THREADS];
   int i;
 
+  /* Something to ensure that the breakpoint used to run to main
+     is only hit once.  */
+  empty_cycle ();
+
   while (watch_count_done == 0)
     {
-      /* GDB will modify the value of "i" at runtime and we will
-	 get past this point.  */
+      /* GDB will modify the value of "watch_count_done" at runtime and we
+	 will get past this point.  */
       empty_cycle ();
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]