TITLE
    MacsBug 6.5.3: Read Me
Article ID:
Created:
Modified:
18348
8/9/95
4/7/99

TOPIC
DISCUSSION

    About MacsBug 6.5.3

    POWERPC STACK CRAWL

    Two bugs were fixed in Mixed Mode SC6 stack crawls. The stack crawl would always terminate when it encountered a 68K to PowerPC switch frame. It would also terminate with no output in the PowerPC to PowerPC case if the current routine's frame hadn't yet been set up.

    DISASSEMBLY

    When MacsBug is entered because of a crash, it no longer tries to disassemble instructions around the current PC if it is at an invalid address (odd, unmapped, etc.). This means that if a program somehow jumps into hyperspace, MacsBug won't eat itself alive with another exception. Instead, it will display a helpful message in the PC window area.

    The PlayMem 512-byte scratch area will now disassemble with a name and offsets.

    The '...' character (Option-;) is now a shortcut for the address in the comment field at the current PC. This is most useful when you want to disassemble at the target of a branch at the current PC. With this shortcut, you no longer have to type the actual address.

    The IL, IP, and ID commands support a '-c' parameter, which means current ISA. For example, il...-c (where '...' means branch target effective address) disassembles using the correct disassembler automatically. This feature is best used inside of a macro, and the new standard macro IT takes advantage of it (see the Macro section below).

    POWERPC DISASSEMBLY

    Fixed a bug in the PowerPC disassembler front-end logic which would only let you disassemble code at addresses after the system heap start and below the last byte of contiguous RAM (not logically remapped memory), in PowerPC file mapped space, or in the ROM. Any other location would get you an unable to access that address message.

    Rolled in the latest version of the disassembler. It's a little smaller, and it fixes a problem where the extended mnemonic mr. was incorrectly disassembled as mr.

    The disassembler now calls the full symbol lookup code when performing effective address replacement. This fixes two problems; 1) bls to C++ functions now shows the unmangled name, 2) bls to functions not owned by CFM which contain traceback symbols will correctly find and use the names.

    68K DISASSEMBLY

    In 68K disassembly, MacsBug no longer says will set to ones for the $50FF instruction (it's an illegal 68K instruction). Added will trap and will not trap for the various trap instructions.

    POWERPC EXCEPTIONS

    Taking a PowerPC exception no longer trashes the 68K registers D0, A0 and A1. This meant that as you stepped PowerPC code, some 68K registers were silently changing.

    MacsBug now tries to protect itself from installing its PowerPC exception handler twice. This fixes the problem on certain Performa 5200/6200 configurations where you couldn't set breakpoints or step in PowerPC code.

    SYMBOL LOOKUP

    Sped up the PowerPC and 68K embedded symbol lookup when using the Command-: pop-up and when evaluating any name in an expression.

    Significantly reworked the embedded symbol lookup code to better deal with areas of code that are PowerPC, but aren't known by CFM (such as accelerated resources). In the past, if code wasn't known by CFM, it was assumed to be 68K, and the PowerPC traceback code was never given a chance to find symbols. That could give very misleading information since quite often parts of PowerPC tracebacks look like old fixed-length 8-character MacsBug names.

    Reduced the character space for valid traceback symbols to match embedded 68K symbols. This should remove a number of invalid symbols.

    When showing what PowerPC fragment an address is within, we now show the byte offset into the fragment. This helps when you're in VM file mapped space and thus not in a heap block.

    Rolled in the latest C++ symbol unmangler. It's way cool, and attempts to make sense out of the varying mangling schemes in the ARM, xlC, MrC, Symantec, and CFront. It does a very good job, too.

    Refreshing the scrollback area after the Command-: symbols pop-up is dismissed now correctly accounts for a scrolled history buffer and doesn't redraw the wrong text.

    REGISTER EVALUATION

    I can't believe this has been broken for so long (all previous versions of MacsBug 6.5). When running with VM on, the value to which SP and A7 evaluate was the interrupt stack pointer, which is wrong. They now correctly evaluate to the value displayed in the regster area for A7.

    All 68K Dn and An registers are now valid when in PowerPC code. This means you can now display and change them, regardless of the current instruction set. I could go on about how this took some serious voodoo magic, but it didn't.

    BREAK POINTS

    Added support for a low-level PowerPC Debugger trap that will stop on the instruction after the trap, without modifying any registers. This is useful for stopping in arbitrary locations within hand-written assembly code. With this special trap, you don't have to make a cross-TOC call to the high-level Debugger implementation which destroys the volatile registers. The trap instruction is:

    #define kPowerPCLowLevelDebuggerTrap 0x7F800008 // tw LT|GT|EQ,r0,r0

    This trap instruction behaves much like the high-level Debugger call in that it can be enabled and disabled with the DX (Debugger Exchange) command.

    The BRM command (Breakpoint Multiple) works again for the first time in years. It was broken in the first version of MacsBug 6.5.

    STEPPING

    Fixed a bug in the mode switching step logic. If you stepped across a PowerPC to 68K boundary with a step count or expression (ie. Step until PC = blah), the 68K code on the other side was disassembled as PowerPC. The instruction set associated with the current PC, which is passed into the disassembler, was synchronized only when a 68K to PowerPC switch occurred.

    After a step, we now show things of interest that may have changed. Currently MemErr, ResErr, and QDErr are watched. If there's anything else cool we should watch, let us know. Here's a sample line of output when the value of ResErr changed when a Step Over was executed:

    Step (over)
    'CODE 0002 08D2'
    +0274C 00CCFDBC _GetResource ; 00049BAE | A9A0
    ··· ResErr changed to #-192 (from #0)

    For drivers that like to call the Memory Manager, we need to save and restore MemErr around all of the video driver calls in the step code path. This means MemErr won't get reset to zero as you step.

    A-TRAP ACTIONS

    Fixed A-Trap actions when tracing over a trap to actually work again. For example, if you break on MountVol, and then set an ATB on Read, and then trace over the MountVol, you won't break on Read even though it's being called a number of times. This was broken in MacsBug 6.5.2 in an attempt to fix anther bug. Both are now fixed.

    A-Trap disassembly and breaking has been significantly enhanced to support all variants of each trap word. For example, we now correctly disassemble the trap word 0xA22E as BlockMoveData, and you can now break on it by name. We'd suggest using the new API command to browse the full namespace that MacsBug supports for trap display and breaking.

    Updated trap selectors for DisplayDispatch, ColorSync 2.0, HFSUtil, FSM, ReleaseFolder, QuickTime and SoundDispatch.

    API COMMAND

    Added a new command, API. This command shows anything MacsBug knows about a given trap or trap range. It shows if the trap has selectors, what those selectors are, and if they are implemented in 68K code, PowerPC, or both. It's way cool, and will show even more info in the future.

    HEAP DUMPING

    The HD command (Heap Dump) has new options that can greatly reduce the number of heap blocks you need to examine during debugging. The '-s' and '-e' options allow you to constrain the range of addresses that are dumped within the current heap. The ' -s' option lets you specify the starting address, and '-e' lets you specify the ending address. If you use the two options together, '-e' can optionally be used as a byte count. If the end is less than the start, it's a length.

    To limit display to blocks of certain sizes, you can use up to two options of the form ,<20. The possible tests are <, =, >, <=, and >=. For example, HD RS,>1K,<5K shows resource blocks with sizes between 1K and 5K.

    COMMAND LINE

    The macro GG (clear breaks and Go) no longer gets saved into the command-line history.

    Made the command line history logic sensitive to case. This is useful such as when you capitalize a case-sensitive CFM symbol incorrectly and then repeat the command. The corrected version now gets saved in the command history.

    Parameter parsing works much better, because binary '-' (subtraction, not negation) can no longer have a blank before it. This means that commands such as RD -f 2 -i 3 now work, for example. Previously, it would try to evaluate 2-i.

    MACSBUG PREFERENCES FOLDER

    The MacsBug Preferences folder can now be located in the same folder as MacsBug (the System Folder) or within your Preferences folder (actually whatever it's called, we're international-savvy). You can place your various preferences files within either or both of these folders. As before, up to 32 files will be opened (this is the sum total of both folders, not 32 per folder).

    DCMDS

    The PC window now redraws if a dcmd modifies the current PC.

    Updated the Errors dcmd to match the latest Errors.h header file. I also rewrote it in C because I was bored one night (yes, that bored).

    Fixed two problems in the Leaks dcmd which could cause it to crash on 68K machines. It now does Mixed Mode stack crawls only if it's on a PowerPC machine. The PowerPC crawl now validates the back chains as it climbs over switch frames. Updated the display of ISAs to be more consistent with MacsBug.

    The Gestalt dcmd has been enhanced, and now takes two options. It can be asked to just show one selector as in Gestalt 'sysa', and it can just dump the installed selectors without calling them as in Gestalt -n.

    The RD dcmd has a new option, '-o', which turns on display of resource data offsets. Some labels have been abbreviated to save space.

    The functionality of the StopIf dcmd is now part of MacsBug as a built-in command. The external implementation was quite lame in that it poked MacsBug's globals (incorrectly, for the last couple of years).

    Fixed a problem where the A7 register as passed to dcmds with VM on is the wrong stack. It was always passing the interrupt stack pointer, when it really should be the one shown in
    the register display area as A7.

    Universalitized dcmd.h and dcmd.p. All constants are now enums, rather than #defines. The input strings to callbacks that are constant are now declared properly. The files are now
    wrapped in the standard C++ and structure alignment goo.

    Added the FSInfo dcmd (by Jim Luther), and made it format 3. It has a new option, '-t', which shows a summary table of all installed external file systems.

    When warning that you have duplicate dcmds, the compare is now case-insensitive, so we don't miss any.

    Updated all of the sample dcmds sample build commands to be current.

    Included the latest PowerPC dcmds in their own file, PowerPC dcmds.

    MACROS

    Added MPW SetKey-style key bindings for all extended keyboard function keys. You can define macros that get executed when any of the keys are hit. The macros expected are of the following form (where 'n' is the function key from 1 through 15):

    DoFn
    DoCmdFn
    DoOptFn
    DoCmdOptFn

    The extended keyboard keys Help, Home, Page Up, Forward-Delete, End, and Page Down are now supported. With Help you can type a command name and then Help, and you'll get that specific reference section. Help alone gives you the entire help text (pressing Help places a '?' as the first character on the command line and then presses return for you).

    Added cw and cwp macros for breaking into the Metrowerks debugger in 68K and PowerPC code, respectively.

    The size of the buffer in which you can create macros at runtime has been increased from 256 bytes to 1K.

    The MC command (Macro) now wraps output properly, rather than having it extend off of the right side of the screen.

    Added comments to some common macros, which are now shown if you get help on a macro.

    Added a macro named IT which disassembles the target effective address at the current PC. This is a shortcut for typying ILP ... or IL ... (the macro does the right thing and gets the instruction set correct).

    Added a TimeTasks macro for walking though all of the currently pending Time Manager tasks.

    TEMPLATES

    Added some new basic types: SECONDS, ATRAPWORD, BINARY8, BINARY16, BINARY32, and OSTYPE. A number of the standard templates were changed to use these new types.

    The CGrafPort template now references the portPixMap as a PixMap, rather than a handle.

    The IOREFNUM basic type now displays driver names as well as file names.

    Duplicate definitions of DCtlEntry and Driver were removed from the standard templates.

    LOGGING/STDLOG

    MacsBug now knows what version of the system it's running on when you break into it right after it loads. This means log files at boot time will go to the desktop by default (among other internal behaviour changes).

    The log mechanism has been enhanced to be as robust as it can be, given the runtime MacsBug lives in. We now make sure interrupts are enabled when both printing and logging. We no longer write data to the log file when the file system is busy (as best as we can tell), and you'll get a warning message if it is. This should clean up a lot of lockups if you NMI with logging on. Writes to the log no longer go into the file system cache. When writing to the log file, we now flush the volume as well as the file. This way all logging actions should stick even if you crash with the file still open.

    The StdLog macro (and any others that use the SET SUSPENDPROMPT feature) no longer randomly starts prompting you to press return again after a dcmd executes.

    Fixed the StdLog macro so it doesn't change your current TargetZone (the calls to HX are now balanced).

    The STAT command now displays the Gestalt 'sysu' (System Update version) value if it's present.

    MISCELLANEOUS

    Help on the Help command works reliably now.

    Added a new SET option, SIMPLIFIED. This allows you to toggle the display of PowerPC extended mnemonics.

    If MacsBug is running on a PowerPC machine, it now ignores what Gestalt says and records that the ROM is really 4 MB. This means that using the WH command (Where) in the last 1 MB of the ROM will say it's in ROM, because it really is. Previous versions of MacsBug thought ROMs on PowerPC machines were 3 MB (that's the size of the 68K portion).

    The U.S. KCHR that we distrbute is now the System 7.x one instead of 6.x.

    A command of # (pound sign followed by a blank) means the rest of the line is a comment. This is useful in macros.

    If we have a '#' in front of a decimal constant and fail to convert it, that's an immediate syntax error. We no longer incorrectly proceed to look it up as a symbol.

    The machine names list had an incorrect 'mach' value for the 8100/100.

    Blank Return just scrolls display by one line, so you can now insert blank lines into the history if you wish.

    The internal processor cache range flush routine now goes to extra efforts to make sure that the cache flushing A-Trap it calls is implemented before calling it. This makes SM (Set Memory) and breakpoints work at boot on older Mac IIs.

    The 6100/7100/8100 sound driver bus error fix now only runs on 7.5, 7.5.1, and 7.5.2. The real bug has been fixed in System 7.5.3.

    The CS command (Checksum) now shows the checksum value. The trivially simple 68K assembly code to do the checksum is:

    ******************************************************************
    ;
    ; pascal long ComputeChecksum(Ptr lowAddr, Ptr highAddr);
    ;
    ; Calculate checksum over specified address range. Checksum is
    ; calculated by summing one byte at a time into a long word
    ; starting from the low address, and rotating left 1 bit (high
    ; order bit rotates to low order bit) after each byte is added.
    ;

    ComputeChecksum FUNC EXPORT

    move.l (sp)+, d0 ; Return address
    movea.l (sp)+, a1 ; High address
    movea.l (sp)+, a0 ; Low address
    move.l d0, -(sp) ; Restore return address
    moveq #0, d0

    ; Sum bytes in long word, rotating left one bit after each byte is added.

    @loop add.b (a0)+, d0
    rol.l #1, d0
    cmpa.l a1, a0
    ble.s @loop
    move.l d0, 4(sp)

    rts

    ENDF

Document Information
Product Area: Apple Software
Category: Utility Software
Sub Category: General Topics

Copyright © 2000 Apple Computer, Inc. All rights reserved.