Related
Quick Links
The powerful GNU Debugger GDB returns to the front stage.
Join us for an all-new, more advanced introduction to GDB.
What IsGDB?
This article will continue to build further on the information presented there.
It sounds likeapples, pie, and pancakes!
(And to some extent, it is.)
If this sounds a little complicated, have a look atDebugging with GDB: Getting Startedfirst.
Single-threaded or Multithreaded?
The program was single-threaded: No other execution threads wereforkedfrom within the code.
There are only occasional instances where GDB will mistake the crashing thread for another.
For example, this might happen if the program has crashed in two threads at the same time.
The termLWPstands forLight Weight Process.
Shutterstock/Nicescene
Note that GDB must do this upfront so that it might find the crashing thread as described earlier.
Additionally, no variable readouts would be presented for those function names.
This can be achieved by using the commands
or
, respectively.
We can swap the
in the last command to access another thread, etc.
This is a real skill.
It’s quite clear: This thread is waiting for input.
In other words, there would be as good as zero value in continuing to debug this thread.
All we have to do to start our debugging adventure is to get a backtrace.
Then, when analyzing multiple threads and their interaction, it makes sense to jump between threads with thethreadcommand.
The information is stored to
by default.
Some care has to be taken here.
It’s quite easy to mismatch binaries, code, and core dumps.
There’s one other small exception here, and that is stack smashing.
Most of the time, it will be quite clear.
At times, a really bad bug can cause stack smashing.