[mod.computers.vax] Thanksgiving gift: DEBUG_{ON,OFF}

LEICHTER-JERRY@YALE.ARPA (11/27/86)

I've found the following two command files very useful when doing program
development.  @DEBUG_ON <image> produces a new version of <image> that, when
run, will start up in the Debugger, as if it had been linked /DEBUG.  Any
debugging information available in the image will be used, but obviously what
isn't there can't be used...the effect is really equivalent to typing CTRL/Y -
DEBUG just before the image starts executing.  DEBUG_ON works with any image,
including an image that was linked /NOTRACEBACK.  (Note that such an image
will contain no symbols at all.)

Conversely, @DEBUG_OFF <image> produces a new version of <image> that will NOT
start up in the debugger.  However, any debugging information in the image is
unchanged, so that a later CTRL/Y - DEBUG will have access to all the local
symbol information, etc.  Note that, since the debugger is NOT started, it
will NOT be there to gain control if the image dies due to some sort of excep-
tion (until you type CTRL/Y - DEBUG) (or signal SS$_DEBUG?).

There is one limitation with DEBUG_OFF'ed images:  If you are too fast about
typing CTRL/Y - DEBUG, you may get an error message from the debugger and
end up back in DCL.  I don't know exactly what "too fast" means; empirically,
if you wait for your program to issue a prompt before doing CTRL/Y, it seems
to work.

DEBUG_ON and DEBUG_OFF produce various warning and informational messages as
they run.  Presumably, they'll produce some other messages if something goes
wrong.  Since I've never seen anything go wrong, I don't know what messages to
expect.

Both command procedures take an optional second parameter that is the spec of
the output file - default is a new version of the input file.

				N O T I C E

This stuff is VERY unsupported - by anyone, including me.  "You break it, you
bought it."  It works on VMS V4.3 and V4.4, and will PROBABLY work on other
versions.

Enjoy!
							-- Jerry

------------------------------DEBUG_ON.COM------------------------------------
$ o = ""
$ if p2 .nes. "" then o = "/OUTPUT:" + p2
$ on warning then goto move
$! Try to just turn the "LNKDEBUG" bit on
$ patch/absolute/journal:_NL:'o' 'p1'
examine/word 2
define base = \
!
verify/long base = 7FFEDF68
!
examine/long 20			!get the link flags
deposit/long 20 = <\/2>*2+1	!set the LNKDEBUG bit
!
update
$ exit
$! No previous entry for debugger in vector, do things the hard way:
$! (insert one)
$move:
$ on warning then continue
$ patch/absolute/journal:_NL:'o' 'p1'
examine/word 2
define base = \
!
examine/long base + 8
define contents = \
deposit/long base + 0C = contents
!
examine/long base + 4
define contents = \
deposit/long base + 8 = contents
!
examine/long base
define contents = \
deposit/long base + 4 = contents
!
deposit/long base = 7FFEDF68
!
examine/long 20			!get the link flags
deposit/long 20 = <\/2>*2+1	!set the LNKDEBUG bit
!
update
$done:
------------------------------DEBUG_OFF.COM-----------------------------------
$ o = ""
$ if p2 .nes. "" then o = "/OUTPUT:" + p2
$ patch/absolute/journal:_NL:'o' 'p1'
examine/long 20			!get the link flags
deposit/long 20 = <\/2>*2	!clear the LNKDEBUG bit
!
update
$ exit
-------