gdb breakpoint on pthread_create gdb breakpoint on pthread_create multithreading multithreading

gdb breakpoint on 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, so in case I didn't really understand you, or my first answer wasn't helpful, do this:

(gdb) info func pthread_createAll functions matching regular expression "pthread_create":Non-debugging symbols:0x080485e0  pthread_create0x080485e0  pthread_create@plt0x00786590  __pthread_create_2_10x00786590  pthread_create@@GLIBC_2.10x00786ee0  __pthread_create_2_00x00786ee0  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 digitsand underscores, such as 1__pthread_create_2_1.


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 gdbwill find a symbol "pthread_create@plt", which is a stub that leads intothe 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 eventuallyreaching (and stopping at) the correct shared library function.

Now in case that doesn't solve it for you, on to my second answer...