[futurebasic] MacsBug

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2001 : Group Archive : Group : All Groups

From: Pete <furbies@...>
Date: Fri, 28 Sep 2001 18:36:32 +1000
I'm writing an .INCL that will allow me to determine if MacsBug is
installed, and if it is, then I can call some debugging FNs.

What I'm having trouble with, is determining if MacsBig is
installed/running.

From MacsBug 6.2 manual:

Support for debeuggers is provided beginning with the 128K ROM. When a
system error or 68000 exception occurs, the ROM code examines the global
variable MacJmp to obtain the address of the debugger¹s entry point. MacJmp
might contain additional information, depending on whether you are running
under a 24-bit or 32-bit Memory Manager.

If you are running under a 24-bit Memory Manager, the high-order byte of
MacJmp is a flags byte that contains  the following information:

Bit             Meaning
7               Set if debugger is running
6               Set if debugger can handle system errors
5               Set if debugger is installed
4               Set if debugger can support the Discipline utility

The lower 3 bytes of MacJmp are used to store the  address of the debugger¹s
entry point.

If you are running under a 32-bit  Memory Manager, the flags byte is moved
to address $BFF and the long word at MacJmp becomes a full 32-bit address
that points to the debugger¹s entry point.

When a debugger installs itself, it should set bit 5 in the flags byte to
indicate it is installed and, if it supports Discipline, it should set bit 4
as well. It must do this under either a 24-bit or 32-bit Memory Manager,
although, as mentioned above, this information will be stored in different
locations.

So from the above, and from a single example I found lurking on my HDs,
I wrote the following (untested code follows):

'===========================================

local fn determine24Or32BitMemMode

DIM   mem32BitMode    as int
dim @ gestaltResponse as long
dim   OSErr           as int

mem32BitMode = _false

OSErr = FN GESTALT(_gestaltAddressingModeAttr, gestaltResponse)
long if OSErr = _noErr
long if (gestaltResponse and _gestalt32BitAddressing%)
mem32BitMode    = _zTrue
end if
end if

end fn = mem32BitMode

'===========================================

local fn checkMacsBugInstalled

dim macsBugInstalled as int

macsBugInstalled = _false

long if fn determine24Or32BitMemMode' In 32bit memory
long if  [_Macjmp] ' Is address of MacsBug valid
macsBugInstalled = _true
end if
xelse' In 24bit memory
long if ([_Macjmp] AND &FFFFFF) ' Is address of MacsBug valid ?
macsBugInstalled = _true
end if
end if

end fn = macsBugInstalled

'===========================================

In 32bit mode, [_Macjmp] should be the address of MacsBug, if MacsBug is
installed, but I need help interpreting the flags byte at address $BFF

And I'm confused about testing the flags byte if I'm running in 24bit mode.

If I'm reading MacBug manual correctly, I reckon that I should test the flag
byte, even if [_Macjmp] is a valid value.

Are there any bit twidlers/macsbug experts/knowledegable persons who can
help ?

Pete...                             (the other one)