A Longer Example
slide 8
slide 9
slide 10
Debuggers
- never depend on a debugger to find errors
- you can waste a lot of time stepping through
- many debuggers will show you the wrong data
- e.g.,
int
s represented as long
s
- e.g., memory (pointers) may be initialized differently
An ounce of analysis is worth a pound of debugging!
- Debugging is often best when done with a print out away from
your terminal
- Be sure to get enough sleep
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]
- dbx program
- dbx program core
- 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)
- From Unix shell
- From Within dbx
- sh man dbx (or !man dbx)
- help (or ?)
[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
Slide 8
Slide 9
Slide 10
Other slides
longer example
List of Contents
further references (in the Introduction)
Last updated by J. Blustein on 29 May 1996.
This document is copyright by its author, J. Blustein <jamie@csd.uwo.ca>.
