Apr 97 Tips
Volume Number: 13 (1997)
Issue Number: 4
Column Tag: Tips & Tidbits
Tips & Tidbits
By Steve Sisak
Debugging 68K Code Resources with MacsBug
I'm using a CDEF as an example here, but this technique can be quite useful in many situations.
I recently had the pleasure of writing a tiny application for an old client. There was actually more code in the custom CDEF than the app itself. Once it was all polished and "bug free" I took it to the client's site for a demo. Naturally, it crashed immediately on launch. Everything froze up and I had to do a hard reset. I strongly suspected my CDEF was the problem. Normally, I would put a DebugStr in the CDEF, recompile, and use MacsBug to find the problem. But this was a 4MB LCII. There was no chance of installing CodeWarrior and rebuilding the CDEF. However, the computer did have an old copy of ResEdit. The following is what I did.
1) I opened my application in ResEdit and used the GetInfo dialog to make my CDEF preloaded and locked. I then saved the file and quit ResEdit.
2) In MacsBug, I set an A-trap break on InitGraf.
atb _InitGraf
3) I launched my app. Since initializing QuickDraw is one of the first things my program does, my A-trap break fired and I dropped into MacsBug.
4) The MacOS automatically loads preloaded resources when the resource file is open, so I found my CDEF in memory and set a breakpoint. To find the resource, I typed "hd RS" (list all resources in the current heap).
The screen looked something like this
hd RS
Displaying the "Quick Launch" heap at 00192830
Start Length Tag Mstr Ptr Lock Prg Type ID
00194890 00000544 R 00192A00 L CODE 0001
00196872 00000A44 R 00192A04 L CDEF 0080
etc...
5) Since my CDEF was already loaded in memory, and locked down, I set a breakpoint at the beginning of the CDEF.
br 00196872
I then typed command-g to continue. My breakpoint was soon hit and the bug identified. I fixed the problem the next day and got paid. This technique can be used to set a breakpoint at the beginning of nearly any code resource.
Damon Cokenias
http://www.netgate.net/~cokenias
In the MacTech 13.02 (February 1997) we printed a tip from Bill Hayden that System 7.5.3 made it possible to navigate the Standard File dialog box by clicking items visible on the desktop. Since then, a number of readers have written to report they could not reproduce this behavior.
After trying a variety of system software releases, we have not found a publicly released version of the system exhibiting this behavior, although one reader has reported reproducing it on a version of System 7.5.3 release 2 but not 7.5.5.
We offer two possible explanations for the source of the tip. First is a freeware utility called "Click, there it is!", by Richard Cardona Utilities Group (now in version 1.0.7), which enables the behavior described in the tip. A second possible explanation is that the reported functionality may have been enabled in a developer release of system software, but removed from the final, public release.
In any case, we apologize for the error and thank everyone who took the time to report it, as well as those who have taken the time to submit tips - please keep them coming.
Best wishes,
--Steve