Copyright c Xerox Corporation 1980Inter-Office MemorandumToMesa UsersDateOctober 27, 1980FromBruce MalaskyLocationPalo AltoSubjectDebugger: Extended FeaturesOrganizationSDD/SS/MesaXEROXFiled on: [Iris]Doc>XDF.bravo (and .press)DRAFTThis memo discusses Debugger User Procedures (UserProcs) and contains a sample Printer, a specialtype of UserProc.The Debugger is now the functional equivalent of the Alto/Tajo environment (with the exception ofLibrarian support and communications). As a result, there are no longer any differences betweenthe FileTool and ChatTool that run in Alto/Tajo and the versions that run in the Alto/MesaDebugger.Loading User ProceduresTo install the Debugger from the command line with some UserProcs, type:XDebug YourProc1[/l] YourProc2[/l] ... to the Alto Executive. To load files in an installed debugger, simply enter the Debugger nub; thendo a >New filename, followed by >Start globalframe. More information on the mechanism forloading programs into the Debugger can be found in the Mesa User's Handbook and the MesaDebugger Documentation.Hints for Writing User ProceduresThe Debugger gives you added help in gaining access to the information it already knows aboutyour program. The Debugger's configuration exports all of the Debugger's and Tajo's interfaces;see XDebug.config for details. A user program can access any of the Debugger's publicprocedures simply by importing the definitions modules of the procedures that you want to use.When writing your own debugging routines, look carefully at some of the utility routines that theDebugger already provides (e.g., Name, Frame, ShortREAD, etc.). In particular,DebugUsefulDefs contains most of the interesting procedures you might want. The interfaceDOutput contains utility procedures for displaying information in the Debug.log (a la IODefs).You should also look at the and directories for UserProcs that otherMesa users have already written and debugged.Warning: The Mesa Group makes no guarantees about the stability of these interfaces betweenreleases. Use at your own risk!!pX qp]g~ri cs]pX -s7Bp ^s]p -s7Bp Y)s]p-s 7Bp St MsF0? u FHp vp"vp D AR U ?A >wpwp8 <\ 9 x 5pH3Cy' 0p5. /!ypxp ypx pxp! -z'vpv +p (x! %5pW #3- !y pA ?6(  U !w pwp IwpB wp?ypwp yzpy p% S- xv; ]2>d Debugger: Extended Features2PrintersThe Debugger is capable of calling a user supplied procedure to print variables of specific types.To do this, a program must first register any type it will display by calling AddPrinter: PROC [type: STRING, proc: PROC [DebugOps.Foo]]from the interface Dump. The Debugger's interpreter evaluates type at the beginning of eachsession and remembers the target type of the result. Unfortunately, type is not a simple typeexpression, but rather a statement evaluated by the interpreter; the type is extracted from the result.Any additional information such as the address of a variable used when evaluating the statement is ignored.Later, whenever the Debugger encounters a variable of that type, it will call proc to display it. If,for a given printer, calling proc or evaluating type ever causes an UNWIND, the printer is nevercalled again. The parameter to proc is defined as follows:Foo: TYPE = POINTER TO Fob;Fob: TYPE = RECORD [ there: BOOLEAN, addr: BitAddress, words: CARDINAL, bits: [0..WordLength), . . .]];BitAddress: TYPE = RECORD [ base: LONG POINTER, offset: [0..WordLength], . . .];If there is TRUE, the BitAddress is a location in the user core image. For large structures,LongREAD and LongCopyREAD from DebugUsefulDefs should be used to access the data;for small structures the procedure GetValue in the interface DI (it takes a Foo as its argument)copies the information into the Debugger's core image and updates the addr. The Debugger ownsthe storage for Foos and the values copied into them from the user's core image; they are freed bythe Debugger between commands.A good technique for debugging the string used in the call to AddPrinter is to actually try it outusing the interpreter. All REALs could be intercepted by supplying the following STRING toAddPrinter:0%(REAL)The following STRING is used by the sample printer attached at the end of this memo.LOOPHOLE[1400B, StackFormat$Stack]^The constant 1400B is simply a location that is always mapped; AddPrinter's evaluation of the STRING does notactually use that location.Once StackPrinter is instantiated in the Debugger, PrintStack is called whenever the Debuggerwants to display a StackObject. Since PrintStack understands the format of StackObjects, itcan show the complete contents of a stack, something the Debugger is unable to do because of thezero length array. fxG b ^p20 ](NYw {w{w{w Vpwp'wp TEwp S</8 Q|Up NF2wp Lwpwpsp JwpGw{w{ wE-{w{wCpw{wApw@7pw{w>pww p $sp2sp #Gw pwsw p sp@[{wXyw 0|6{ |s|  ]pw xpxpw p w pw pw p #wp7 g \ >[fDebugger: Extended Features3-- StackFormat.mesa-- Last Edited: Keith, October 21, 1980 10:30 PMStackFormat: DEFINITIONS = BEGIN Stack: TYPE = POINTER TO StackObject; StackObject: TYPE = RECORD [ top: CARDINAL _ 0, max: CARDINAL _ 0, overflowed: BOOLEAN _ FALSE, stack: ARRAY [0..0) OF CARDINAL]; END.-- StackPrinter.mesa-- Last Edited: Keith, October 21, 1980 10:38 PMDIRECTORY DebugOps USING [Foo, LongREAD], DI USING [GetValue], DOutput USING [Char, Line, Octal, Text], Dump USING [AddPrinter], StackFormat USING [StackEntry, StackObject];StackPrinter: PROGRAM IMPORTS DebugOps, DI, DOutput, Dump = BEGIN PrintRecord: PROC [lp, lps: LONG POINTER TO StackFormat.StackObject] ={ lpStack: LONG POINTER TO CARDINAL _ LOOPHOLE[@lps.stack]; IF lp.top = 0 THEN DOutput.Text["empty "L] ELSE FOR i: CARDINAL DECREASING IN [0..lp.top) DO DOutput.Octal[DebugOps.LongREAD[lpStack + i]]; DOutput.Char[' ]; ENDLOOP; IF lp.overflowed THEN DOutput.Text["(overflow!) "L]; IF lp.max = lp.top THEN DOutput.Text["(full!)"L]; DOutput.Line[" "L]}; PrintStack: PROC [f: DebugOps.Foo] = { g: LONG POINTER _ f.addr.base; DI.GetValue[f]; PrintRecord[f.addr.base, g]}; Dump.AddPrinter[ type: "LOOPHOLE[1400B, StackFormat$Stack]^", proc: PrintStack]; END. fxG by `2 ] \ Y' U Ty R Qq O% L HY F2 C BI! @ ?A* = <8. 90; 7 4H 3 1= 0. . -2 +H * (8 '5 %| "s( " k1 c C   =NQ TIMESROMAN MATH  TIMESROMAN  HELVETICALOGO HELVETICA TIMESROMAN  HELVETICA  TIMESROMAN  GACHA   HELVETICA   HELVETICA  TIMESROMAN\j/&Q{ XDF.bravo SDD - wickOctober 28, 1980 8:13 PM