pthread_create上的gdb断点

Jua*_*uan 15 multithreading gcc gdb breakpoints

我试图在gdb的linux中为创建线程的程序设置一个断点.我想在线程创建时设置一个断点,但不幸的pthread_create是它是一个版本化的符号,我无法得到它的全名.

如果我输入:

catch thread_start
Run Code Online (Sandbox Code Playgroud)

我明白了

Catch of thread_start not yet implemented
Run Code Online (Sandbox Code Playgroud)

在这种情况下,如何在gdb中捕获线程创建的最佳方法是什么?

Emp*_*ian 16

试试这个:

(gdb) b __pthread_create_2_1
Run Code Online (Sandbox Code Playgroud)

或者建立自己的GDB这个补丁适用.

或者试试最新的预发布GDB 在这里,它应该让你做"catch syscall clone"


Mic*_*der 16

好的,如果我不是真的了解你,或者我的第一个答案没有帮助,请这样做:

(gdb) info func pthread_create
All functions matching regular expression "pthread_create":

Non-debugging symbols:
0x080485e0  pthread_create
0x080485e0  pthread_create@plt
0x00786590  __pthread_create_2_1
0x00786590  pthread_create@@GLIBC_2.1
0x00786ee0  __pthread_create_2_0
0x00786ee0  pthread_create@GLIBC_2.0
Run Code Online (Sandbox Code Playgroud)

现在选择您认为正确的符号,并在那里设置断点.不要选择那些带有"@"的,但其中一个有数字和下划线的那些,例如1__pthread_create_2_1.