previous next top complete contents complete index framed top this page unframed
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 argument, which is the name of a file
# of debugger commands to read. These commands will
# typically set breakpoints in a program. The commands
# should not include a "Q" (quit) command, since DSU adds
# this itself.
# If the file is not specified on the command line, DSU
# 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
# DSU, since DSU binds $DEBUG.
INITIAL PROCEDURE;
BEGIN
BOOLEAN origEchoCmdFile;
STRING s,ss,arg;
POINTER(textFile) f,origCmdFile,newCmdFile;
IF NOT $getCommandLine(s)
OR NOT $nextCommandLineArg(s,arg) THEN
arg := $sGet
("Name of file containing debugger commands: ");
open(f,arg,input);
s := "";
DOB read(f,ss); IF NOT $gotValue(f) THEN DONE;
write(s,ss,eol) END;
close(f);
# Write additional commands to quit the debugger (confirming
# with "Y"), and answering "N" to the question about whether
# to remove breakpoints. These commands will be read from
# cmdFile, not from the argument to $debugExec, so must
# redirect cmdFile.
open(newCmdFile,"MEM" & $devModBrkStr,
create!input!output!random);
write(newCmdFile,"Q" & eol & "Y" & eol & "N" & eol & eol);
setPos(newCmdFile,0L);
origCmdFile := cmdFile; cmdFile := newCmdFile;
# Echo redirected cmdFile; otherwise, output looks messy
origEchoCmdFile := $tstConfigurationBit($echoCmdFile);
$setConfigurationBit($echoCmdFile);
$debugExec(s);
cmdFile := origCmdFile; close(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 XIDAK, Inc., Point Arena, California, USA.
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
MAINDEBUG: Q
Want to return from debugger (Yes<eol> or No<eol>): Y
Remove breakpoints (Yes<eol> or No<eol>): N
*sample<eol>
Size of hash bucket: 131<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:
MAINDEBUG User's Guide, Chapter 7