Skip to content

Instantly share code, notes, and snippets.

@mheffner
Created August 18, 2009 16:36
Show Gist options
  • Save mheffner/169818 to your computer and use it in GitHub Desktop.
Save mheffner/169818 to your computer and use it in GitHub Desktop.
$ gdb condwait_test
<snip LICENSE>
(gdb) set environment LD_PRELOAD ./condwait_wrap.so
(gdb) b condwait_test.c:17
Breakpoint 1 at 0x400864: file condwait_test.c, line 17.
(gdb) r
Starting program: condwait_test
[Thread debugging using libthread_db enabled]
[New Thread 0x7ffff7dd3910 (LWP 603)]
[Switching to Thread 0x7ffff7dd3910 (LWP 603)]
Breakpoint 1, thr_start (data=0x0) at condwait_test.c:17
17 pthread_cond_wait(&cond, &mut);
(gdb) s
pthread_cond_wait (cond=0x600d80, mutex=0x600dc0) at condwait_wrap.c:24
24 printf("Calling func condwait with cond: %p, mutex: %p...",
(gdb) n
26 fflush(stdout);
(gdb) n
Calling func condwait with cond: 0x600d80, mutex: 0x600dc0...27 ret = condwait_internal(cond, mutex);
(gdb) s
__pthread_cond_wait_2_0 (cond=0x600d80, mutex=0x600dc0) at old_pthread_cond_wait.c:32
32 {
Current language: auto; currently minimal
(gdb) bt
#0 __pthread_cond_wait_2_0 (cond=0x600d80, mutex=0x600dc0) at old_pthread_cond_wait.c:32
#1 0x00007ffff7dfb777 in pthread_cond_wait (cond=0x600d80, mutex=0x600dc0) at condwait_wrap.c:27
#2 0x0000000000400873 in thr_start (data=0x0) at condwait_test.c:17
#3 0x0000003cf900686a in start_thread (arg=<value optimized out>) at pthread_create.c:297
#4 0x0000003cf84de39d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5 0x0000000000000000 in ?? ()
gdb) n
33 if (cond->cond == NULL)
(gdb) n
32 {
(gdb) n
33 if (cond->cond == NULL)
(gdb)
38 newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
(gdb)
39 if (newcond == NULL)
(gdb)
38 newcond = (pthread_cond_t *) calloc (sizeof (pthread_cond_t), 1);
(gdb)
39 if (newcond == NULL)
(gdb)
50 if (atomic_compare_and_exchange_bool_acq (&cond->cond, newcond, NULL))
(gdb)
52 free (newcond);
(gdb) print *cond
$1 = {cond = 0x7ffff00008c0}
(gdb)
55 return __pthread_cond_wait (cond->cond, mutex);
(gdb) s
56 }
(gdb)
__pthread_cond_wait_2_0 (cond=<value optimized out>, mutex=<value optimized out>)
at old_pthread_cond_wait.c:55
55 return __pthread_cond_wait (cond->cond, mutex);
(gdb) print /x $rdi
$2 = 0x7ffff00008c0
(gdb) s
pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:155
155 pushq %r12
Current language: auto; currently asm
(gdb) bt
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:155
#1 0x00007ffff7dfb777 in pthread_cond_wait (cond=0x600d80, mutex=0x600dc0) at condwait_wrap.c:27
#2 0x0000000000400873 in thr_start (data=0x0) at condwait_test.c:17
#3 0x0000003cf900686a in start_thread (arg=<value optimized out>) at pthread_create.c:297
#4 0x0000003cf84de39d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5 0x0000000000000000 in ?? ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment