[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

328.0. "Who called me?" by REGENT::MINOW (Martin Minow -- DECtalk Engineering) Mon Oct 06 1986 12:36

Many years ago, I implemented the "caller()" function in Decus C --
it returned a string that named the routine that called the current
function.  For example,

	main() {
		foo();
	}

	foo() {
		printf("%s\n", caller());
	}

would print "main".

This should be easy to do in VMS -- could any kind soul point me to
the proper incantation?

Thanks.

Martin.

T.RTitleUserPersonal
Name
DateLines
328.1easy in VMS?BLITZN::PALOComputer-friendly livewareMon Oct 06 1986 23:385
    why would this be easy in VMS?  What about the case where the program
    is linked/notrace (ie no DST information in the .exe).  Granted
    you could code a lot of the garbage,  but that's not VMS.
    
    	\rik
328.2huh?REGENT::MINOWMartin Minow -- DECtalk EngineeringTue Oct 07 1986 09:497
It should be easy in VMS because, if I abort the program, I get
a traceback with exactly the information I want -- module, routine,
and line number.  (I finally fixed the bug by crashing the program
at different places until I found the offending caller in the
traceback.)

Martin.
328.3keyword: TRACEBACKFROST::HARRIMANDEC 41-BLANK-03, Harriman,Paul J., qty 1Tue Oct 07 1986 10:1711
    re: .-1
    
    Sure, it's easy if you have traceback... But if you don't (.-2's
    scenario) you have a bigger problem... 
    
    Even though you don't have the symbolic information, the address
    of the caller should be on the stack somewhere, shouldn't it? Or
    the FP? Could someone refresh my memory?
    
    /pjh
    
328.4ULTRA::PRIBORSKYTony PriborskyTue Oct 07 1986 13:086
    Look at facility TRACE in the fiche.   If your image is linked /NOTRACE,
    you can't get there from here.   This will affect INSTALLed images,
    since with V4, you can INSTALL only if linked /NOTRACE.  [Has this
    been relaxed?   I seem to recall that shareable images can now be
    linked /DEBUG.   /NOTRACE => /NODEBUG.   Does the /NOTRACE on
    installed images now apply only to executable images?]
328.5What is the conflict?SKYLAB::FISHERBurns Fisher 381-1466, ZKO1-1/D42Tue Oct 07 1986 13:226
    re .4:  I don't know the answer to your question, but I don't see
    a conflict.  One need not install a sharable image in order to debug
    it.
    
    Burns
    
328.6No fair debugging installed PRIVED imagesTLE::AMARTINAlan H. MartinThu Oct 09 1986 13:214
Re .4:

Maybe you can only install an image *with privs* if it was linked /NOTRACE?
				/AHM
328.7INSTALL with privs <> LINK/TRACEWHOARU::MCCARTHYError Message #000000Thu Oct 09 1986 21:2411
    
 >   Maybe you can only install an image *with privs* if it was linked /NOTRACE?

  
    Is this a question?  I know INSTALL does not allow installation
    of an image with privs that has been linked with trace.
    
    I don't use install alot and therefore get caught by this once in
    a while.
    
    mac
328.8An incantation of sortsCASEE::COWANKen CowanSun Oct 12 1986 10:5932
	
    RE: .0
    
    It is very difficult to mung the DST records to get the information
    you want, however, you have easy access to the PC of the person
    who called you.   The VAX Architecture Handbook describes the 
    format of the call frame on page 278.   In BLISS the incantation
    is:
    
	LIBRARY 'SYS$LIBRARY:STARLET';
    
    	BUILTIN
    	    FP;
    
	LOCAL
    	    PC,
    	    FMP : REF BLOCK[, BYTE];
    
    	FMP = .FP;               
    	PC = .FMP [SF$L_SAVE_PC];

    
    Re: the other topic
    
    A privileged executable image has to be /NOTRACE for security, however,
    a sharable image it uses can have /TRACE enabled.   Since the
    executable is /NOTRACE, you won't get traceback, but other things
    using it will.
    
    I'm not sure how privileged sharable images behave.  
    
	KC