MAINDEBUG User's Guide, Chapter 7

previous   next   top   complete contents   complete index   framed top   this page unframed


7. Debugger Initialization

XIDAK has not provided an official initialization file for MAINDEBUG, even though some users have requested the ability to issue debugger commands automatically at the beginning of a debugging session. Since the exact requirements for debugger initialization depend on the program being debugged, XIDAK does not plan to offer a general-purpose debugger initialization facility. However, you can get a similar effect by writing a program that calls $debugExec.

Below is an example of a MODULE, DSU, that starts a debugger session by reading debugger commands from a file and passing them to $debugExec. You can modify this MODULE to meet your needs:

BEGIN "dsu" # debugger setup

Takes a command line argumentwhich is the name of a file
of debugger commands to readThese commands will
typically set breakpoints in a programThe commands
should not include a "Q" (quitcommandsince DSU adds
this itself.

If the file is not specified on the command lineDSU
prompts for the file name.

After executing DSU and returning to MAINEX (or whatever
invoked DSU), invoke the program in which the breakpoints
were set.  MAINDEBUG will gain control when a breakpoint
is reached.  You can't invoke DEBUG directly after running
DSUsince DSU binds $DEBUG.

INITIAL PROCEDURE;
BEGIN
BOOLEAN origEchoCmdFile;
STRING s,ss,arg;
POINTER(textFilef,origCmdFile,newCmdFile;

IF NOT $getCommandLine(s)
        
OR NOT $nextCommandLineArg(s,argTHEN
    
arg := $sGet
        ("
Name of file containing debugger commands: ");

open(f,arg,input);
s := "";
DOB read(f,ss); IF NOT $gotValue(fTHEN DONE;
    
write(s,ss,eolEND;
close(f);

Write additional commands to quit the debugger (confirming
with "Y"), and answering "Nto the question about whether
to remove breakpointsThese commands will be read from
cmdFilenot from the argument to $debugExecso must
redirect cmdFile.
open(newCmdFile,"MEM" & $devModBrkStr,
    
create!input!output!random);
write(newCmdFile,"Q" & eol & "Y" & eol & "N" & eol & eol);
setPos(newCmdFile,0L);

origCmdFile := cmdFilecmdFile := newCmdFile;
Echo redirected cmdFileotherwiseoutput looks messy
origEchoCmdFile := $tstConfigurationBit($echoCmdFile);
$setConfigurationBit($echoCmdFile);

$debugExec(s);

cmdFile := origCmdFileclose(newCmdFile);
IF NOT origEchoCmdFile THEN
    
$clrConfigurationBit($echoCmdFile);
END;

END "dsu"

This MODULE is meant to be invoked with an argument that is the name of a file containing debugger commands to initialize your debugging session. For example, compile the file sample.msl on the MAINSAIL directory debuggable, then create a file dsu.txt with the following contents:

b@sample.hash
op f

These commands set a breakpoint in SAMPLE.hash and tell the debugger always to display local variables. Using DSU to set up the debugging session for SAMPLE might look like:

*dsu dsu.txt<eol>

MAINDEBUG (tm) (type ? for help)
Copyright (c) 1984-1998 by XIDAKInc., Point ArenaCaliforniaUSA.
Opening intmod for $SYS from
 
intlib(/std/15/6/sun4/4.1/mainsail/sys-usp.ilb)>$sys-uspa
Opening intmod for SAMPLE from sample-usp.int
Set break at SAMPLE.108
Display local variables

MAINDEBUGQ
Want to return from debugger (Yes<eolor No<eol>): Y
Remove breakpoints (Yes<eolor No<eol>): N
*
sample<eol>
Size of hash bucket131<eol>
Next key to be hashed (eol to stop): xyzzy<eol>

--
SAMPLE.HASH--
H  0
I  0
J  0
S  "xyzzy"

}
h _ length(s); i _ h MIN 4; j _ 1;
SAMPLE.HASH:

previous   next   top   complete contents   complete index   framed top   this page unframed

MAINDEBUG User's Guide, Chapter 7