ResEdit Hacking MacsBug
Anyone who runs an unattended server Mac will appreciate a little-known feature of MacsBug 6.2.2. You can define a FirstTime/EveryTime macro that automatically restarts the Mac if it crashes into MacsBug, rather than sitting with an error message on its screen. You need ResEdit to do this, and all standard warnings about ResEdit corrupting the moral fiber of today’s youth apply.
But first, some background. MacsBug is a free low-level debugger from Apple that normally only programmers use. However, MacsBug has a few commands useful to non-programmers, and I find that MacsBug sometimes helps me identify guilty applications when I have strange crashes. Here are the basic MacsBug commands for non-programmers:
- ? — Gets help from MacsBug. Issue the command ? g for help on the g command, for instance.
- g — Tells MacsBug to start executing the program at the point where MacsBug was entered. This is normally not too useful because you enter MacsBug primarily in a crash situation, and you can’t generally continue from that point. You use the g command when you accidentally enter MacsBug (such as by pressing the interrupt switch).
- es — Tells MacsBug to "exit to shell." On the Mac, the Finder is the shell, so you’re telling MacsBug to quit the current application and go to the Finder. Try this first after crashing into MacsBug. There is a related command, ea, which stands for "exit to application," which tells MacsBug to quit the current application and restart it. I find that this almost never works, so I don’t even bother trying it.
- rs — Tells MacsBug to unmount all volumes other than servers and then reboot the Mac. This is generally what you do when es doesn’t work and you want to reboot. There is a related command, rb, which unmounts the boot volume only and then reboots the Mac. I have multiple volumes, so I generally use rs. I haven’t noticed any real difference.
As I said, you can define a macro that will run automatically when MacsBug is entered. Note that this by no means solves any problems – it’s like replacing a fuse immediately after it blows without checking why the fuse blew. It’s useful for keeping a Mac that crashes occasionally running most of the time. A MacsBug wizard might be able to modify the macro to open a log file, do a few things (like a stack crawl, or at least log the reason MacsBug was called), close the log, and then restart. The user would then have a record of what happened and why, which could be shared with the developer. However, that’s beyond my MacsBug skills, although I’m willing to accept clarifications or modifications. On to the hack!
- In ResEdit 2.1.2, open a copy of the file Debugger Prefs.
- Open the mxbm resource.
- From the Resource menu, choose Create New Resource.
- Click on the first entry, 1) *****, and then go to the Resource menu and choose Insert New Field(s).
- In the Macro name box, type "FirstTime", and in the Expansion box, type "g" (both without the quotes).
- Click on the second entry, 2) *****, and then from the Resource menu select Insert New Field(s).
- In the Macro name box, type "EveryTime", and in the Expansion box, type "rs" (again, both without the quotes).
- Close the "mxbm ID = 128 from Debugger Prefs" window, make sure that resource is still selected (it should be), and from the Resource menu choose Get Resource Info.
- In the Name: box, type "Works FirstTime/EveryTime", close the Info window, save the file, and quit ResEdit.
Make sure that both MacsBug and the modified Debugger Prefs file are loose in the System Folder (not in any special System 7 folders), and reboot. The next time the Mac crashes and enters MacsBug (this won’t help when the Mac just freezes), the macro will restart the Mac. Test it by hitting the interrupt switch.
MacsBug is available on <ftp.apple.com> as:
If you use the Centris 610 and low-end 650 with the 68LC040 chip, you need a special version of MacsBug, which is available as:
Unfortunately, this special version doesn’t include the Debugger Prefs file, so you’ll have to get both versions of MacsBug if you have one of the affected Centris models. Rumor has it that you need a new version of MacsBug for the most recent PowerBooks as well, but that might best be a question for APDA, your dealer, or 800/SOS-APPL.
AutoBoot — Those who want more functionality at the risk of patching a few traps should check out the shareware AutoBoot utility from Karl Pottie. AutoBoot is a Control Panel/Extension that reboots your Mac if a certain amount of time has passed after a System Error or freeze. I haven’t used the latest version of AutoBoot, but since it can reboot the Mac after a freeze, it is potentially more useful than my MacsBug hack. However, as an extension, there’s always a chance that AutoBoot could conflict with something. If you want to try AutoBoot, it’s available for anonymous FTP on sumex-aim.stanford.edu as:
— Information from:
Karl Pottie — [email protected]