Find Callers vs. Find All Instances

Hello LabVIEW friends,

Sometimes it can be very useful to know where a bit of code is used or called from. There's several ways of doing this in LabVIEW: Find Callers, Find All Instances and VI Hierachy to name a few.

My job involves a lot of debugging - in fact, I would say I spend much more time debugging existing systems than writing new code. When I first started, I had no idea about when I should choose Find Callers over Find All Instances. I was surprised that I couldn't see the differences between them listed anywhere - neither in the documentation or on the forums. So I've made an attempt at comparing the two tools from my own experience. Let me know in the comments if there's anything I missed!

Firstly, here are some example results that the two tools give. 

Find callers results window
'Find Callers' Results Window


Results obtained by Find All Instances tool
'Find All Instances' Results Window for the same Control

You can see they don't match - Find Callers has found 5 callers, while Find All Instances lists 7 items. This is because the control is used twice in a couple of the VIs, which is picked up by Find All Instances but not Find Callers.

Here are some more differences:

 

 Find Callers (help page)

Find All Instances (help page)

How accessed

Right-click an item in the Project Explorer window and select Find»Callers from the shortcut menu to display this dialog box. Or you can use the Find:Callers Property. (Text taken from documentation.)

Right click the VI icon in the Block Diagram or VI Hierachy window. Also works from the icon/connector pane.

What it searches

All callers of a specific item in the project. (So if it has a caller outside the project, you won’t find it.)

 

Only instances in VIs/objects that are loaded to memory. So if the VI/object containing a particular instance is not in memory (read: open), you won't find it.

What it finds

Highlights the caller VI/object(s) in Project Explorer.

The location that the VI is called from i.e. where it is on the block diagram. Also front panel for controls.

How the results are displayed

  • No callers: 'No items were found' dialog box
  • Single caller: selects it in the Project Explorer
  • Multiple callers: dialog box

Note that it only tells you which VI calls it, not where in the VI is called! And it has no way of telling you if the caller calls the VI in multiple places on the block diagram.

 

Top tip: you can output a list of results as a .txt file. This can be useful for external documentation.

  • No instances: empty list
  • Single instance: highlights the instance on the block diagram
  • Multiple instances: A dialog box with the options to replace selected VIs


Note about the 
Ø symbol in column 2 in the image posted previously:  "A strikeout icon appears next to an entry in the Search Results list if LabVIEW cannot replace that instance. For example, you cannot replace the text in a Property Node or an Invoke Node. You also cannot replace text in running VIs." (Text taken from documentation.)

 

Can you quickly jump between the callers?

Yes: after clicking 'Go To', you can press CTRL+G to select the next caller in the list on the project explorer. CTRL+Shift+G will cycle backwards.

Yes: the next caller in the list is opened and highlighted when you press Ctrl+G. Again, CTRL+Shift+G will cycle backwards.

Does it keep a record of which callers you have visited?

No

Yes: callers that you have navigated to (using CTRL+G or Go To) have a tick by their name.

Can you use it while the VI is running?

Yes

The option does not come up when you right click the icon/connector pane but it DOES seem to work from the VI Hierachy window. I honestly don’t know why, so if you can explain the logic behind this, please post in the comments.


Polymorphic VIs are one of the 'gotchas' with Find All Instances. If you right click a polymorphic on the block diagram it will find instances of any of the polymorphic VIs - to see the specific VI you need to open that one up directly. Also if you are calling VI's by reference, these methods won't work.

 

While on the subject of callers, did you know that it is possible to find items with no callers? I think of it as doing the weeding. If you see anything on here that isn't a top level VI, chances are that it is not being used!

Finding Items with No Callers

So, how can we put this information into practice? I mentioned that 'Find Callers' only tell you which VIs are callers, not where in the VI they are called. This makes things tricky when the caller VIs are large. A good strategy is to open the caller VI and then use 'Find Instances' on the VI of interest to highlight where exactly the call happens.

Hope you find this useful, and please mention in the comments if you have any tips of your own with  Find Callers/All Instances.

Cheers,

Leah

Comments

  1. Great Post! Just had to explain this to someone the other day. It is definitely confusing for beginning users.

    ReplyDelete

Post a Comment