I am trying to set a breakpoint in linux in gdb for a program creating threads. I would like to set a breakpoint on thread creation, but unfortunately pthread_create<
Try this:
(gdb) b __pthread_create_2_1
Or build your own GDB
with this patch applied.
Or try the latest pre-release GDB
here, which should allow you to do "catch syscall clone"
OK, I'm going to post two answers, because I'm not sure if I understand your question.
First: pthread_create is in a shared library, and gdb knows how to handle that. If you just say "break pthread_create", it should "just work".
You shouldn't need to know this, but the way it should work is that gdb will find a symbol "pthread_create@plt", which is a stub that leads into the dynamic loader, and will eventually be replaced by a jump to the appropriate shared library function. We will set a breakpoint there, and gdb will automatically deal with the dynamic loader until eventually reaching (and stopping at) the correct shared library function.
Now in case that doesn't solve it for you, on to my second answer...
OK, so in case I didn't really understand you, or my first answer wasn't helpful, do this:
(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
Now pick the symbol that you think is the right one, and set a breakpoint there. Don't pick the ones that have "@" in them, but one of the ones that has digits and underscores, such as 1__pthread_create_2_1.