While in a debug session, any of the following commands could be used as the next action for starting the actual debugging of the project:
For more information about these commands and their arguments, see the Using GDB appendix in this guide, or use the help cmd command in gdb.
Let's see how to use some of these basic commands.
# The list command: (gdb) l 3 4 main () { 5 6 int x,y,z; 7 8 setprio (0,9); 9 printf ("Hi ya!\n"); 10 11 x=3; 12 y=2; # Press <enter> to repeat the last command: (gdb) <enter> 13 z=3*2; 14 15 exit (0); 16 17 } # Break on line 11: (gdb) break 11 Breakpoint 2 at 0x80483c7: file hello.c, line 11. # Continue until the first breakpoint: (gdb) c Continuing. Hi ya! Breakpoint 2, main () at hello.c:11 11 x=3; # Notice that the above command went past the # printf statement at line 9. I/O from the # printf statement is displayed on screen. # Inspect variable y, using the short form of the # inspect command: (gdb) ins y $1 = -1338755812 # Get some help on the step and next commands: (gdb) help s Step program until it reaches a different source line. Argument N means do this N times (or till program stops for another reason). (gdb) help n Step program, proceeding through subroutine calls. Like the "step" command as long as subroutine calls don't happen; when they do, the call is treated as one instruction. Argument N means do this N times (or till program stops for another reason). # Go to the next line of execution: (gdb) n 12 y=2; (gdb) n 13 z=3*2; (gdb) inspect z $2 = 1 (gdb) n 15 exit (0); (gdb) inspe z $3 = 6 # Continue program execution: (gdb) continue Continuing. Program exited normally. # Quit the debugger session: (gdb) quit The program is running. Exit anyway? (y or n) y (61) con1 /home/allan/src >