Debugging with dbx by mudoc123

VIEWS: 21 PAGES: 12

									  Debugging with dbx

• interactive debugging tool
• to inspect the state of a stopped
  program
• complete control of the
  dynamical execution of a
  program
• evaluating and displaying data
• breakpoints
     How to use dbx

• Compile your program with
  option -g:
  > cc -g program.c -o
   program
• Load your program in the
  debugger:
  > dbx program
• Start your program:
  (dbx) run [arg]
• Perhaps you can already see the
  location of the fault...
 A typical fault in your
       program..
• You get an informative massage
 > program
 Floating exception
 The same fault using dbx
> dbx program
dbx version 3.11.10
Type 'help' for help.

main:    6 for (j=1;j<=10;j++){
(dbx) r
signal Floating point exception
  at    [function:21
  +0x10,0x120001288]     f=1.0/g;
(dbx) where
> 0 function(i = 10)
  ["program.c":21, 0x120001288]
    1 main() ["program.c":13,
  0x12000123c]
(dbx) p g
0.0
      Controlling dbx

• Lists all existing aliases:
  (dbx) alias
• Lists currently set stop:
  commands
  (dbx) status
• Delete stop commands:
  delete [<nr>|all]
   Controlling dbx (2)
(dbx) stop at 6
[5] stop at "program.c":6
(dbx) stop at 19
[6] stop at "program.c":19
(dbx) status
[5] stop at "program.c":6

[6] stop at "program.c":19

(dbx) delete 5
(dbx) status
[6] stop at "program.c":19
     Examining Source

• Calls an editor on the current
  file:
  edit
• Lists 12 lines starting at line
  <line>:
  list [<line>]
• Prints a type declaration:
  whatis <variable>
 Examining Source (2)

(dbx) whatis g
Integer g;
(dbx) whereis g
program.function.g
(dbx) whatis
  program.function.g
double g;
  Controlling Programs
• Assign an expression to a
  program variable:
  assign <variable>
• Resume execution:
  cont
• Step over one line, dont go
  through a subroutine:
  next
• Step over one line, go through a
  subroutine:
  step
    Execution tracing

• Stops execution when
  <.variable> changes:
  stop <variable>
• Stops execution when
  <procedure> is entered:
  stop in <procedure>
• stops at line <line>:
  stop at <line>
   Examining Program
         State
• Prints variable information
  about the current procedure:
  dump
• Prints the value of variables:
  print <var1>,<var2>
• Show the trace of the program:
  where
   Examining Program
       State (2)
(dbx) run
signal Segmentation fault at
  >*[fprintf, 0x3ff800dab60]
  ldq     r16, 40(r16)
(dbx) where
  > 0 fprintf(0x8008460d,
  0x140000cc8,
  0xffffffffffefffff, 0x100000,
  0x0) [0x3ff800dab60]
   1 main(argc = 2, argv =
  0x11fffe708) ["sim.c":157,
  0x120002d48]

								
To top