Scholarly Resources for CompSci Undergrads

C Programming Language

Notes about C Debugging (slides 8 to 10)

Back to A Longer Example down to slide 8 down to slide 9 down to slide 10


Slide 8: Using dbx


Debuggers

Debuggers In General



Very important: An ounce of analysis is worth a pound of debugging!


Using the dbx Debugger

Nota Bene

Be sure to compile with the -g switch and without any -O switches (Can you say `Makefile'?) [The advice about the -O switch does not apply anymore. My notes about using gcc at UWO are more current. -- 19 May 1996]

Invocation

dbx program
dbx program core

Slide 9: Using dbx


Essential Commands

where
print current call stack (can be used to discover where the program stopped after a core dump)
stop in func
set a breakpoint at first executable line of function func, e.g. main
stop at line
set a breakpoint at line line
run args
run your program using any (optional) command line arguments you supply
print expr
display the value of the expression expr (e.g., value of a variable, result of executing a function)

Some Other Commands

cont
continue executing after a breakpoint
step
execute the current line of your program
next
same as step but will not enter functions
status
shows breakpoints, etc. you have set
list
displays source lines. Use depends on dbx version.
In GAUL, list start:num
shows lines start to start + num.
Other versions use list start,stop.
Some versions use list func
to display the source lines of function func.
alias
can be used to create your own names for dbx commands, may allow you to make macros (depends on dbx version)

Slide 10: How to Debug


Where to Get Help With dbx

Recommended Reading

[I think my lists of books, WWW sites and Usenet postings are better than what I suggested in 1994. -- 19 May 1996]


Where to next?

These slides

back up to Slide 8 back up to Slide 9 back up to Slide 10

Other slides

Back to longer example Up to List of Contents Forward to further references (in the Introduction)


http://www.csd.uwo.ca/~jamie/C/Debug/debuggers.html

Last updated by J. Blustein on 29 May 1996.

This document is copyright by its author, J. Blustein <jamie@csd.uwo.ca>.

HTML 2.0 Checked!