【问题标题】:Make gdb show thread names on 'apply all' operations让 gdb 在“应用所有”操作上显示线程名称
【发布时间】:2012-09-22 15:50:37
【问题描述】:

我正在调试一个包含许多线程的应用程序,因此我使用 prctl 为它们命名。这适用于 gdb 的 info threads 选项,但如果 thread * apply all 操作也显示它会很好。有什么方法可以强制 gdb 这样做吗?

(gdb) info threads
  Id   Target Id         Frame 
  ...
  3    Thread 0x7ffff6ffe700 (LWP 30048) "poll_uart_threa" 0x00007ffff78eb823 in select ()
    at ../sysdeps/unix/syscall-template.S:82
  2    Thread 0x7ffff77ff700 (LWP 30047) "signal hander" do_sigwait (set=<optimized out>, 
    sig=0x7ffff77feed8)
    at ../nptl/sysdeps/unix/sysv/linux/../../../../../sysdeps/unix/sysv/linux/sigwait.c:65
* 1    Thread 0x7ffff7fcc700 (LWP 30046) "simulator" __lll_lock_wait ()
    at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:132

指针、PID {嗯、线程 ID,但 LWP 线程 == 进程、ish} 和名称

(gdb) thread apply all bt
...
Thread 3 (Thread 0x7ffff6ffe700 (LWP 30048)):
#0  0x00007ffff78eb823 in select () at ../sysdeps/unix/syscall-template.S:82
#1  0x0000000000403bb3 in poll_uart_thread (unused=0x0) at uart.c:96
#2  0x00007ffff7bc4e9a in start_thread (arg=0x7ffff6ffe700) at pthread_create.c:308
#3  0x00007ffff78f24bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#4  0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7ffff77ff700 (LWP 30047)):
<call stack>
#2  0x0000000000417a89 in sig_thread (arg=0x7fffffffbb60) at simulator.c:879
#3  0x00007ffff7bc4e9a in start_thread (arg=0x7ffff77ff700) at pthread_create.c:308
#4  0x00007ffff78f24bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7ffff7fcc700 (LWP 30046)):
<call stack>
#9  0x00000000004182e3 in simulator (flash_file=0x7fffffffe0e4 "../programs/blink.bin")
    at simulator.c:1005
#10 0x0000000000401f14 in main (argc=3, argv=0x7fffffffdd48) at cli.c:167

虽然我可以通过搜索调用堆栈找到名称,但如果它可以打印在摘要行中会很好/方便/等等,这里只有 PID 和指针。

【问题讨论】:

  • 如果相关,我正在运行:GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2) 7.4-2012.04

标签: gdb pthreads pretty-print


【解决方案1】:

没有简单的方法,您必须修补 GDB。这是一个简单的补丁,你可以找到它here

【讨论】:

    【解决方案2】:

    如果它可以打印在摘要行中会很好/方便/等等,这里只有 PID 和指针。

    请在GDB bugzilla提出提升请求。

    如果你正在使用带有嵌入式 python 的 GDB,你也许可以 script "thread apply" 来做你想做的事,但它确实应该已经做正确的事了。

    【讨论】:

      猜你喜欢
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 2012-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-25
      相关资源
      最近更新 更多