home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / System / Debugger FKEY 1.0 / Debugger FKEY.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-09  |  2.1 KB  |  59 lines  |  [TEXT/KAHL]

  1. #include <GestaltEqu.h>
  2. #include <Traps.h>
  3. //
  4. // According to the Macintosh Technical Notes (PT 535-MacsBug Q&As) we have:
  5. //
  6. // ================================ citation start ================================
  7. // The MacsBug debugger is loaded into high memory above the value found in the
  8. // global variable BufPtr ($10C). Since it’s loaded into the memory that’s not
  9. // managed by the Memory Manager, it’s not in a heap. The global variable MacJmp
  10. // ($120) points to the debugger’s entry point.
  11. // 
  12. // There’s also a flags byte in low memory that contains the following information:
  13. //
  14. // Bit 7  Set if debugger is running.
  15. // Bit 6  Set if debugger can handle system errors.
  16. // Bit 5  Set if debugger is installed.
  17. // Bit 4  Set if debugger can support the Discipline utility.
  18. //
  19. // The flags byte may be in one of two places: the high-order byte of the long word
  20. // at MacJmp, or the address $BFF. When MacsBug is loaded, it examines the value at
  21. // address $BFF. If the value at $BFF is $FF, the system is using the 24-bit Memory
  22. // Manager and the flags byte will be the high-order byte of the long word at MacJmp.
  23. // If the value at $BFF isn’t $FF, the system is using the 32-bit Memory Manager and
  24. // the flags byte will be at address $BFF.
  25. //
  26. // For information on debuggers other than MacsBug, you’ll need to contact the
  27. // publishers of those products.
  28. // ================================= citation end =================================
  29. //
  30. // Thus, one would expect that
  31. //
  32. //            "Debugger present <=> (MacJmp != 0)".
  33. //
  34. // On a Mac IIx with 8MB RAM, however, MacJmp contained the value '0x80000000' when
  35. // MacsBug was not installed. If MacsBug was installed it seemed to contain the
  36. // address of an entry point to MacsBug. Therefore we use a slightly different
  37. // way to detect the presence of MacsBug:
  38. //
  39. //            "Debugger present <=> ((MacJmp & 0x0FFFFFFF) != 0)"
  40. //
  41. #define MacJmp 0x120
  42.  
  43. void main()
  44. {
  45.     asm
  46.     {
  47.         move.l    MacJmp,D0
  48.         and.l    #0x7FFFFFFF,D0
  49.         beq.s    @noDebuggerPresent
  50.         dc.w    _Debugger
  51.         rts
  52.     
  53.     noDebuggerPresent:
  54.         move.w    #0x09,-(sp)
  55.         dc.w    _SysBeep
  56. //        rts        automatically included at end by Think C
  57.     }
  58. }
  59.