My program is not working correctly. It looks like it is stuck in an infinite loop or a bad mutex lock/unlock. But, I have no idea where the bug is. I tried using gdb for debugging.
I can't use gdb backtrace command because I don't designate breakpoint. And I can't designate it because I don't have any idea where the error is.
Does gdb have instrument for backtrace "on the fly"?
gdb will stop your program at whatever line it has just executed. From here you can examine variables and move through your program.
Start calc from within gdb using the run command. It will go into an infinite loop. Press Ctrl-C (like before) to stop your program.
GDB allows you to do things like run the program up to a certain point then stop and print out the values of certain variables at that point, or step through the program one line at a time and print out the values of each variable after executing each line. GDB uses a simple command line interface.
I can't use gdb backtrace command because I don't designate breakpoint.
Yes, you can.
All you need is for the inferior (being debugged) program to be stopped somewhere.
When you first attach to the program, GDB will stop all threads, and you can examine where they are. Later, you can hit Ctrl-C
, and again look at all threads. A useful command is thread apply all where
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With