HowTo debug EventDisplay job with GDB/DBX




HowTo debug EventDisplay job with GDB/DBX/Totalview

The  purpose  of a debuggers such as GDB/DBX/Totalview is to allow 
you to see what is going on ``inside'' another program  while  it
executes - or  what another program was doing at the moment it crashed.

       GDB/DBX/Totalview can do four main kinds of things (plus other
things in support of these) to help you catch bugs in the act:

o   Start  your programm, specifying anything that might
    affect its behaviour.

o   Make your program stop on specified conditions.

o   Examine what has happened, when  your  program  has
    stopped.

o   Change  things  in your program, so you can experiment
    with correcting the effects of one bug and  go on to 
    learn about another.


Here I'll try to give you simple hints how to debug, for further information
try to look through the GDB/DBX/Totalview manuals
(just type 'man gdb' / 'man dbx' / man 'totalview' from the command prompt)

Suppose, a job you run is crashing and you want to use GDB/DBX/Totalview 
to debug it.


GDB

How to run gdb from the xterm: run gdb, then type (gdb) file evd.exe you'll see gdb's output: Reading symbols from evd.exe...done. type set args /tmp/evd.tcl.{$USER} If you run evd file_name, it creates /tmp/evd.tcl.{$USER}, so you may use what you were running. It's the same if you run evd.exe /tmp/evd.tcl.{$USER} from command prompt. Another way is to type: (gdb) file evd.exe if you want to talk to different modules/include your file from AC++ prompt. then run the program by typing (gdb) run Try to do whatever you want to make the program crash again, then investigate output of the debugger using 'up' and 'down' commands, and 'info local' to print some file local info. How to run gdb from the emacs/xemacs: Start emacs/xemacs session, type 'Alt-X gdb'(or Esc-X gdb) on prompt give the location of GDB binary, normally typing 'gdb' is enough. Type file evd.exe on gdb command prompt, run evd.exe. To attach running evd.exe to the gdb for debugging type attach process_ID in GDB session, where process_ID corresponds to the debugged evd.exe, let GDB to load in the necessary shared libraries type 'continue' in GDB window, the debugged executable will resume. To get process_ID of the evd.exe you are running type ps -U {$USER} (type 'man ps' for details)

DBX

Some words how to use dbx for debugging. Look at this example: > which evd.exe ./bin/IRIX6-KCC_4_0/evd.exe > dbx ./bin/IRIX6-KCC_4_0/evd.exe So you run dbx _file_name_ using a full path for this file name.

Totalview

This is the most user-friendly debugger. To start with it type setup totalview totalview evd.exe Click on the middle button when TOTALVIEW pops up its windows and you will get instructions on how to proceed further Basic totalview commands: ------------------------- Mouse: mouse-left: o clicking on the line number sets/resets the breakpoint o clicking on the "stack subwindow" (upper left in the source code window) will display the source code in that stack frame mouse-middle: o brings up a pull down meny with a lot of stuff, including "help" mouse-right: o clicking on a variable pops up another window with the value o if the variable is a class, a whole class will be displayed o if the variable is a pointer, the current value will be displayed, but then further right-clicking with display the content of the address the pointer points to Keys: f "file" -- opens a dialog box prompting the user to specify a file or a subroutine/method to be displayed. After you see the source code, left-click on the line number to set the breakpoint. (Note that if the clickable line numbers are comments or empty lines, your source code is likely out of date.) g "go" -- run or continue the execution. When debugging evd.exe just type this until you reach the AC++> prompt, and then type "source [tcl_file_name]"(/tmp/evd.tcl.{$USER}) since there you may use [TAB] to complete the file name. a "argument" -- supplies the command-line arguments for the executable, e.g. a tcl file to run. n "next" -- go to the next line but step over subroutine calls s "step" -- go to the next line but step into any subroutine calls. o "out" -- return from this subroutine call to one stack level up d "directory" -- in an ulikely event that the totalview can't find the source code, this command will pop up a dialog box to set the directory to search for the source files. Most other key bindings will be shown in a pull-down menu that comes after a middle-click to the source-code window. Problem is that the Fermilab licence server sometimes runs out of licenses, and then you can't run it until somebody else is done debugging.




Last modified July 27, 2001 by Andrei Loginov(loginov@fnal.gov)