F From:	SMTP%"MACRO32%WKUVX1.BITNET@uu7.psi.com"  7-JUL-1993 11:59:49.27 To:	EVERHART CC:	, Subj:	Re: Clarification on Debugger Question  O X-Listname: "VMS Internals, MACRO, & BLISS Discussions" <MACRO32@WKUVX1.BITNET>  Warnings-To: <> - Errors-To: MacroMan%WKUVX1.BITNET@uu7.psi.com * Sender: MacroMan%WKUVX1.BITNET@uu7.psi.com" From: <jnelson@gauche.zko.dec.com> X-Newsgroups: vmsnet.internals/ Subject: Re: Clarification on Debugger Question  Date: 7 Jul 1993 15:01:35 GMT + Organization: Digital Equipment Corporation 	 Lines: 65  Distribution: world * Message-Id: <21eogf$9cl@usenet.pa.dec.com>+ Reply-To: MACRO32%WKUVX1.BITNET@uu7.psi.com % Nntp-Posting-Host: gauche.zko.dec.com  X-Newsreader: mxrn 6.18-5  To: MACRO32@WKUVX1.BITNET  X-Gateway-Source-Info: USENET     7 In article <mcdermott-170693120519@ckm3885.draper.com>, 7 mcdermott@draper.com (Christopher K. McDermott) writes: E |>I have found a work around for the problem (see original article) I C |>was having, as illustrated below, but, I would still like to know G |>extactly what the *debugger* is doing with the space above the top of H |>the stack.  Again, if anyone has a clue about what it is doing, or howH |>to stop it (like tell the debugger that this a MACRO routine, and I'll. |>be mucking with the SP), please let me know.  D And then in article <1993Jun25.000118.1@condor>, blacka@logica.co.uk (Andrew Black) replies: H |>My understanding of how the debugger works is as follows. When you setG |>a breakpoint, it plants a BPT instruction in the code.  When reached, E |>it casuse the CPU to take an exception, which in turn places signal E |>and  mechanism arrays on the stack.  This then filters through into G |>DEBUG.  Likewise, single stepping casues an exception to be taken for G |>every instruction.  thus the area of stack that is logically above SP E |>(arithmetically below sp) is likely to be fairly heavily visited by A |>debug, by any other conditions that your program may invoke, by 	 |>ASTs...  |>E |>( I don't vouch for the details of how debug works, but I am pretty  |>sure of the general idea)   A I would have answered this sooner, but I've been on vacation. The F explanation given by Andrew is on the mark. DEBUG does make use of theH user mode stack. When an exception is delivered, not only are signal andF mechanism arrays pushed (by the VMS exception delivery mechanism), butD debug's exception handler is called, so it's using stack space, too.E Debug's exception handler invokes other routines as well. There is no $ way to change or stop this behavior.  F The original problem Chris was having with his thread context switcherC has been solved, but I'd still like to give this warning: homegrown H thread context switchers must take extreme care when writing into FP andB SP. Don't violate the rules/assumptions in both the Alpha (or VAX)H Architecture Reference Manual and the OpenVMS Calling Standard Manual orE you will have no end of troubles. Two important rules I can think of:   E 1. SP must always point to valid memory, otherwise exception delivery  (e.g., debugging) will fail.  K 2. SP is always equal to or less than FP. In other words, SP>FP is illegal. @ This implies that FP and SP have to be updated *very* carefully.  F The prefered way to handle this is to not handle it at all, but to useG CMA and let it worry about the details. Not only that, but the debugger H has special capabilities for debugging CMA threads which isn't available to homegrown thread managers.   D Your own business needs will determine whether or not it makes senseD to replace a homegrown thread package with CMA, and I can understandI that for some it makes sense to try and stick with the homegrown package. I This warning is intended primarily for those who need thread capabilities H and are thinking of writing a thread manager. You don't know what you're8 getting into, and it's best if you keep it that way. :-)   Hope this helps.   -Jeff E. Nelson  -OpenVMS DEBUG Architect -Digital Equipment Corporation% -Internet: jnelson@gauche.zko.dec.com ; -Not an official statement of Digital Equipment Corporation 