aru*_*zhi 2 c debugging multithreading gdb
我想在gdb中杀死一个特定的线程.这是我将程序附加到gdb的方法.
(gdb) r ./bin/myProg arg1 arg2
Run Code Online (Sandbox Code Playgroud)
我得到当前运行的线程
(gdb) info threads
3 Thread 0x7ffff61fe700 (LWP 28549) 0x000000323b6db7ad in foo () from /lib64/libc.so.6
* 2 Thread 0x7ffff6bff700 (LWP 28548) bar () at ./src/myProg.c:229
1 Thread 0x7ffff7506740 (LWP 28547) 0x000000323be0822d in pthread_join () from /lib64/libpthread.so.0
Run Code Online (Sandbox Code Playgroud)
这是我试图杀死一个线程(比如线程3)
(gdb)t 3
[Switching to thread 3 (Thread 0x7ffff61fe700 (LWP 28549))]#0 foo () at ./src/myProg.c:288
(gdb)call raise(3,0)
Run Code Online (Sandbox Code Playgroud)
在这里我假设了raiseas 的签名raise(threadId as displayed in the gdb, signo as 0)
但线程并没有被杀死.我应该使用不同的signo还是线程ID错误?
注意:我在SO中阅读了这个问题,但这对我没有帮助
多线程应用程序中的信号处理通常很复杂.因此,仅仅切换到线程更有意义,确保它没有持有任何资源(例如锁定的互斥锁),然后只是pthread_exit()代表它调用,就像它自己退出一样.
| 归档时间: |
|
| 查看次数: |
2767 次 |
| 最近记录: |