Article ID: 42364
Article Last Modified on 11/21/2006
This article was previously published under Q42364
SUMMARY
When debugging memory problems (with heap or data) or system errors that may occur in QuickBASIC compiled programs, you can get a lot of information by surrounding the questionable statement with dead loops so you can drop into your favorite Macintosh debugger and dump the heap before and after. An illustration of this is shown below. This information is only appropriate for advanced Macintosh users who are already familiar with a Macintosh debugger.
MORE INFORMATION
Suppose you have a BASIC statement in a compiled program that you suspect is giving you memory problems. You can surround it with loops as follows:
zippy: goto zippy aBasicStatement zip2: goto zip2
Wait until the program hangs at the loop, then press the Macintosh Programmer's Switch on the outside of the Macintosh. At this point, you can dump the heap, etc. To proceed past the loop, leave the "Process Runtime Events" option off in the compiler. If you do so, these loops compile to the following:
L1: bra.s L1
Change this to NOP ($4e71) and continue executing. If the "Process Runtime Events" option is on, do the following:
- Dump the heap, while gathering the statistics you want, and locate the handle that is equal to the size of the MBRL resource (it is detached, so it will not show up as a resource).
Disassemble at the first data in the handle; you should see the following:
bra.l xxxx 'bra.l InterstatmentEventProcessor bra.l xxxx bra.l xxxx ...
- Set a breakpoint at the first "bra.l" and GO.
STEP once; you will see the following:
MOVEA.L (A7)+,A1 * Get return address. MOVEM.L A1/A3/A5/A6/A7,INTRLN(A0) * Save user state for RESUME. ADDQ.L #6,A1 * Bypass interline information.
- If you step PAST the ADDQ.L #6,A1, A1 contains the address of the code for the current statement.
- Disassemble at A1. You will see "bra.s xxxx". Change it to a NOP and continue executing.
Additional query words: MQuickB
Keywords: KB42364