gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Docs on multi-threaded debugging using gdbserver?


From: Grant Edwards
Subject: Docs on multi-threaded debugging using gdbserver?
Date: Fri, 19 Jun 2009 20:54:18 +0000 (UTC)
User-agent: slrn/pre0.9.9-102 (Linux)

Is there any documentation on how to set up for remote
multi-threaded debugging using gdb-server?

Single-threaded debugging works fine on all my targets, but I'm
trying to debug a multi-threaded app remotely using gdbserver
and I'm having zero luck.  I've tried on both a glibc/PPC
target and a uclibc/ARM9 target.

On the PPC target, gdb seem completely unaware of threads.  I
haven't spent much time beating my head agains that wall...

On the ARM target, gdb seems vaguely aware that there are
multiple threads, but can do nothing usable with/about them.

Here's a typical session:

    GNU gdb 6.8
    Copyright (C) 2008 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "--host=i386-pc-linux-gnu 
--target=arm-linux-uclibc".
    [New Thread 860]
    0x40000930 in _start () from 
/home/grante/processors/atmel/RM9200/buildroot-2009.05/project_build_arm/uclibc/root/lib/ld-uClibc.so.0
    (gdb) break main
    Breakpoint 1 at 0x8bf4: file hello.c, line 45.
    (gdb) c
    Continuing.
    
    Breakpoint 1, main () at hello.c:45
    45        pthread_attr_t attr, *attrp=NULL;
    (gdb) next
    48        pthread_mutex_init(&printfMutex,NULL);
    (gdb) 
    50        tprintf("main()\n");
    (gdb) 
    52        s = pthread_attr_init(&attr);                            
abort_if_error(s);
    (gdb) 
    53        s = pthread_attr_setschedpolicy(&attr, SCHED_RR);        
abort_if_error(s);
    (gdb) 
    54        s = pthread_attr_getschedparam(&attr, &sp);              
abort_if_error(s);
    (gdb) 
    55        sp.sched_priority = 50;
    (gdb) 
    56        s = pthread_attr_setschedparam(&attr, &sp);              
abort_if_error(s);
    (gdb) 
    60        for (i=0; i<NumPorts; ++i)
    (gdb) 
    62            s = pthread_create(tid+i, attrp, thread, (void*)i);  
abort_if_error(s);
    (gdb) 
    
    Program received signal SIG32, Real-time event 32.
    0x400443d4 in ?? ()
    (gdb) 
    Cannot find bounds of current function
    (gdb) next
    Cannot find bounds of current function
    (gdb) c
    Continuing.
    
    Program received signal SIG32, Real-time event 32.
    0x400443d4 in ?? ()
    (gdb) c
    Continuing.
    [New Thread 863]
    
    Program received signal ?, Unknown signal.
    [Switching to Thread 863]
    0x40044328 in ?? ()
    (gdb) info threads
    [New Thread 861]
    [New Thread 862]
      4 Thread 862  0x40065500 in ?? ()
      3 Thread 861  0x40043718 in ?? ()
    * 2 Thread 863  0x40044328 in ?? ()
      1 Thread 860  0x400443d4 in ?? ()
    warning: Couldn't restore frame in current thread, at frame 0
    0x40044328 in ?? ()
    (gdb) info thread
      4 Thread 862  0x40065500 in ?? ()
      3 Thread 861  0x40043718 in ?? ()
    * 2 Thread 863  0x40044328 in ?? ()
      1 Thread 860  0x400443d4 in ?? ()
    warning: Couldn't restore frame in current thread, at frame 0
    0x40044328 in ?? ()
    (gdb) 
    ) c
    Continuing.
    warning: Remote failure reply: E01
    
Here's .gdbinit:

    set sysroot 
/home/grante/processors/atmel/RM9200/buildroot-2009.05/project_build_arm/uclibc/root
    set solib-absolute-prefix 
/home/grante/processors/atmel/RM9200/buildroot-2009.05/project_build_arm/uclibc/root
    file hello
    target remote 10.0.0.98:12345

    
I've spent hours reading through web postings and mailing-list
threads and have found little helpful info.  What I've found is
that a lot of people have problems with this, and there is a
lot of contradictory and vague information.

I've found advice saying you have to point sysroot to the root
of the target filesystem. I've found advice saying to point
solib-absolute-prefix to the target root.  (I've tried both --
together and individually).  I've found advice saying point
sysroot to the location of the dev-host libraries for the
cross-toolchains.

I've found _lots_ of postings saying things like "your
libraries need to be unstripped".  Unfortunately nobody deigns
to specify _which_ libraries they're talking about on _which_
system (dev-host or target).

I've also found plenty of suggestions like "your
LD_LIBRARY_PATH needs to include the location of
libthread_db.so".  Well _I_ don't have a LD_LIBRARY path.  I
have two different machines that have them, and I have
libthrad_db.so files in at least 4 different locations.

Which host needs LD_LIBRARY_PATH to point to which
libthread_db.so when running what executable?

I've search the gdb docs, and can't find any info on how remote
multi-threaded debugging works when using gdb-server.

I have found a few people who claim it works for them, but the
seem unable to provide enough details to allow others to
duplicate their success.

-- 
Grant Edwards                   grante             Yow! I wonder if I ought
                                  at               to tell them about my
                               visi.com            PREVIOUS LIFE as a COMPLETE
                                                   STRANGER?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]