FB II Compiler







Disk I/O














Made with FB


Know if Macsbug is installed

Awhile ago, someone was wondering how to tell is macsbug was installed. I don't remember the outcome of the question, so here are a couple of notes I found on one of apple's sites. Note the dates.
Revised by: Developer Support Center September 1993
Written by: Developer Support Center October 1990
This Technical Note contains a collection of archived Q&As relating to a specific topic--questions sent the Developer Support Center (DSC) along with answers from the DSC engineers. Current Q&A's can be found on the Macintosh Technical Q&A's web site.

Determining whether MacsBug debugger is installed

Date Written: 9/9/92
Last reviewed: 6/14/93

I'm attempting to determine whether a debugger is installed, and if so, to find a THz pointer to its heap zone. Is this possible?

The MacsBug debugger is loaded into high memory above the value found in the global variable BufPtr ($10C). Since it's loaded into the memory that's not managed by the Memory Manager, it's not in a heap. The global variable MacJmp ($120) points to the debugger's entry point.

There's also a flags byte in low memory that contains the following information:

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

The flags byte may be in one of two places: the high-order byte of the long word at MacJmp, or the address $BFF. When MacsBug is loaded, it examines the value at address $BFF. If the value at $BFF is $FF, the system is using the 24-bit Memory Manager and the flags byte will be the high-order byte of the long word at MacJmp. If the value at $BFF isn't $FF, the system is using the 32-bit Memory Manager and the flags byte will be at address $BFF.

For information on debuggers other than MacsBug, you'll need to contact the publishers of those products.


How to tell whether a Macintosh debugger is installed

Date Written: 11/12/91
Last reviewed: 12/11/91

What is a robust way to tell if a debugger is installed? According to the MacsBug Reference, a low-memory global, MacJmp, contains the address of any debugger, but the manual doesn't say (1) whether this address is NIL or garbage if no debugger is installed, and (2) what the actual address of MacJmp is.

To determine if a debugger is installed, you do want to examine the low-memory global MacJmp vector; it is at address $120 and is 4 bytes long. When a debugger is not installed, the value there is 0. When a debugger is installed, the value there is non-zero. This is true for MacsBug and TMON, and probably for The Debugger. This is the standard way to determine if a debugger is installed; third-party debuggers should set this up properly.

X-Ref: "How MacsBug Installs Itself," MacsBug Reference, page 412.


Here is what the FB debugger uses (From the Dbug Tolz Source)

LONG IF ([_Macjmp] AND &FFFFFF) = 0 'Address of MacsBug
  PRINT "No MacsBugs Installed"
  PRINT "MacsBugs is at:";([_Macjmp] AND &FFFFFF)

And here is another that was posted by someone (Thanks to whoever!)

LOCAL FN IsMacsBugInstalled

  Result% = _False
'It doesn't seem to make a difference as to whether or not
'reg-width is 24 or 32 bit. It appears that $BFF ALWAYS
'contains 11100000b, if MB installed, and never $FF(255),
'as per some information I've seen.

  macsBug% = PEEK(&BFF) 'Get high-order word
  LONG IF macsBug% AND &70 <> 0 'Is MacsBug installed & running?
    Result% = _True
  END IF 'IF macsBug% AND &70 <> 0
END FN = Result%