Earlier this year I wrote a post on how you could debug C++ code on Linux from Visual Studio. It was a bit cumbersome, but it was doable. Today we are releasing the Visual Studio GDB Debugger extension preview. This will enable debugging remote Linux targets including IoT devices.
To use this extension, you need to have Visual Studio 2015 Community or higher with the Visual C++ tools for Android installed. Those tools use the open source MIEngine that provides the support for the Visual Studio debugger to use Machine Interface that GDB and LLDB use. The GDB Debugger extension introduces a new project type that surfaces additional project properties that allow you to connect the Visual Studio debugger to GDB either locally or remotely, including on remote Linux targets.
To get started go download the GDB Debugger extension from the VS Gallery and install it. This post is going to walk through how to use the extension in detail, from project creation to F5 including how to configure your Windows and Linux environments for SSH. I’ll have a post next week on how to use this with a Raspberry Pi.
Project creation
After you’ve installed the extension, create a new project and you’ll find a new template for Makefile Project GDB) under Visual C++, Cross Platform.
When we select that and create a new project we get a new empty solution with some supporting files and a readme. Much of what is covered in the readme is covered below, but with more pictures. 🙂
If we take a quick look at the project properties, you’ll see under the debugging tab we’ve added options for a Remote and Local GDB debugger. We’ll cover these options in more detail below.
Once configured you can hit any breakpoints you set and the normal VS debugger experience you are accustomed to will be there; peek, watch, setting and removing breakpoints, etc.
Configuring SSH
Local SSH Clients
First you will need to get a local SSH client. You may use the SSH client of your choice, for example the Win32 Port of OpenSSH, PuTTY, MinGW, or Cygwin. The SSH client will be used to securely tunnel Machine Interface commands to a remote GDB executable.
For PuTTY you need to use plink.exe as the SSH Executable. You will probably also want the full putty.exe client and pscp.exe for copying files to your Linux machine. You will need puttygen.exe for creating your private key for SSH access. The tools in the Win32 OpenSSH port and from Putty can be used in the NMake build step in VS. Note that MinGW/Cygwin based SSH is fine for the SSH Executable but cannot be used from the build step in VS due to how we launch processes there.
Creating your keys on Windows
At this time we cannot support certificates that have a pass phrase.
To generate private/public keys for Win 32 OpenSSH use the ssh-keygen utility as follows
ssh-keygen.exe -t rsa -f yourkey
Your private key will be in the file specified above as yourkey and the public key will be in a file yourkey.pub.
For PuTTY you need to create a certificate usable for SSH authentication by running puttygen and clicking generate.
Save the private and public keys to use in subsequent steps.
Adding your public keys on the Linux machine
On your Linux machine you need to add the public key to the ~/.ssh/authorized_keys file. If it doesn’t exist look below for how to create it. Each public key should be on one line. You can do this as follows once the file already exists.
nano ~/.ssh/authorized_keys
In the editor this invokes right click on a new line to insert the copied public key text. The screenshot above shows my file that has two keys added to it. Hit ctrl-x to exit which prompts you to save.
If the file does not already exist do the following first:
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
chmod 0700 ~/.ssh
chmod 0600 ~/.ssh/authorized_keys
Connecting with SSH
To connect from an SSH client:
ssh.exe -i privatekey user@host
To connect from PuTTY, load your saved session and then go to Connection, Data and set your user name. Now under Connection expand SSH and under the Auth node add the private key you saved. Go back to the session page and save it. Now you can open a session using keys without a password. Simply double click the session name to open it.
On your first connection you will be prompted to save the host as a trusted connection. You must do this via your SSH client before the other tools can connect via cert auth from within Visual Studio.
GDB debugging on an Azure Linux VM
While we’re describing this with an Azure VM the principles are the same for any machine running Linux be it a hosted/local VM, server or device. The only real requirement we have on the remote Linux target is that you can securely connect over SSH using certificates and that GDB is present. Go here if you need help getting started with Azure Linux VMs.
For your source you probably already have something. If you do add it via add existing item by right clicking on the VS project. You can also add a new item if you are just trying this out. For this example I added a new item main.cpp which I added the following to.
#include <iostream>
using namespace std;
int main()
{
int loops = 10;
for (int i = 0; i < loops; i++) {
cout << “loop number ” << i << endl;
}
cout << “All done” << endl;
return 0;
}
The source obviously isn’t interesting, it’s just here to exercise the steps below.
You will need to get the remote machines address, e.g. myServer.cloudapp.net. You can get that in the Azure Portal by selecting your VM and copying the DNS address on the main page.
I’m going to use Putty tools for connecting in this example. No matter which tool you use you’ll want to connect to the remote target at least once so you can accept the prompt to add it to your trusted hosts before scripting connections in VS.
Go to the properties on the project from and on the Debugger tab set the “Debugger to launch” to “Remote GDB”.
Here I need to set my host name, user name, my private key and the secure shell I want to use. When using PuTTY tools I need to use plink as that is the tool used for piping commands as opposed to the interactive PuTTY terminal. Now I can set the remote working directory and remote executable. I have no arguments for the executable and gdb is fine as my remote debugger executable. Apply those changes so we can see these values as we create our build command.
We will use pscp from PuTTY for this in combination with our parameters from the build tab for the private key, user, host and remote working directory. When you are copying files this way to a Linux host make sure the remote directories you are using already exist. Next we’ll specify the build command line with the remote executable name as commands passed via plink. Note here if there are spaces in your parameter values you should escape them with quotes. We specify these on the build command line of the Nmake tab of the project properties.
If you open that line for edit you will be able to see parameter names evaluated.
c:\tools\pscp.exe -i $(PrivateKey) “C:\Users\mgoodner\Documents\Visual Studio 2015\Projects\Project1\Project1\main.cpp” $(RemoteUserName)@$(RemoteHostName):$(RemoteWorkingDirectory)/main.cpp
$(SecureShellExecutable) $(RemoteUserName)@$(RemoteHostName) -i $(PrivateKey) “cd $(RemoteWorkingDirectory);g++ -g main.cpp -o $(RemoteExecutable)”
Now we see the debugger is set to Remote GDB, set a breakpoint in the loop and you can F5.
Let it build and we see we hit our break point. You’ll get the normal functionality you’d expect, e.g. setting and removing breakpoints, adding watches, etc. If you connect to the machine with your ssh client you will see the files are present in the remote destination and you can run the executable there directly as well.
If you hit an error and your output window has a message that “More than one remote source not supported”, check if there is a space at the end of your host name, if so delete it.
Local GDB debugging
In addition to Linux you can use the GDB Debugger extension on Windows, for example using MinGW. Note that you will want your MinGW bin folder, e.g. C:\MinGW\bin, on your path. That provides us with the GNU compilers, gcc, g++ and the gdb debugger that we’ll describe here. Let’s modify the project properties from the example above to run locally. Change the Debugger to Launch drop down from Remote GDB to Local GDB.
For the options we will specify the full path to where our source is, do not let the selection dialog use the “.” convention. We can specify our executable name and gdb is fine as it is on our path.
Now tell VS how to build this. On the NMake edit the build command line. First hit “Apply” so we can see the values from what we set on the debugging tab get evaluated. We’ll use g++ to build this which works as it is part of my global path already, and we’ll pass it the source in our working directory, tell it to emit the debugging symbols and output the executable name we specified in our working directory.
We can now see that the debugger is set to Local GDB, now you can F5.
We’ll let it build and we see we hit our breakpoint again.
More on scripting your build
The project properties from the debug tab are all available for use in the NMake build command line. Note that you can set values for both Remote and Local GDB for use in your build command line even though you are only launching one or the other. The properties available are:
Host Name: $(RemoteHostName)
User Name: $(RemoteUserName)
Private Key: $(PrivateKey)
Secure Shell Executable: $(SecureShellExecutable)
Remote Working Directory: $(RemoteWorkingDirectory)
Remote Executable Name: $(RemoteExecutable)
Remote Executable Arguments: $(RemoteExecutableArguments)
Remote Debugger Executable: $(RemoteDebuggerExecutable)
Local Working Directory: $(LocalWorkingDirectory)
Local Executable: $(LocalExecutable)
Local Executable Arguments: $(LocalExecutableArguments)
Local Debugger Executable: $(LocalDebuggerExecutable)
Local Debugger Server Address: $(LocalDebuggerServerAddress)
For targeting Linux your source must be built on a remote Linux machine. By invoking pscp from the build command line you can copy your source(s) to the remote Linux machine. Using plink you can invoke the compiler on the source on the remote Linux machine. The plink command is capable of executing any command supported by the remote target.
Here is an example remote file copy and build command line using PuTTY Tools:
pscp.exe -i $(PrivateKey) source.cpp $(RemoteUserName)@$(RemoteHostName):$(RemoteWorkingDirectory)/source.cpp
plink.exe $(RemoteUserName)@$(RemoteHostName) -i $(PrivateKey) “cd $(RemoteWorkingDirectory);g++ -g source.cpp -o $(RemoteExecutable)”
Note that we do not support MinGW/Cygwin SSH tools invoked from the build command line due to how we launch that process. You can use the PowerShell tools port of OpenSSH here including their implementation of sftp.
Here is an example of building on the local Windows machine (presuming g++ is on the global path).
g++ $(LocalWorkingDirectory)\source.cpp -g -o $(LocalWorkingDirectory)\$(LocalExecutable)
Conclusion
This is our first preview release and we need your feedback on what is working for you and what isn’t. We hope to hear from those of you building cross platform apps, services running on big Linux servers and of course everyone with devices that I hope you are connecting to Azure IoT. We hope to release regularly and are working on enabling this with local GDB servers that interface with On Chip Debuggers for even smaller device targets. If that is of interest to you please get in touch with us via the blog or you can find me on Twitter @robotdad.
–Marc Goodner















