GDB QUICK INFO
================================
Compile with the -g option: % g++ -g mypgm.c
Print your program with
line numbers: % cat -n mypgm.c | lpr -Pqms
Edit & view your program with % vi mypgm.c
line numbers: :set nu (inside vi)
To invoke gdb: % gdb a.out
(gdb) quit Gets out of gdb
(gdb) shell temporarily gets back to UNIX (shell)
(gdb) help Access on-line help of gdb commands
(gdb) list List source code
(gdb) list 15,25 lists lines 15 through 25
(gdb) list funcname lists 10 lines of named function
(gdb) list myprog.c:10 list line 10 of file myprog.c; this is how
to switch to another source file
(gdb) break 57 put a break point on line 57
(gdb) clear 57 clear the breakpoint at line 57
(gdb) run start execution
(gdb) run arg1 arg2 arg3 start execution with these arguments
(gdb) run < file1 > file2 start ex. using file I/O redirection
(gdb) where print line number which it will do next
(gdb) info break show breakpoints
(gdb) info source show source file information
(gdb) bt backtrace (show stack of frames)
(gdb) up move up one from on stack
(gdb) down move down one from on stack
(gdb) frame reset to the top frame
(gdb) info frame show information about current frame
(gdb) s advance only 1 line, i.e. do next line & stop
(gdb) c continue execution from this point to next
breakpoint
(gdb) n execute the next line but don't step "into" a
function's code; just do it and proceed to
next line
(gdb) print x print variable x
You can print almost any C++ variable, array, or class:
print table[i]
print ptr->part1
print x.part1
If a program is running, you can press CONTROL-C to interrupt it. Gdb will
give you the (gdb) prompt. Use "where" to find out where you are. You can
continue from there.