Deploy, run, and debug your Linux project
Once you have created a Linux C++ project in Visual Studio and you have connected to the project using the Linux Connection Manager, you can run and debug the project. You compile, execute, and debug the code on the remote target.
There are several ways to interact with and debug your Linux project.
Debug using traditional Visual Studio features, such as breakpoints, watch windows, and hovering over a variable. Using these methods, you may debug as you normally would for other project types.
View output from the target computer in a special Linux Console window. You can also use the console to send input to the target computer.
Debug your Linux project
Select debugging mode in the Debugging property page.
GDB is used to debug applications running on Linux. GDB can run in two different modes, which can be selected from the Debugging Mode option in the project's Debugging property page:
In gdbserver mode, GDB is run locally, which connects to gdbserver on the remote system. Note that this is the only mode that the Linux Console window supports.
In gdb mode, the Visual Studio debugger drives GDB on the remote system. This is a better option if the local version of GDB is not compatible with the version installed on the target computer. |
If you are unable to hit breakpoints in gdbserver debugging mode, try gdb mode. gdb must first be installed on the remote target.
Select the remote target using the standard Debug toolbar in Visual Studio.
When the remote target is available, you will see it listed by either name or IP address.
If you have not yet connected to the remote target, you will see an instruction to use Linux Connection Manager to connect to the remote target.
Set a breakpoint by clicking in the left gutter of some code that you know will execute.
A red dot appears on the line of code where you set the breakpoint.
Press F5 (or Debug > Start Debugging) to start debugging.
When you start debugging, the application is compiled on the remote target before it starts. Any compilation errors will appear in the Error List window.
If there are no errors, the app will start and the debugger will pause at the breakpoint.
Now, you can interact with the application in its current state, view variables, and step through code by pressing command keys such as F10 or F11.
If you want to use the Linux Console to interact with your app, select Debug > Linux Console.
This console will display any console output from the target computer as well as take input and send it to the target computer.
Configure other debugging options
Command-line arguments can be passed to the executable using the Program Arguments item in the project's Debugging property page.
Specific debugger options can be passed to GDB using the Additional Debugger Commands entry. For example, you might want to ignore SIGILL (illegal instruction) signals. You could use the handle command to achieve this. by adding the following to the Additional Debugger Commands entry as shown above:
handle SIGILL nostop noprint
To debug ARM devices on Linux, see this blog post: Debugging an embedded ARM device in Visual Studio.
To debug using the Attach to Process command, see this blog post: Linux C++ Workload improvements to the Project System, Linux Console Window, rsync and Attach to Process.
Send feedback about: