gdb信息线程打印线程名称

时间:2014-06-30 19:14:03

标签: gdb

在使用gdb调试多线程代码期间,我需要从gdb中找到线程名称以更快地定位错误。

例如下面的gdb命令只打印线程1,2,3 ...等,但我希望我不能线程A,B,C ...这意味着我需要线程列出名单。

是否可以从gdb命令。

(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 个答案:

答案 0 :(得分:3)

您没有说明您使用的是哪个版本的gdb。

对于本机Linux(即不使用gdbserver),在gdb 7.3中添加了线程名称的打印。所以,升级到至少那个版本,你应该看到它的工作。

计划对gdbserver支持此功能,但尚未实现。 对其他平台的支持取决于志愿者。