1

During use gdb to debug multithread code, I need to find the thread name from gdb to locate error more faster.

for e.g. below gdb command only print thread 1,2,3..., etc, but I wish I can not thread A,B,C... that means I need to thread name list out.

Is it possible from gdb command.

(gdb) info threads
  15 Thread 8725  __ioctl () at bionic/libc/arch-arm/syscalls/__ioctl.S:13
  14 Thread 8726  __ioctl () at bionic/libc/arch-arm/syscalls/__ioctl.S:13
  13 Thread 8730  __ioctl () at bionic/libc/arch-arm/syscalls/__ioctl.S:13
  12 Thread 13328  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
  11 Thread 13330  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
  10 Thread 13331  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
  9 Thread 8711  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
  8 Thread 13334  nanosleep () at bionic/libc/arch-arm/syscalls/nanosleep.S:13
  7 Thread 8722  nanosleep () at bionic/libc/arch-arm/syscalls/nanosleep.S:13
  6 Thread 8724  nanosleep () at bionic/libc/arch-arm/syscalls/nanosleep.S:13
  5 Thread 8710  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
  4 Thread 8712  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
  3 Thread 8723  __ioctl () at bionic/libc/arch-arm/syscalls/__ioctl.S:13
  2 Thread 8721  read () at bionic/libc/arch-arm/syscalls/read.S:14
* 1 Thread 8709  __futex_wait () at bionic/libc/arch-arm/bionic/futex_arm.S:51
1

1 Answer 1

3

You don't say what version of gdb you are using.

For native Linux (that is, not using gdbserver), printing of thread names was added in gdb 7.3. So, upgrade to at least that version and you should see it work.

Support for this for gdbserver is planned, but not yet implemented. Support for other platforms depends on volunteers.

1
  • Is it available for android gdb now?
    – user4284784
    Nov 23, 2014 at 17:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.