Gdb allows you to debug multiple programs at once without exiting the process you're currently running.
Gdb uses an inferior as a handle for a process. An inferior is attachable/detachable from a process
info inferiors # display list of current inferiors.
(gdb) info inferiors Num Description Executable 2 process 2307 hello * 1 process 3401 goodbyeSwitch to another inferior:
inferior infno # make inferior number infno the current inferior
Loading multiple inferiors:
1) add-inferior [ -copies n ] [ -exec executable ] # n defaults to 1 and optional exec gives an empty inferior2) clone-inferior [ -copies n ] [ infno ] # n defaults to 1 and infno defaults to current inferior number
Ending the inferiority complex:
remove-inferior infno # Remove the empty inferior Note: Can't remove an inferior with a running assoc. process.
detach-inferior infno # detaches from an inferior from assoc. process
kill-inferiror infno # kills the process attached to the inferior. It can be removed or re-attached to some process.
Debugging Multi-threaded Programs:
info threads # displays thread info - thread number, thread-id, stack frame summary
thread threadno # make threadno as active current thread and shows stack frame summary
Starting and Stopping Multi-thread Programs
2 modes of debugging:
1) All stop mode: aka 3 musketeers mode i.e. "All-for-one, One-for-all"
2) Non-stop mode:
set target-async on|off # Switch asynchronous mode.
show target-async # Show the current target-async setting.
interrupt # suspend execution of the running program (whole process in all-stop, current thread in non-stop modes)
interrupt -a # stop the whole program in non-stop mode
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.