Operating System - OpenVMS
1753962 Members
7211 Online
108811 Solutions
New Discussion юеВ

Name of the invoking funtion

 
SOLVED
Go to solution
Jairo Alves
New Member

Name of the invoking funtion

We wish to print out (log), within a called module, what is the calling module name.

What would you recommend?

Thanks,
Jairo
12 REPLIES 12
RBrown_1
Trusted Contributor

Re: Name of the invoking funtion

In the absence of a better specification, I would try using the traceback handler. Perhaps you could call lib$signal with a status of 3.
Hoff
Honored Contributor

Re: Name of the invoking funtion

What would I recommend?

More words around your problem statement.

This question can go in dozens of directions...

Off the top, what programming language? What version? Operating system platform? Version? Compiled with debug, or not? Are there specific application run-time or traceback requirements? Any specific source code portability requirements?

Some background on the problem, in other words.

If you're catching errors, I might well suggest the process dump mechanism, or dynamically activating the debugger.

For differing requirements, I might then suggest one of the (documented) stack traceback calls.

Here's a write-up on the ACCVIO and infomation on how that works, with links to signal handling and to examples of callable traceback:

http://labs.hoffmanlabs.com/node/800
http://labs.hoffmanlabs.com/node/803
abrsvc
Respected Contributor

Re: Name of the invoking funtion

If you are looking for getting names etc WITHOUT image termination, it is possible but will require programming that is not trivial and likely to be hardware platform dependent and not supported. As was stated before, additional information about what you are attempting and why is necessary for us to provide proper guidance.

Dan
Hein van den Heuvel
Honored Contributor

Re: Name of the invoking funtion


Right, you probably want to call the Trace BacK handler to sort this out.

Documented, with sample code in :

http://h71000.www7.hp.com/doc/83final/4493/4493pro_070.html

support routines used ...

tbk$show_traceback
tbk$i64_symbolize
lib$i64_get_curr_invo_context
lib$get_curr_invo_context
lib$get_prev_invo_context

I have attached a sample function to just return callers name, with integrated test.

hth,
Hein.
Brad McCusker
Respected Contributor

Re: Name of the invoking funtion

It's easy to do from DCL using symbols, assuming you own (i.e. can modify) the calling modules.

Here is a very simple, very NOT robust example. Depending on your environment, you will probably want to add a lot more, particularly in the area of initial invocation and exit and error handling. This is intended purely to provide you an example of the concept, the routine names reflect my opinion of the code:

$ ty junk1.com
$!
$ say := write sys$output
$ if("''p_name'" .eqs. "")
$ then
$ c_proc = "NONE"
$ else
$ c_proc = "''p_name'"
$ endif
$!
$! Name of THIS procedure
$!
$ this_p = f$env("PROCEDURE")
$ p_name = f$parse(this_p,,,"NAME","SYNTAX_ONLY")
$!
$ say "Routine ''p_name', called from ''c_proc'"
$ @junk2.com
$ say "Back to Routine ''p_name', called from ''c_proc'"
$ @junk3.com
$ exit
$
$
$ ty junk2.com
$!
$ say := write sys$output
$ if("''p_name'" .eqs. "")
$ then
$ c_proc = "NONE"
$ else
$ c_proc = "''p_name'"
$ endif
$!
$! Name of THIS procedure
$!
$ this_p = f$env("PROCEDURE")
$ p_name = f$parse(this_p,,,"NAME","SYNTAX_ONLY")
$!
$ say "Routine ''p_name', called from ''c_proc'"
$ @junk3.com
$ say "Back to Routine ''p_name', called from ''c_proc'"
$ exit
$
$
$ ty junk3.com
$!
$ say := write sys$output
$ if("''p_name'" .eqs. "")
$ then
$ c_proc = "NONE"
$ else
$ c_proc = "''p_name'"
$ endif
$!
$! Name of THIS procedure
$!
$ this_p = f$env("PROCEDURE")
$ p_name = f$parse(this_p,,,"NAME","SYNTAX_ONLY")
$!
$ say "Routine ''p_name', called from ''c_proc'"
$ exit
$
$
$ @junk1
Routine JUNK1, called from NONE
Routine JUNK2, called from JUNK1
Routine JUNK3, called from JUNK2
Back to Routine JUNK2, called from JUNK1
Back to Routine JUNK1, called from NONE
Routine JUNK3, called from JUNK1
$

