Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!oliveb!apple!voder!pyramid!cbmvax!vu-vlsi!swatsun!jackiw From: jackiw@cs.swarthmore.edu (Nick Jackiw) Newsgroups: comp.sys.mac.programmer Subject: Re: LSC - how to find if the debugger is running? Message-ID: <2547@ilium.cs.swarthmore.edu> Date: 14 Mar 89 16:39:19 GMT References: <1806@viscous.sco.COM> Reply-To: jackiw@ilium.UUCP (Nick Jackiw) Organization: Visual Geometry Project, Swarthmore College, PA Lines: 49 In article <1806@viscous.sco.COM> jamesm@sco.COM (James M. Moore) writes: > I'd like to be able to do somthing like this in LSC 3.0: > > if (DebuggerIsActive()) > DebugStr("\pNow in Macsbugs"); > ... > > at the beginning of my main() procedure. This would be useful during > the debugging process, as I like to be able to go in and set > breakpoints before my code starts executing. How do I tell if the > debugger is running? > I assume you aren't talking about LSC's debugger, which I know nothing about (hence my assumption). For Macsbug et al., this should do the trick: The normal trap which the debugger invokes is $A9FF. Macsbug, TMON, etc. all patch this to point to something other than the in-ROM debugger (the empty dialog box with a '>' prompt, which--I think--accepts only DM, SM, and G commands [display mem, set mem, and go]). So what you want to do is determine whether trap $A9FF invokes the built-in debugger (worthless for breakpoints) or something else (i. e. your better- debugger-of-choice). Taking a clean (debugger-free) system, write a little program to print out the result of NGetTrapAddress($FF,ToolTrap) [cf. IM IV-234]. This is the address which a debuggerless Mac will hit; let's say it's X. Your DebuggerIsActive function is now the comparison NGetTrapAddress($FF,ToolTrap)<>X; i. e. whether someone has patched this to a different (and presumably better) debugger. Caveat: Never used LSC. LSP's DebugStr and other debugger commands CHECK whether Macsbug is installed before executing anyway (I think...maybe this only applies to their menu-invoked debugger calls). Hope this helps. > -- > ** James Moore ** > ** Internet: jamesm@sco.com ** > ** uucp: {decvax!microsoft | uunet | ucbvax!ucscc | amd}!sco!jamesm ** > ** Nil clu no suim ar bith ag SCO ceard a bhfuil me ag scriobh anois. ** -- +-------------------+-jackiw@cs.swarthmore.edu / !rutgers!bpa!swatsun!jackiw-+ | nicholas jackiw | jackiw%campus.swarthmore.edu@swarthmr.bitnet | +-------------------+-VGP/MathDept/Swarthmore College, Swarthmore, PA 19081--+ "Ah...I've got this CHRONIC pain." _True Believer_