LabVIEW developers can take advantage of several tools for a combination of static and dynamic code analysis to screen for problems and isolate their causes. These tools can reduce the time spent tracking down problems while providing more exhaustive and complete analysis of the software. This article offers an overview of the LabVIEW Desktop Execution Trace Toolkit and how you can use it for the dynamic analysis of LabVIEW applications.
To learn more about other software engineering tools for LabVIEW, visit ni.com/softwareengineering.
1. Introduction to Code Analysis Techniques
A formal code review is an important and common practice to reduce the risk of unforeseen problems, identify the causes of bugs that are difficult to find, align the styles of multiple developers, and demonstrate that the code works. These reviews are an opportunity for a team of qualified individuals to scrutinize the logic of the developer and analyze the performance of the software.
Manual reviews can quickly prove to be time- and cost-prohibitive for large applications; therefore, tools for static code analysis, such as the LabVIEW VI Analyzer Toolkit, are typically used to examine source code and proactively seek out potential problems. Once problems are identified, dynamic code analysis tools, such as the LabVIEW Desktop Execution Trace Toolkit, are valuable for gaining low-level insight into code execution and helping developers locate the causes.
- Static code analysis refers to any tool or method that has preestablished criteria by which it can compare source code to see if it meets standards for style, organization, and technique. This can be performed prior to, or even without, compilation or execution of the application.
- Dynamic code analysis refers to the ability to understand what software is doing under the hood during execution. In other words, it provides details about events and the context in which they occur to give developers a bigger picture and more information to solve problems.
2. Knowing When to Use Dynamic Code Analysis to Trace Execution
Dynamic code analysis is useful throughout the software development life cycle for the following:
- Detecting memory and reference leaks
- Isolating the source of a specific event or undesired behavior
- Screening applications for areas where performance can be improved
- Identifying the last call before an error
- Ensuring the execution of an application is the same on different targets
While all of these uses are appropriate, knowing exactly what you're looking for or where you're looking for it offers the greatest breakthroughs. This makes it easier to sort through the information to find details that can help address your specific concern.
3. Tracing a LabVIEW Application
The LabVIEW Desktop Execution Trace Toolkit is a stand-alone application that you can install with or without the LabVIEW development environment. However, it does integrate with the LabVIEW Project Explorer if installed on the same machine to enable automated configuration of traces.
To launch the LabVIEW Desktop Execution Trace Toolkit from within LabVIEW using an automatically configured trace, right-click on My Computer from within the LabVIEW Project Explorer and select Trace Execution from the menu that appears. When the toolkit opens, it is already set up to monitor all VIs in that project window during execution.

Figure 1. You can launch the LabVIEW Desktop Execution Trace Toolkit from within LabVIEW to automatically configure the toolkit to trace the current project.
Alternatively, users can configure traces themselves from within this tool by selecting New Trace from the menu at the top of the screen. From this dialog, users can select Local application instances, Remote application instances, or Application or Shared Library.

Figure 2. Selecting New Trace in the LabVIEW Desktop Execution Trace Toolkit reveals this dialog, which you can use to select either a local or remote application instance to monitor.
The first option, Local application instances, helps you trace an application on the same machine within the development environment. Selecting this option should list all of the active LabVIEW projects that are open. You also can use the toolkit to monitor remote systems over a network as well as executables and shared libraries. You can configure these from this dialog. Learn more about remote systems in the following section.
4. Tracing Deployed Systems and Remote Targets
Problems such as memory leaks can have costly consequences for systems that must operate for extended periods of time or for software that has been released to a customer. If software that needs debugging has been deployed and LabVIEW is not installed on the machine, you may want to perform dynamic code analysis with the LabVIEW Desktop Execution Trace Toolkit over the network. For deployed systems, even if the development environment is available, locally troubleshooting or profiling the execution of a running system may be impractical or difficult.

Figure 3. The LabVIEW Desktop Execution Trace Toolkit can monitor remote VIs, executables, and shared libraries via a network connection.
When developing an application to be remotely monitored, you must enable network communication with VI Server from the Options menu. For remote tracing of a VI in the development environment, make sure that the TCP/IP communication is turned on and select a port that is not in use (default is 3363). You also need to ensure that machine access is enabled for the terminal where the Desktop Execution Trace is located. For remote tracing of an executable or shared library, enable debugging from the Build Specifications menu and ensure that the VI Server port is available.
To connect from the LabVIEW Desktop Execution Trace Toolkit, select either Remote application instances or Application or Shared Library from the New Trace Connection dialog. Specify the IP address and the port on which VI Server is accessible, and select the instance from the list that appears.

Figure 4. Specify the IP address and port of the remote application instance to trace.
For more information on how to set up remote tracing, click here to see the LabVIEW Desktop Execution Trace Toolkit Help.
Configuring Traces
Before starting a trace, you can configure the tool to record only certain types of events. Click Configure on the toolbar to select from all of the different types and specify details such as the minimum size required to capture a memory allocation.
5. Understanding the Trace Data and Creating Filters
After clicking Start on the toolbar, the main view of the LabVIEW Desktop Execution Trace Toolkit enumerates every event in chronological order as the tool receives trace data. This view shows the time at which the event occurred, the name of the VI that fired the event, the type of event that was fired, the thread ID that it was assigned to, and any other appropriate details. Clicking on an event displays additional information, including the call chain that led to this event and which core that the process was actually executed on, in the panel below the table.

Figure 5. Highlighting an event from the table reveals additional information in the dialog below.
Double-clicking certain events when profiling instances that have access to the block diagram highlights the object on the block diagram that caused the event. For example, if you detect an unhandled error, double-clicking the event in the table highlights the VI as shown in Figure 6.

Figure 6. Double-clicking an event in the table highlights the corresponding object on the block diagram.
Keep in mind that a large application may result in a proportionate amount of run-time behavior data when performing dynamic code analysis. For this reason, you may want to create a filter to help wade through large amounts of data and target specific events or VIs. To set up a filter, click on the Configure Filter button on the toolbar above the table.

Figure 7. Because of the amount of data returned by large applications, you may want to use this toolkit to create custom filters.
Since filters are applied to events after they are received, the numbering of events is unchanged and shows gaps where other events have been filtered out.
6. Summary
Debugging code is a time-consuming and difficult task for developers. When software exhibits unusual or unexpected behavior that is not easily explained, dynamic code analysis with tools like the LabVIEW Desktop Execution Trace Toolkit can help you detect and isolate the cause of these problems.
7. Related Links
LabVIEW Desktop Execution Trace Toolkit Product Information
Software Engineering Best Practices for LabVIEW
Software Engineering Tools for LabVIEW
Large LabVIEW Application Development Resources
Large LabVIEW Application Community
Performing Validation and Automated Software Testing in LabVIEW

