How to Get Caller's Name in TestStand

Updated Oct 28, 2024

Environment

Software

  • TestStand

A developer can suspend the execution and find out the call stack in the Call Stack pane in TestStand development environment. However, you would not be able to see the Call Stack pane if you are running a sequence with the custom User Interface. With this technique, the complete call stack can be output to a text file or the user interface for troubleshooting.

To get caller's name recursively, you need to complete the following steps.
  1. Launch NI TestStand.
  2. Insert 2 sequences by right-clicking the Sequences Pane, selecting Insert Sequence.
  3. Rename them to Sequence_1 and Sequence_2.
03.PNG
  1. Go to MainSequence and insert a Sequence Call step.
    • Rename it to Call Sequence_1
    • Check Use Current File
    • Select Sequence_1 from Sequence drop-down list
04.PNG
  1. Go to Sequence_1 and insert a Sequence Call step.
    • Rename it to Call Sequence_2
    • Check Use Current File
    • Select Sequence_2 from Sequence drop-down list
05.PNG
  1. Go to Sequence_2.
    • Add a String Locals Variable CallStack
    • Add a Number Locals Variable i
    • Add a Number Locals Variable out
06.PNG
  1. Add a Statement step in Sequence_2
    • Type in Locals.CallStack = "" in the Expression text box
07.PNG
  1. Add a For step in Sequence_2
    • Type in RunState.Thread.CallStackSize in the Number of Loops
    • Type in Locals.i in the Loop Variable
08.PNG
  1. Insert a Statement step between For and End step
    • Type in Locals.CallStack+= RunState.Thread.GetSequenceContext(Locals.i, Locals.out).CallStackName + "\n" in the Expression text box
09.PNG
  1. Add a Message Popup step after End step in Sequence_2
    • Type in "Call Stack:\n" + Locals.CallStack in the Message Expression text box on the Text and Buttons tab
10.PNG
  1. In the NI TestStand, select Execute » Single Pass to run the sequence.
 

The Message Popup window displays the complete call stack for the execution thread as shown below. Furthermore, you could save the output string Locals.CallStack to a log file for further troubleshooting.
12.PNG