From: mors@tessella.co.uk (Stephen Morris)
Newsgroups: comp.os.vms
Subject: Re: How do you RUN a program with parameters?
Date: 18 Dec 92 09:59:01 GMT
Organization: Tessella Support Services plc, Abingdon, England

In article <1ga33pINN8jn@nz12.rz.uni-karlsruhe.de> 
DAHMS@ifk20.mach.uni-karlsruhe.de (Heribert Dahms) writes:

>And now my question:
>====================
>
>How can I force like RUN/DEBUG or RUN/NODEBUG ?
>I usually compile and link with /DEBUG but sometimes want to prevent debugger
>startup. I don't want to patch flags in the image file.
>Can I write a jacket program which accepts /[NO]DEBUG and starts the image
>named by the first argument accordingly and passes remaining arguments?
>The routines LIB$RUN_PROGRAM or LIB$FIND_IMAGE_SYMBOL don't seem fitting to me.
>i.e.
>	$ ccrun := $disk:[directory]ccrun
>	$ ccrun/nodebug myprogfilename <Pass this rest of line as args>
>
>
>Thanks, Heribert (dahms@ifk20.mach.uni-karlsruhe.de)

I had a similar problem, in that I was working on a large program, which took
ages to start up if it was LINKed/DEBUG.  I came up with the following
solution, which allowed me to "switch off" the debugger.

Regards,
Stephen Morris (mors@tessella.co.uk)
(Standard disclaimers apply)

	.TITLE NULL_DEBUGGER
;+
; Description:
;	If a program is LINK/DEBUGged, VMS will automatically invoke the
;	debugger when the program is run.  Although the debugger can be
;	inhibited by a RUN/NODEBUG, this is not always possible (e.g. if the
;	program if invoked via a DCL command).
;
;	NULL_DEBUGGER can take the place of the VMS debugger in these
;	circumstances, and allow the program to run as if the debug flag was
;	not set.
;
;	To build NULL_DEBUGGER, issue the following commands:
;
;		$ MACRO NULL_DEBUGGER
;		$ LINK/SHARE NULL_DEBUGGER,SYS$INPUT:/OPTIONS
;		BASE=0
;		^Z
;
;	To use the null debugger, define the logical name LIB$DEBUG to be the
;	image NULL_DEBUGGER.EXE, then run the program as normal.
;
; Author:
;	S. A. Morris	 October 1988
;-

; Size of data areas.

XFRVEC_SIZE = <4 * 4>			; Transfer vector array size
ARGLST_SIZE = <7 * 4>			; Argument list size
BYTES_RESERVED = XFRVEC_SIZE + ARGLST_SIZE

; Offsets in stack data area. These offsets are from the location of the frame
; pointer (FP).

XFRVEC = - XFRVEC_SIZE
ARGLST = XFRVEC - ARGLST_SIZE

; Declare the debugger data structures.

	.PSECT	CODE EXE,NOWRT

	.LONG	0			; Ignored (?)
	.LONG	0			; Ignored (?)
	.ADDRESS NULL_DEBUGGER+2	; Transfer address

	.ENTRY NULL_DEBUGGER ^M<R2,R3,R4,R5>
	SUBL2	#BYTES_RESERVED,SP	; Reserve space on stack for data

; Set up the new transfer vector array, with the debugger address removed.

	MOVL	4(AP),R0		; Transfer vector array address
	MOVQ	4(R0),XFRVEC(FP)	; 2nd and 3rd -> 1st and 2nd addresses
	MOVL	8(R0),XFRVEC+8(FP)	; 4th -> 3rd address
	CLRL	XFRVEC+12(FP)		; Zero a new 4th address

; Set up the new argument list for the program. This is identical to the
; argument list passed here, but with the transfer vector array address
; replaced.

	MOVC3	#ARGLST_SIZE,(AP),ARGLST(FP) ; Move argument list across
	MOVAL	XFRVEC(FP),ARGLST+4(FP)	; Set new transfer vector array
	CALLG	ARGLST(FP),@XFRVEC(FP)	; Transfer control to program
	RET				; Return to caller

	.END NULL_DEBUGGER
Newsgroups: comp.os.vms