MAC DEBUGGING

asm dc.w OxF000+i Once in the general vicinity of the ExitToShell trap (ES)will normally . problem, you can use single -steppingplace you safely back in the . USER BR K(0x20) (S) to monitor the value of key regis- Machine language debugging is The availability of 4096 distinct ters or arguments up to the point ofmade much more difficult by those traps allows you to use each break-failure. Most of the time you'll wantdevelopment systems that use "glue point as an unambiguous sentinel in-to use the single-step command thatroutines" to bind your program to dicating progress within your pro- steps through traps as one instruction ROM traps. In such code, a direct ref- gram. However, on a future 68020 - (T). If there are compiled breakpoints erence to a particular trap won't be based , these op codes will in the program, the go command (G) in your routine: instead you'll find that be reserved for 68881 coprocessor in- will continue execution until the pro-your program calls a subroutine that structions, so you would use thegram reaches the breakpoint. references the trap. Based on experi- _Debugger trap (A9FF hexadeci- Finally,if you want to save your ence, I would make this a major con- mal). RAM disk, or just avoid rebooting, the sideration in choosing development software for the Macintosh.

Table 1: The most often used subset of MacsBug commands. The commands PREVENTIVE MEDICINE with an asterisk are included in the built-in debugger on the Macintosh Plus. As you may have concluded by now, it is cost-effective to avoid or reduce *DM addr nbytes Display memory actual debugging on a system such as "SM addr vail val2 Set memory values IL addr num Disassemble num lines at addr the Mac. The previous sections, plus "SM PC 4E71 No -op at current PC location some hands-on debugging of your *An or Dn Show address or data register n own, will offer some clues as to what "{An,Dn} value Set address or data register n maladies to guard against. TD Display all registers A brief list of remedies includes PC addr Set program counter BR addr count Breakpoint at addr after count Compiler checking-A high-level S num Step number of instructions language provides tremendous pro- T Single-step past trap ductivity advantages over assembly ST addr Step until PC reaches addr or low-level languages, customarily at ES Exit to shell (Finder) HD Formatted heap dump the expense of speed and size. All *G addr Branch to specified address languages are not created equal and, *G 40F6D8 Exit to shell (128K ROM) in particular. compile -time verification AB trap1 trap2t Breakpoint at specified traps of argument parameters is extremely AT trap1 trap2 t Trace specified traps valuable. A compiler that detects a t If trapl, trap2 omitted, for all traps pointer where you should be using a handle can save you hours of hair - pulling.Inthisregard, Pascal (or Modula-2) with its data -type checking ITEMS DISCUSSED has a marked advantage over C. lb remedy this problem for devoted C MACINTOSH68000 MAcNosY $75 users, at least one version of the lint DEVELOPMENT SYSTEM $195 Jasik Designs interface -checkingutilityisunder Apple Computer Inc. 343 Renton Way development for the Mac. 205025 Mariani Ave. Menlo Park, CA 94025 Cupertino, CA 95014 (415) 322-1386 Desk checking-This may sound ob- (408) 996-1010 Includes MacsBug. Be sure to vious, but if you're treading in a new Includes editor, assembler, linker, specify version for 64K or 128K area of the toolbox, you should verify MacsBug, and MacDB debuggers. ROM. the interfaces manually by checking that they correspond to definitions in MACINTOSH SOFTWARE TMON $100 Inside Macintosh. (For more information SUPPLEMENT price varies ICOM Simulations Inc. refer to Macintosh Technical Note #43.) .Apple Computer Mailing Facility 626 Wheeling Rd. Prototyping-If you're really not 467 Saratoga Ave., Suite 621 Wheeling, IL 60090 sure how a particular or rou- (312) 520-4443 San Jose, CA 95129 tine works, make a simple test. In par- (408) 988-6009 You can also request information Each update can include revisions on the public domain Extended ticular,if you want to pass a null to development tools (MacsBug, User Area, which includes pointer as an argument, and the docu- ResEdit) and new or revised "Discipline," an of TMON mentation doesn't explicitly endorse chapters of Inside Macintosh. that validates arguments on trap it, test it first. Assuming it works will calls. likely cost you more time in the long run. Also, it's easier to isolate prob-

138 BYTE DECEMBER 1986