Before asking this question - I referred to How does gdb multi-thread debugging coordinate with Linux thread scheduling? for added context
I have a c++ daemonized multithreaded program running on linux. It launches a thread every time It processes a transaction . The code to be debugged is part of the transaction processing code invoked in new thread.
This is the process I follow to debug.
I start gdb, turn off pagination, turn on synchronous command execution and set non-stop mode.
Then I attach gdb to running daemon program and set breakpoints on "all" threads (See illustration below) and send a new transaction.
The problem is that gdb seeems to inform me clearly that breakpoint is in thread 1. I don't get a break on the breakpoint in the new thread. A new thread is created when I send a new transaction and exits without breaking at breakpoint.
Please help me understand what is the possible reason (what am I missing)
(gdb) set pagination off
(gdb) set target-async on
(gdb) set non-stop on
(gdb) attach 11067 # <daemon pid>
(gdb) thread apply all b foo
Thread 1 (Thread 0x7f94bb9f3740 (LWP 11067)): Breakpoint 1 at <filename> ,
line <line#>
(gdb) c
Continuing.
[New Thread 0x7f94b725e700 (LWP 15750)]
[Thread 0x7f94b725e700 (LWP 15750) exited]
The problem is - it did not break in function "foo" ( my breakpoint )
What is it that I am missing ?
How do I instruct gdb to follow new child threads.
Isn't "thread apply all" supposed to apply to "all" threads ?
foo
is actually called in the new thread? Try addingabort()
insidefoo
, execute the transaction again. – Employed Russianb foo
should be enough to set breakpoint on all existing threads and all not yet created threads. – ks1322