From:	SMTP%"wayne@tachyon.com"  6-APR-1995 08:51:17.81
To:	EVERHART
CC:	
Subj:	Re: RE: Debug bit in process header

From: wayne@tachyon.com (Wayne Sewell)
X-Newsgroups: comp.os.vms
Subject: Re: RE: Debug bit in process header
Message-ID: <1995Apr5.234215.295@tachyon>
Date: 5 Apr 95 23:42:15 CST
Reply-To: wayne@tachyon.com
Organization: Tachyon Software Consulting
Lines: 157
To: Info-VAX@Mvb.Saic.Com
X-Gateway-Source-Info: USENET

In article <3lhn9r$e27@amdint.amd.com>, gessling@amd.com (Jim Gessling) writes:
> From article <44081564@MVB.SAIC.COM>, by "GWDGV1::MOELLER" <moeller@gwdgv1.dnet.gwdg.de>:
>> Gandalf the Grey <SYSBRC%ALBNYVMS.BITNET@vm.gmd.de> writes:
>>> I have a C program that runs in the debugger but not without it (I know, fix
>>> the program, check for stack corruption). Well I have the source but the
>>> program is not mine and is large enought that I don't want to debug it.
>>>[...]
>>> I recall reading that there was a bit in the image header that controls
>>> debugger activation. If I can reset that bit perhaps the image will still
>>> run correctly but not invoke the debugger. In that case I can invoke it
>>> via foreign symbol and use the command line arguments.
>>>[...]
>> 
>> Pick up my (unsupported, but "standard") SET_EXE tool from
>> 
>> 	ftp.gwdg.de:/ftp/pub/vms/set_exe.com
>> 
>> which will let you modify the /[no]DEBUG and /[no]TRACE characteristics.
>> (It's all DCL, and works on both VAX and AXP for either sort of executable).
>> 
>> In your particular case, I could imagine that defining DBG$INPUT 
>> to point to a file containg just "GO", and then running the program 
>> with /DEBUG enabled _might_ help ...
>> 
>> Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdgv1.dnet.gwdg.de
>> GWDG, D-37077 Goettingen, F.R.Germany           PSI%(0262)45050859008::MOELLER
>> Disclaimer: No claim intended!  |  moeller@decus.decus.de   w.moeller@ieee.org
> 
> Or use patch and set the bits, too bad no patch on AXP, but here's how to do 
> it on VAX.

No problem with AXP if you have *access* to a VAX.  Copy the image over to the
vax, patch it, and copy it back.  If you are clustered, you don't even have to
do the copy.  PATCH, when used in absolute mode, doesn't recognize image files
at all, much less the difference between vax and alpha images.  It's just a
binary file.


> $ patch/abs filename.exe
> 
>   PATCH  Version 5-05    20-June-1991
> 
> %PATCH-I-NOGBL, some or all global symbols not accessible
> %PATCH-I-NOLCL, image does not contain local symbols
> PATCH>e 20
> 00000020:   010000A8
> PATCH>dep 20
> NEW> 010000A9
> NEW> exit
> old:    00000020:   010000A8
> new:    00000020:   010000A9
> PATCH>e 30
> 00000030:   000302D0
> PATCH>dep 30
> NEW> 7FFEDF68
> NEW> 000302D0
> NEW> EXIT
> old:    00000030:   000302D0
> old:    00000034:   00000000
> new:    00000030:   7FFEDF68
> new:    00000034:   000302D0
> PATCH> update
> %PATCH-I-WRTFIL, updating image file ...
> PATCH> exit
> 
> What's this all about?  at 20 in the image file are some flags, the
> low order bit set turns on the debugger, so add one to the value at
> offset 20 and redeposit that value.  at 30 is the array of entry points,
> examine 30 to see what your program uses.  Then deposit the debugger
> entry point (7FFEDF68 on my system, you can check this with anal/image
> on a known debug image).  So deposit this at 30 and then the original
> transfer address at 34 as the next in the array.  Update the image
> and you're off.  Executing the image with run or as a foreign command
> will enter the debugger.
> 
> Credit to longtime VAX guy Derek Frankforth (wherever you are) for 
> showing me this some years ago.  I've used it enough to remember 
> everything except the debugger transfer vector which I need to figure
> out each time.
> 

Here's the alpha version.  I posted it a couple of weeks ago, but what the
hell.  This is from the program comments of DELIVER (the version I ported to
AXP):



;
;
;       PATCH does not exist on AXP (as of version 6.1).  However, If you 
;	have a VAX system available, you can copy the image there, patch it,
;       and copy it back to the Alpha.  PATCH won't work in image mode in this
;       case, since it can't recognize an Alpha image (or the machine code,
;       for that matter), but the absolute mode works fine.  With absolute,
;       the image file is just a block of binary data.  If the Alpha is 
;       clustered with VAXen, or the Alpha disk is accessible in some other
;       way (other than DECNET), you can patch the image in place.
;
;
;      In an AXP image, the transfer address array consists of three quadword
;      addresses:
;
;
;               +--------------+
;       50:     |   01000028   |        ! Image flags
;               +--------------+
;
;               +--------------+
;       70:     |   00000F18   |        ! Transfer address array
;               +--------------+
;       74:     |   00000000   |
;               +--------------+
;       78:     |   00000000   |
;               +--------------+
;       7C:     |   00000000   |
;               +--------------+
;       80:     |   00000000   |
;               +--------------+
;       84:     |   00000000   |
;               +--------------+
;
;
;
;       As with the VAX, set bit 0 in the flags to be 1.
;       The transfer address to allow traceback is different for the Alpha.
;       The first transfer address must be changed to FFFFFFFF 00000340 (for
;       AXP VMS V6.1, don't know about 1.5 and earlier) while the existing 
;	address must be moved down to the second quadword.  So, our example 
;	would become:
;
;               +--------------+
;       50:     |   01000029   |
;               +--------------+
;
;               +--------------+
;       70:     |   00000340   |        ! Transfer address array
;               +--------------+
;       74:     |   FFFFFFFF   |
;               +--------------+
;       78:     |   00000F18   |
;               +--------------+
;       7c:     |   00000000   |
;               +--------------+
;       80:     |   00000000   |
;               +--------------+
;       84:     |   00000000   |
;               +--------------+
;
;
-- 
========================================================================
Wayne Sewell, Tachyon Software Consulting   |wayne@tachyon.com
>>mail to pgpkey@tachyon.com for pgp key    |(214)-553-9760
Key fingerprint =  77 A5 C1 56 9C ED F1 8E  89 F9 27 3C 86 79 F7 1B 
========================================================================
Elwood:"It's 109 miles to Chicago.  We got a full tank of gas, half a pack of
cigarettes, it's dark, and we're wearing sunglasses."    Jake: "Hit it."
