NI Linux Real-Time Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Microsoft Visual Studio with NI Linux Real-Time

Debugging NI Linux Real-Time Applications using VisualGDB

What is VisualGDB

A plug-in for Visual Studio that allows seamless debugging within the familiar Windows Visual Studio environment of GDB-debug-based targets, including our RT Linux devices. This has been verified to work on Linux x64 targets, but there should be no reason it can't work for ARM the same way.

visual_gdb.png

Getting Started

Download and install the 30-day evaluation version from http://visualgdb.com/

Setting up the target

  1. Enable SSH from MAX. The plugin uses SSH to execute GDB remotely, list processes, transfer files, etc.
  2. Install GDB and dependencies on the target. Newer target Base images appear to have GDB pre-installed, although it is missing some of the threaded debugger support so you need to add that:
    1. Install GDB if not already there
      1. opkg update
      2. opkg install gdb
    2. Make backup of ld.conf
      1. cp /etc/ld.so.conf /etc/ld.so.conf.backup
    3. Fixup threaded debugging by updating libc6
      1. opkg download libc6
      2. opkg download libc6-dbg
      3. opkg install libc6*
    1. Restore ld.conf
      1. cp /etc/ld.so.conf.backup /etc/ld.so.conf
  3. Install sudo (seems to be needed for the base scripts it tries to run)
    1. opkg install sudo
  4. Update "sudoers" file to allow admin to sudo.
    1. Put attached sudoers file in /etc/sudoers (normally you use visudo to edit it, but this should work too) - https://nitalk.jiveon.com/servlet/JiveServlet/download/187661-1-166390/sudoers

Debugging Target

  • The first time you install it and open Visual Studio, it will bring up quick-start wizard to create a new target

  • Setup a new SSH connection for a Linux debug (hostname/username/password)

  • If debugging a program it will launch, just fill in the parameters as you would expect
  • If you want to attach to an existing process, like LVRT, leave all the fields blank but check the box at the bottom "I would like to enter additional GDB commands ... before debugging starts"
  • Save Preset as new name
  • Starting debug
    • If debugging an app that is launched at debug time via your preset, just do Debug->Quick Debug With GDB
    • If attaching to a process, go to Debug->Attach to Process and select VisualDBG as a transport. You should see your existing target config preset as one of the populated options. Clicking it should list all the processes. Select "MainAppThread" process if you want to debug code running in LVRT.
    • After clicking Attach, it will start debugging in a broken-in state. You can hit Continue and the process will be live again.
  • Symbol files are loaded automatically if you have debug builds with symbols.
  • If you cross-compiled the binaries from your host (so the source paths match), it just finds your source automatically.
  • If you have symbols but the source paths don't line up (built on another machine), if you point VS at one source file in the hierarchy for that binary, it appears to figure out all the rest relative to it
  • Code for libraries (libc, pthreads, etc) automatically download from the target when you click on a stack frame if they exist in known system paths. I was debugging a hang in a pthread_join and it automatically pulled source from /usr/src/debug/eglibc/2.17-r4/eglibc-2.17/libc/nptl/pthread_join.c (I'm guessing the libc6-dbg package downloaded it?)

Known issues

  • Going to the Attach to Process multiple times in a single debug session sometimes generates an error (under VS2013). The only way to get around it (that is saw) was to re-launch VS.

National Instruments
Comments
brosner99
Member
Member
on

Excellet article. VisualGDB also enables remote native compilation with Visual Studio. I'm not sure about RIO but PXI and CDAQ Linux boxes have plenty of space and horespower to compile natively. You need to install the gcc compiler and a few utilities to get this going in addition to installing sudo and libc6 (which happened to already be the latest rev on the compact daq I tried).

opkg install gcc gcc-symlinks

opkg install gdb gdbserver

opkg install binutils

opkg install diffutils

opkg install libgcc-dev

opkg install libstdc++-dev

Visual Studio 2017 (to be released in March) also includes Microsoft developed remote native Linux compilation and debugging in the box but I havern't tried it yet.

 

 

Paul-D
NI Employee (retired)
on

Hi, your images and links are currently linking to internal NI resources that external will not be able to see.

Paul Davidson
National Instruments
Product Owner - ni.com Chat
Contributors