LabWindows/CVI User Group Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows/CVI Tip: Attach Debugger to a Running Program

LabWindows/CVI 2010 includes a new feature to allow you to allow developers to attach the LabWindows/CVI debugger to a running Process, without having to restart the program. With this tool, developers can more efficiently debug source code and gain additional insight into application failures and crashes.

Attaching the LabWindows/CVI debugger to a process

The LabWindows/CVI debugger can be attached to running processes or programs that have crashed.

To attach to a running process, select Run»Attach to Process.

attach to running process.png

To attach the LabWindows/CVI debugger to a crashed program, you will use the LabWindows/CVI just-in-time debugger. This is  installed and registered as the default just-in-time debugger when you install LabWindows/CVI. If you later install software that registers a different just-in-time debugger, you can re-register the LabWindows/CVI just-in-time debugger by selecting Tools»Register Just-In-Time Debugger.

just in time debugger.png

Attach to process options

  • Available Processes - This will displays the currently running processes to which you can attach the LabWindows/CVI debugger.
  • Show processes from all users - This will display processes created by all users logged into the computer.
  • Show processes in all sessions - This will display all processes running in other logon sessions.

process list.png

You can attach to external processes, including executables that were not built with LabWindows/CVI. This is most useful in the case where the external process calls a LabWindows/CVI-built DLL. Use the Attach to Process dialog as an alternative to the Specify Executable to Debug command, which requires that you load the DLL project before the external process is started.Additionally, LabWindows/CVI installs and registers a just-in-time debugger you can use to attach to and debug a crashed process at the time of the crash.

Obtaining the most useful information

To receive the most useful debugging information, build the DLL or EXE you want to debug in LabWindows/CVI 2010 or later and in debug configuration.When you attach the LabWindows/CVI debugger to a process that contains LabWindows/CVI debug information, the source code opens in LabWindows/CVI when the program breaks, either by hitting a breakpoint or by a break command being issued by the environment. While the process is suspended you can use breakpoints and other LabWindows/CVI debugging tools to debug the process.

Adri Kruger
National Instruments
LabVIEW Product Marketing
Comments
ondrej.h
Member
Member
on

Thank you for the tip, it's very useful, especially since dettaching from a process is available in CVI 2013. By the way, is it possible to automate or simplify (shortcut) the process of attaching to a process when I only need attach debugger to Teststand?

Constantin--P
NI Employee (retired)
on

Ondrej,

I assume you have a dll written in LabWindows/CVI and you are calling into this dll from Testand. If you want do debug this dll, you could open the dll project in CVI and in Run>>Specify Executable and Command Line in Program name you could select teststand(Path\SeqEdit.exe). If your CVI verision is prior to 2013 the menu is Run>>Specify Executable to Debug. Then, when you press the Run button Teststand in launched and when your dll functions are called the breakpoints set in CVI will be honored. Does this answer your question?

Constantin

ondrej.h
Member
Member
on

Hi Constantin,

thank you for your answer. I use "Specify Executable..." quite often, but I would prefer attach to a process and detach from a process options, because I don't want to launch Teststand again every time when I need to break execution of CVI dll. Some button or shortcut key for attaching debugger to already running Teststand would be perfect for me.

Ondrej

Constantin--P
NI Employee (retired)
on

There is not such button or shourtuct key. For the menu Run>>Attach to Process I guess the reason for Shortcut key or Toolbar button don't exist and can't be customized is that this menu is not used very often.

You'll have to perform a few mouse clicks.

ondrej.h
Member
Member
on

You are probably right. I also didn't use it before, because it didn't seem to be so useful, but now in CVI2013 it perfectly makes sense when you can detach CVI debugger from a Teststand without ending it. Launching Teststand takes quite a long time and it's annoying to do it repeatedly.

Contributors