I'm glad to see it. Great work as always.
Works great, thanks!
It would be nice to have a possibility to set the environment variables for the remote process (such as e.g. DISPLAY or PATH), but this can be worked around by using a wrapper debugger script.
This is great start, please continue, I'd like to use VS for all Linux and Windows development
Is the GDB integration based on github.com/…/MIEngine so I don't have to switch to this extension if I'm already successfully using github.com/…/MIEngine ?
@kai yes the extension uses the MIEngine. It provides a new project with properties for use in invoking the MIEngine instead of having to do it via xml files passed via the VS cmdline with Debug.MIDebugLaunch
I am certainly interested in using this with debuggers for microcontrollers. I have spent quite a lot of time before trying to get GDB working in other environments for MSP430 microcontrollers with no success, if this is a use case that you want to support in VS, that would be very exciting.
awesome work
Needs an additional options section for the ssh command ( for options such as port number)
(I worked around this by adding a -p 2222 to the end of the private key item which does not quote its path)
also LF -> CRLF conversion on the output would not go amis
Thank you adding Linux support in VS.
Please simplify the overall process like VisualGDB(http://visualgdb.com/)
For me Visual GDB doesn’t seem to be able to connect for remote debugging, so I’m not sure it’s so simple.
Good idea, but for desktop cross-platform development it is much easier to use Qt Creator; if I have to create separate project in Visual Studio to debug with GDB, it will not give any advantage. When I develop cross-platform C++ application, I have Visual Studio project for Windows and Qt Creator one for Linux. If I can debug on Linux directly from traditional Visual C++ project, it will be very useful feature. If I anyway have to support 2 projects, what is advantage against Qt Creator, Eclipse, etc, i. e. what is advantage against native Linux tools?
This sounds cool, but could you make it so that you could debug Mono Apps running on a Raspberry PI as well?
Thanks
Nice !!
I tried this with a centos machine. A few things I see:
The gdb command doesn't accept quoted path names: e.g if you have your putty in "c:program files (x86…."
I had to revert back to using c:progra~2…
The quoted command does work for the build command lines , i.e. when adding the plink commands
Also, the breakpoint wasn't hit. I.e using the a simple test program (Hello world.. type) I could copy and build and actually invoke the debugger, but the Bp wasn't hit, it just ran through.
The target linux machine did have a gdb 7…. something (mathing with the gcc 4.81 toolset)
Anything I'm missing?
the next thing would be getting Intellisense to point to the right linux files…
Thank you adding Linux support in VS.
Please simplify the overall process like WinGDB
Great extension!
Could you please extend this to MCUs such as MSP430, STM32F4 and support for C and you'll have an awesome IDE.
I can't wait to start using VS to debug my microcontroller and .NETMF projects.
Good job.
Having to specify each source file to copy over can be painful via the NMake build command. Are there plans to simplify this, especially considering that MSBuild can easily collect all the source files and required header files already? Perhaps you can add a "Copy to Remote Command" which gets invoked for each source file where you can do something like:
pscp.exe -i $(PrivateKey) $(CurrentSourcePath)$(CurrentSourceFile) $(RemoteUserName)@$(RemoteHostName):$(RemoteWorkingDirectory)/$(CurrentSourceFile)
@Steve thanks! I struggle with how much to paramaterize here. I like how you worked around this, the only spot I saw so far as a feature was the string to invoke gdb where I often need sudo. I'll follow up with an explanation of how the params are turned into the connection so you can deterministicly add options we have not exposed.
@benpye shoot me a mail at mgoodner my employer .com if you'd like to talk more about micro controller support, especially if you could test prerelease bits.
@Vitaliy that is good feedback. So your cross platform work is in C++ and built for Windows and Linux? Mac? Are you cross compiling for any of those targets or are you always building the source with a toolchain on the target OS?
@Peter I'll look into that. I've got a lot on my plate right now with C stuff so it may be a while before I have anything to report there. Feel free to ding me about it on twitter @robotdad esp during Dec when I'll be off and hacking on side projects
@robin I'm spinning up a centos machine now to see if there is anything there. Regarding spaces in paths that should be fine, but on the NMake tab they should be surrounded by quotes.
@jose working on it! 🙂
I want to try this feature but i have a major block of adding header and source files separately. Is there an option to add source code folder and its subfolders in the project.
awesome, I've been dreamed about it for years
I got it working for my setup! Some lessons I learned along the way:
1. Do not quote your paths: "C:Foo_VM.ppk" and so forth. I entered them like that because I Shift-rightclicked the files in question and used the Copy-as-Path option.. but that causes a pretty nasty error along the lines of: "Unable to start debugging. Launch options string provided by the project system is invalid."
2. There was a codepage problem somewhere inbetween VS, plink and the remote server. I do not know whether I fixed it at the correct/ideal location, but setting the exporting a LC_ALL variable on the remote side before doing anything else solved my problems in a satisfactory enough manner. For example, my Build Command Line is configured as follows:
"C:ProgramsPuttyplink.exe" jw@devBuntu -i D:keysdevBuntu.prv.ppk "export LC_ALL="POSIX";cd /home/jw/dev/myapp/src";make
The debug messages of my app are primarily in the ASCII range, so I haven't seen any issues there with the actual debug process, but I'd love to know whether it is an issue and if so, what the best way to solve that is.
Good luck everyone!
Good job! However, I am missing the possibility to start the program without debugging in a normal console window (simply start the remote process with plink).
@Antonio you are right, that is something we should look into
@mankisheeri I agree this is painful, I'll add it to the list of things to improve
@kdt ah, of course. Right now the only output we have is via gdb in the output window which isn't ideal.
Good idea but we need a complete cross compilation solution such as http://visualgdb.com/
We want to be able to use a custom cross compiler toolchain to target any linux based device.
If you could also import a CMake project file you will have a killer plugin !
Interesting, but this functionality has been available since 2009 as a third party extension WinGDB. Please check out http://www.wingdb.com. WinGDB supports Visual Studio 2005-2015.
WinGDB integrates with standard VS projects (no special project type introduced). It also works with CMake. Supports cross-compiling toolchains.
Yesterday the gdb BP was not hit (although gdb was invoked). Today, with the same project,using plink seems to have problem:
plink unknown option –interpreter=mi
I suppose this needs to be somehow quoted/escaped.
Or changing the project file somehow destroyed this.
I tried this on freshly installed Ubuntu 1404-vm. The toolchain is gcc 4.8.4 gdb-7.7.1 .
I am using putty 0.65 toolset on the windows machine.
the build lines work, though.
Please forget/ delete my last post, for some reason I was using putty instead of plink for GDB!!
Anyway, the problem still is that breakpoints are not set, the program just runs through
Wow Marc, I was just looking to try to start a project on the pi using C++. Really looking forward to your post next week. Interesting point, will it be likely that I can compile a mixed mode exe? I would really like to build something with a ASP.Net vNext front end.
for those wanting CMAKE integration, I did it the other way around, I created the project the conditionally added it to the CMakeLists.txt file when in windows.
if(WIN32)
#include windows project for debugging GDB
INCLUDE_EXTERNAL_MSPROJECT(MSVCGDB "${CMAKE_CURRENT_SOURCE_DIR}/linux/MSVCGDB /v.vcxproj")
endif(WIN32)
This works wonders when sharing the source code directory as a full compile then compiles both on Windows and Linux in one step. it has saved me plenty of time already.
Hi Marc,
Just manged to configure the project with remote GDB debugging .
However have problems to run my application, since it needs to set the LD_LIBRARY_PATH environment variable as application working directory.
Is there any way to define above variable for gdb on remote machine?
Thanks,
Roman
I am trying to get this working with a short Linux program on a Raspberry Pi, and I am having all kinds of problems. For example, my code has this:
#include <mqueue.h>
But when I try a build, VS has no idea where to find mqueue.h. This happens even if I replace <mqueue.h> with the full path name for that file. It feels like none of the Linux environment variables are set correctly. A regular Linux of the same project runs fine.
I probably have many of the project properties set incorrectly. Examples of how to handle all the various things under VC++ Directories would be useful.
This sounds awesome. But does that mean we'll be able to debug any code running in a GDB? Even Perl and stuff?
+1 for a Mono Raspberry Pi solution. I often develop applications on Windows Embedded Handheld devices and would love something similar for the Raspberry Pi.
+1 for support for MCU's using C language.
I've tried this using a STM32 discovery board (a plain embedded target) and openocd but without any success. The VS debugger just hangs waiting for the target to halt.
When I did it manually via gdb I had to give the command 'monitor reset halt' before doing anything else so I guess adding that would resolve the issue. So far I haven't found a way to do that though. 🙁
Has anyone succeeded to debug a similar target?
Maybe the the code is available so I can add an entry for an initial gdb command?
@Stig Andersson, I am trying exactly the same thing… but cant get the plugin to install…
contact me dan [at] walms.co.uk see if we can help each other.
Great work! What is missing:
– CRLF->LF conversion
– automatic file synchronization between local/remote folders (could be automatic for all files included to project, but need to have some optimization for large projects, like you can assume remote has up-to-date copy of local and copy only locally changed files, and make menu option for manual "full" synchonization)
– coredump debugging (must have!!!!)
– detailed options page for SSH
– "Remote Build Command" which does not require entering $(SecureShell), so just need to write like "make …. " – the same as if you'd do that in some native Linux IDE, like KDevelop. SSH command should be some fixed pre-configured one (on the SSH config tab I've mentioned above)
And what generally nice to see in Visual Studio –
Multiple Run configuration within one Build configuration.
How to attach to running process on linux?
Please post details having this work with a Rasperberry Pi, Thanks!
@Dan Walmsley
I mailed but got no response. Did it end up in the spam/junk folder?
Looks tempting. Why does it need the Android development tools ? I don't develop on android. All I'd want is to connect to a remote linux server and debug my code there.
Nice to see a begin being made. Hopefully you will get soon a version able to handle embedded targets not running linux. We write our own rtos' kernels and complete applications from the scratch on our devices. Currently we use visual studio with nmake to generate our elf/binaries and gdb(arm/mips/x86/x64) to connect to the gdbstub on the target device, via serial port or remote(tcp). By selecting LocalGDB, I was able to make the connection with the target but there is no way to instruct gdb to inject the elf executable ( gdb load command ) so: It would be nice to see an option to load script commands to gdb so when gdb gets the elf binary with the command line, after the remote command, call load, or insert breakpoints before go.
Our gdb stubs in our targets are multitask capable, is this the MIEngine able to switch tast stacks?
Great Work!!!
@Dan_T, Stig Anderson, Dan Walmsley, Hector on chip debugger support is coming. I'll have early access bits for that very soon. Anyone interested in that shoot me a message at mgoodner at Microsoft.
@Wizard_2015 great feedback, thank you
@Victor_K we don't support that right now via gdb
@arrow201 I'm a bit behind on that, apologies. Soon!
@Jaro the Android tools are required to get the MIEngine we depend on to install.
Very nice.
A little bit of tweaking would go a long way though. I am trying to use this as a debugger frontend that connects to a build/debug machine that runs gdb (with target remote option enabled) which in turn connects through tcp to a deployed appliance that runs gdbserver attached to the final target process that I am trying to debug.
This is a fairly common scenario of debugging servers as it requires only gdbserver on the remote machine and stripped production code there, while all the symbols, unstrapped executable and the source code are on a build machine and visual studio debugger is replacing manual gdb from that machine.
The problem is that visual studio is trying to run set target-async on in gdb after gdb connected to the gdbserver which is already attached to the debugged process. That causes : Cannot change this setting while inferior is running, which is self explanatory. However I can pass to gdb the setting set target-async on manually, in the command line (optin -x or -ex) but still visual studio will try to send it again afterwards causing the debugger to conk out due to gdb error.
That would be useful if a the sending of the target-async could be manually controlled as that would enable gdbserver workflows.
Another minor niggle would be a way in the template UI/XAML to specify custom ssh ports as plink & co takes the ports as -P argument rather than ip_addr:port format. It is useful for reverse ssh tunnels when we try to create a tunnel from the remote machine to the visual studio that tunnels port xxxx to port 22(ssh) on that remote machine. Specifying port xxxx without a batch file to plink is impossible now, me thinks.
Awesome Plugin tested it and its working great.
Having issues with debug output window seems that CRLF is missing?
I'd like to push the usage of this to other engineers in our company, any reason this isn't a default feature of VS2015? It would be easier to just have this readily at hand rather than tell developers to install it via the extensions gallery.
One other thing to ask for would be to have an option to use a password vs. public key auth method, generating the key etc. is kind of a painful process would be easier to just punch in a password in that dialog and be done with it.
I finally got this to work! Great job!
But I also want to comment on the fact that you'll get a nasty error when quoting paths in the "Environment variables" under the Debugging tab, as jw also reported. It renders an error "Unable to start debugging. Launch string provided by the project system is invalid. 'D' is an unexpected token. Expected white space. Line 2, position 101." where 'D' is the first letter in the path with quotes in. You can pt quotes in the NMake Build Command Line, but it also resulted in problems. The solution I settled for was to put my Private SSH Key file in a place with no spaces in the path.
Maybe this issue would be something to look into? It will for sure cause problems for users.
This is a very nice tool. However, some comments:
– When I had both VS2015 and VS2013 on my box I ran into issues with the extension where I got HRESULT errors. Looking at the log output it seemed like it might have a been an issue between Windows SDK 8.0 and 8.1 having the same ID? I'm not really sure since I don't even use those SDKs. I finally gave up having them try to co-exist and uninstalled VS2013
– Ditto the comment above about needing a nice way to set the port. I'm using a local VM on a different port and I had to misuse the UI by putting the port command in with the private key 🙂
– A few comments from my coworker who is also using a local VM but did not have all the files on his windows host:
– He had issues when stepping from the process he was debugging into a shared library. He said it just stepped over that library call instead of prompting for the file to step into
– He also had the same issue when stepping into templated stl code
– He switched to VisualGDB since it has support for (automatically) copying the files from the Linux machine to his Windows box and hasn't had any issues (that's not something I need but it should probably be an option)
I have setup of Windows machine, linux host and target board all are connected to same network. With this setup, i want to do cross debugging(gdbserver running on target and gdb-multiarch running on linux host) from windows machine to linux host and target device which can be done by using visualgdb plugin.
But, is it possible to do the cross debugging using the visual studio gdb extensions?
Has anyone tried cross debugging with visual studio GDB extensions?
Hi
I am trying to run "gdbserver" on my Linux machine but add-in using "–interpreter=mi" parameter.
How can I remove this parameter ? My gdbserver does not accept it as an input parameter.
Nice but looks like the same old problems still exist though.
The reason for choosing a complicated VS remote debugging setup over “native” development would be the better IDE and debugging experience incl. natvis.
But still:
– no natvis diagnostics!!
can’t even get this to work (while my C++11 std::string works):
_M_h
– natvis does not work at all in debugger datatips (just [Visualized View] = Explicit refresh required for visualized expressions, and the refresh does not work)
– DisplayString is not displayed, only {…}, even on the [Visualized View] sub-node, which is especially bad for strings
– no C++11 STL types in the MDD natvis
– if something goes wrong the entire auto/locals view can freeze requiring a VS restart
It deleted the natvis xml snippet. Was an attempt at unordered_map.
Also just figured out
– format specifiers like ,s8 don’t work
– the Microsoft.Android.natvis seems not to be pulled in by default. So it should be added to the project template.
Just found the place to report bugs: https://github.com/Microsoft/MIEngine
Should be put into the article.
Hi Marc Goodner,
Thank you so much for your article, from your article I have learned how to debug a exec file, however, here I also have a question:
if I want to attach a process already running in remote Linux from local Windows, can I do it by your extension?
In other word, I need a window that list all the processes in remote Linux , I just double click any one of them, and then I can debug it, can I make it by you extension?
Thank you so much 🙂
Solid work!
I’ve been writing a Raspberry Pi GPIO application and this has been absolutely invaluable. I couldn’t have gotten my application written anywhere near as quickly or easily without this.
I made a couple of adaptations to getting it working for Raspberry Pi and I changed the settings to use a Makefile for building my app instead of compiling it through a command line single-source file solution, I also use a cross-compiler on my PC rather than compiling remotely – but the debugging features (as well as the nice ideas of deployment!) are brilliant.
Application output window in VS doesn’t work perfectly, carriage returns don’t seem to function correctly but that’s just a little niggle really.
This is excellent – I applaud your efforts! Thanks very much 🙂
Hey David,
Do you mind share how you make this to cross-compile on WIndows? I have a device which the manufacturer gives us the toolchain for windows so we can cross-compile to linux with it…
Also, there is a new extension just announced today on //Build https://visualstudiogallery.msdn.microsoft.com/725025cf-7067-45c2-8d01-1e0fd359ae6e which suppose to debug on linux but, I can only see it building on target machine however, in my case, the target machine doesn’t have build tools, it only has GDB for debug and we can’t install build tools there.
@MSFT guys who worked on this, gratz! really nice stuff!
Thanks all!
Great work!!
I’m trying to use PyOCD Debugger to debug an application over FRDM-K64F board.
What is the correct forum to ask questions and to get help?
Thanks
Just tried it , it does not really work , is there any serious attempt to make it work ? Did you consider usage in the context of big projects with existing makefiles and non-Microsoft alignment of the project (not under project directory )?
I managed to make it work! it is really good way to debug embedded apps.
You need to make your project as a GDB project, copy your “app.bin” or “compilation output” to the board.
in the project properties->Debug: choosr the OCD GDB Debugger.
in the project properties->Debug->debug binary: don’t put the “app.bin” put the not stripped output.
then start your pyOCD-gdbserver and add breakpoints. then start debugging.
it should work. it worked for me!
It doesn’t work for me. All I want is to connect to a gdbserver running on my computer. I don’t want to give an executable file. I have a server running. Just connect to it. Is there a way?
Finally I managed to make it work, mostly. Several bugs (and missing features) remain:
1. When I detach (Debug >> Detach all) the target continues running, but Visual Studio remains the debugging window arrangement and all the menus options under the Debug menu are grayed out.
2. If I close Visual Studio and reattach everything seems to work, until I detach. That screws up the target too. Now it’s stuck and there’s nothing I can do. When I close Visual Studio the target closes. (That is, detach didn’t really detach.)
3. There’s no real option to connect to a remote gdbserver and *NOT* run an executable. I managed to hack it out, but it’s very possible that’s why I got the aforementioned two bugs. I just want to connect.
4. There’s no way (unless I missed something) to directly interacts with GDB. But Sometimes I want to use the console (just like I do with WinDbg, for example).
5. No way to set access (hardware) breakpoints.
6. No way to get Intel syntax instead of AT&T.
Not that problems 5 and 6 would be solved automatically by resolving issue 4.
I’d appreciate a comment on these issues.
Thanks.
I managed to make it work! it is really good way to debug embedded apps.
You need to make your project as a GDB project, copy your “app.bin” or “compilation output” to the board.
in the project properties->Debug: choosr the OCD GDB Debugger.
in the project properties->Debug->debug binary: don’t put the “app.bin” put the not stripped output.
then start your pyOCD-gdbserver and add breakpoints. then start debugging.
it should work. it worked for me!
@Marc Goodner – MSFT
I’m an open source developer, which mostly work with Visual Studio to create binary add-ons (shared libraries) for all platforms that Kodi supports. I really like Visual Studio and I was very happy to read your post about the VS GDB Debugger extension. In my view it will push Visual Studio to the next level and make cross platform development less painful.
I’m using VirtualBox and Ubuntu for developing binary addons. Instead of manually copying the sources to the VM with “pscp.exe”, I stored them on a samba share and mapped a Windows network drive to this share. Consequently I can access the sources in my VM and in Windows without much effort. Furthermore I created a script on my VM that builds the binary addon Makefiles with CMake and starts the build. So far I can trigger a build and launch Kodi through Visual Studio. To get this working I added this “export DISPLAY=:0.0;gdb” to the option “Remote Debugger Executable”, which starts Kodi as a local process in my VM.
All is working except that the debugger doesn’t stop at breakpoints in my shared library.
The Visual Studio output window shows these error messages:
Stopped due to shared library event (no libraries added or removed)
Stopped due to shared library event:
Inferior loaded /home/user/sources/xbmc_Jarvis/addons/visualization.pictureit/visualization.pictureit.so
Loaded ‘/home/user/sources/xbmc_Jarvis/addons/visualization.pictureit/visualization.pictureit.so’
Stopped due to shared library event (no libraries added or removed)
Stopped due to shared library event:
How can I register my shared library at your extension. I guess this is the only missing step to get it working and start debugging my binary addons through Visual Studio.
I got it working. There was one little thing missing. CMake should generate your workspace with: -DCMAKE_BUILD_TYPE=Debug.
Hi
I’m really looking forward to giving this a go. I have currently used batch files with Cygwin and a makefile project to synchronise, build and run on a remote Linux platform, but having debugging abilities will be really useful. However, when I try to create GDB project with this extension I get the following error dialog
Microsoft visual Studio
X Object reference not set to an instance of an object.
and no new project is created. Any ideas what the problem might be? I’m using Visual Studio Community 2015 Version 14.0.23107.0 D14REL on Windows 10.
Actually, my post above was slightly wrong. It turns out the sln and vcxprj files are created, but not opened properly immediately after creation. If I try to load the .sln file it opens, but shows 0 projects. If I try to open the vcxprj file with VS2015, I get the same error as above. However if I double click it then it opens in VS2012 (I have 2008, 2010, 2012, 2013 and 2015 installed), but nothing really works. I see an assets filter in the solution explorer with .xaml files that I guess are supposed to define the property pages above, but the files don’t actually appear to exist.
I think Visual Studio is an amazing product. However my work is on a Ubuntu OS. I would love to have Visual Studio in linux as well. I think many people would be interested in this product and would be willing to pay for it.
Debugging Linux from Windows is not a good option for me. I want to debug Linux on Linux using Visual Studios IDE.
When will Microsoft release Visual Studio for Ubuntu?
I just found out that there such a thing for Ubuntu:
http://askubuntu.com/questions/616075/how-to-install-visual-studio-code-on-ubuntu
I intend to check it out. Thanks Microsoft!
Is is possible to do remote debugging without compilation, e.g. open only sources in VS and connect to gdb ?
Yes but this extension is no longer in development. You should look at the Linux extension for VS 2015 or the Linux workload that is part of setup in VS 2017.