问题描述
在我的应用程序中创建了很多线程。一些线程名称在gdb中可见,而我执行命令'info threads',其他的则不显示。如何获得所有线程名称本身,而不是十六进制值,如0xb7fe1424
$ pre $ )
* 3线程0xb7291b70(LWP 18375)mylib.cpp中的JKMainT(arg = 0x0):482
2线程0xb7a92b70(LWP 18374)__kernel_vsyscall()中的0xb7fe1424
1线程0xb7a94730(LWP 18371)0xb7fe1424 in __kernel_vsyscall()
有默认的名字 - JKMainT
字符串有当前函数的名字。
尝试选择其中一个线程和查看回溯 - 这可能会给你一个好主意,它是哪个线程。否则,您可以尝试使用 PR_SET_NAME <
如果可用。
There are many threads created in my application. some of the threads name are visible in the gdb while i execute the command 'info threads', others are not displayed. How to get all the thread name itself instead of the hex value like 0xb7fe1424
4 Thread 0xb68ffb70 (LWP 18377) 0xb7fe1424 in __kernel_vsyscall ()
* 3 Thread 0xb7291b70 (LWP 18375) JKMainT (arg=0x0) at mylib.cpp:482
2 Thread 0xb7a92b70 (LWP 18374) 0xb7fe1424 in __kernel_vsyscall ()
1 Thread 0xb7a94730 (LWP 18371) 0xb7fe1424 in __kernel_vsyscall ()
Threads don't have names by default - the JKMainT
string there is the name of the current function.
Try selecting one of the threads and viewing the backtrace - that might give you a good idea which thread it is. Otherwise, you could try prctl with PR_SET_NAME
if it's available.
这篇关于gdb如何获取线程名称显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!