Brad McCusker
Software Concepts International
www.sciinc.com
Brad McCusker
Software Concepts International
Jairo Alves
New Member

Re: Name of the invoking funtion

Thanks everyone for the help so far.

I will explain the problem better.

Programming Language: Compaq Fortran 90, OS: OpenVMS 7.3.2, compiled without debug and no special portability requirements.

Apparently, one of our applications is leaving some data files locked, causing the other modules to not be able to access them.

As we do own the reading/writing routines, we would like to log the name of the calling method every time it holds a data file locked. So that whenever an ACCVIO error is thrown, the log file will tell us where the problem lies.

Any help would be appreciated.
Thanks
Hein van den Heuvel
Honored Contributor
Solution

Re: Name of the invoking funtion

>> Apparently, one of our applications is leaving some data files locked, causing the other modules to not be able to access them.

Hopefully the modules running into the record lock report the file/key/value or just report 'waiting for lock on xxx' and actually use RMS to wait for the lock.
In that case it is trivial to use ANAL/SYST... SET PROC ... SHOW PROC/LOCK to identifiy the lock being waited for (8 byte length, RFA contents) and the lock blocking it.

The module doing the lock obviously long since came and went.

>>> As we do own the reading/writing routines, we would like to log the name of the calling method every time it holds a data file locked.

Hmm, that doesn't sound to effective. Log thousands to catch 1?

>> So that whenever an ACCVIO error is thrown, the log file will tell us where the problem lies.

Huh?
1) why would a lock result in an ACCVIO?! Fix that error handler! And if it did ACCVIOP did it not produce a stack dump with MODULE names/line numbers?
2) but the lock might become a problem thousands of operations, hours, after it was obtained.
3) why not report the file/key #, key value and figure out who has the lock, if an when needed?

Attached a program (requires CMEXEC) which can report the lock holder more easily than ANAL/SYSTEM can.

[ I'm thinking of a variant which can be installed with privs and can be requested to report on a lock via mailbox or some such. Contact me if that would help you even more ]

Good luck,
Hein
abrsvc
Respected Contributor

Re: Name of the invoking funtion

You may be overcomplicating things here a bit. As stated earlier, an ACCVIO should create a stack dump including all of the calling/called routines. I'd start there using that info and the .LIS files. Perhaps it is a simple error easily found that way.

Dan
Hoff
Honored Contributor

Re: Name of the invoking funtion

Without intending offense, are you using the OpenVMS Debugger for troubleshooting here, or are you attempting this using logging and embedded print statements for debugging?

(This task is directly within the Debugger's bailiwick. While the OpenVMS Debugger isn't exactly maintaining parity with debugging on other platforms, it's still a useful tool for this task.)

If you're looking for which process has the blocking access, then AMDS or Availability Manager or ANALYZE /SYSTEM or Hein's tools can help; you can trace down the grant lock that way. But most any application that references the file can be a potential culprit for a collision, depending on the timing of the access. Resolving that usually some combination of retries and moving off the lock after a timeout.

If you identify the culprit, then you can send a $forcex or equivalent, and then have a look at the traceback in the target environment for the call chain. Here's the basic sequence:

http://labs.hoffmanlabs.com/node/800

There are tools that send the $forcex to the specified process available from the OpenVMS Freeware, or you can create your own in a dozen lines of C. And recent versions of VMS have a way to do this from the DCL command line; see the STOP /ID /EXIT stuff.

RMS just isn't all that good at this sort of "meta-locking" task, unfortunately; you get to roll your own coordination and your own archival processing atop the RMS locking.