From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
TurboPhil

Expose "Call Chain" as VI Property

Status: Declined

As per the discussion, this would be impractical if not technically impossible to implement.

The only way I know of getting the call chain of a VI is with the Call Chain primitive, which only works on *this* VI (the VI calling the primitive). It would be nice to expose that as a VI server property, so we could get the call chain of any VI by reference.

 

callchain.png

18 Comments
PaulG.
Active Participant

I'm surprised we can't do that already.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Bob_Schor
Knight of NI

I don't have an example on which to try this out, but I believe if the VIs are in memory, this is easily accomplished:

VI Callers.png

Of course, this lists all of the VIs that can call VI Refnum -- if that is a "popular" sub-VI, going up the chain can quickly get out of hand.

JimChretz
Active Participant

I unkudoed because Bob just cleared that out.

 

Of course we can't have the Call chain of a VI reference because one VI can be used in multiple contexts simultaneously, so the same VI can have several call chain arrays depending on where it's actually running, that's why we have to use the function in the code to have the actual chain...

 

I think with recursivity we can build the entire tree structure of the VIs in memory.

TurboPhil
Active Participant

Callers is not the same as Call Chain.

  • It only presents the immediate caller (parent), not older generations (e.g. grandparents/caller's caller, etc.)
    • Yes, you could theoretically do this recursively to get older generations, except:
  • For reentrant VIs, it returns all callers of all instances. If I want to know the immediate caller of a specific clone instance, this won't work.
JimChretz
Active Participant

I'm not convinced about your reentrant concern, have you tested it?

 

Each clone instance has its own reference and VI name, somevi.vi:1, somevi.vi:2... so they should have their own callers list, which contain only one caller each.

TurboPhil
Active Participant

Yes, I have tested it. Look at this example (sorry it's kinda sloppy):

vi_name.PNG

 

Notice that I get the same list of "Callers" both from the static VI reference (so, basically the "template" for the reentrant VI) as well as for a specific clone instance.

CoastalMaineBird
Trusted Enthusiast

Like I said on the forum thread, I don't see how this can possibly work.

 

If A calls X

and B calls X

and C calls D which calls X,

then what is the "call chain" for X?

 

Go ahead, tell me, I'll wait.

 

If you answered anything except "I don't know" then you're wrong.

 

Call Chain is a trail of EXECUTION control.  It's possible WITHIN a VI instance, because you're talking about one instance, at one point in time.

 

If X is reentrant, then all three instances of X could be executing at the same time.  Which call chain do you mean?

 

If X is NOT reentrant, then which call chain do you mean? A, B, or C-->D ?  The refnum isn't going to tell you that.

 

It can't be done.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

CMal
Active Participant
I agree that it doesn't make any sense to try to get a VI's call chain from a VI reference. A VI reference is specific to one instance of a VI, but that instance may be called in many different locations, each of which will have a different call chain. The "call chain" simply isn't a property of a VI. It's a property of the execution of a VI. I don't see any way this idea could be implemented.
JimChretz
Active Participant

It might make sense to have this property that would return a 2D array or array of clusters containing all the different call chains.

igagne
Member
You want the one instance that's on the wire sort of like the exec.state property method. In the above example you'd get an array with just the callee because its being dynamically called.