microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.46k stars 1.53k forks source link

Remote debugging to a RaspberryPi #1450

Closed MBJBOGO closed 6 years ago

MBJBOGO commented 6 years ago

Hi,

I believe it should be possible to remote-debug on an IOT device (in this case a RaspberryPi) from VScode (on windows 7). But for some reason I can’t get this to work, and I can read in different posts that people have a lot of issues with remote debugging. What I can’t figure out is if this is supposed to work directly via a pipeTransport to the RasspberryPi or if I have to install a gdb client locally on my windows PC including a complete WSL package? My setup is as following:

Some general questions: 1) Can I get this to work without any other components? 2) Will it only work in Win10 with the Creators Update (Build 15063) as explained in some docs? 3) If I’m stuck to Win7 do I have other alternatives (Cygwin, VMware) remotely? 4) If I install VScode in Ubunto via VMware would it then work from the virtual machine in Ubunto? 5) Any other ways to remote debug an IOT device from VScode?

BR Morten

pieandcakes commented 6 years ago

@MBJBOGO You can do this using pipeTransport and an ssh client on windows to speak with gdb on the raspberry pi.

•I use Git\Bash as the pibeProgram

Is this a windows based program? are you connecting without using a password? if the ssh pipe needs additional interaction to setup, then it won't work.

2.Will it only work in Win10 with the Creators Update (Build 15063) as explained in some docs?

This requirement is for if you want to use WSL as your Linux layer

3.If I’m stuck to Win7 do I have other alternatives (Cygwin, VMware) remotely?

I've used PuTTY's plink.exe with success after setting up the ssh keys. This is how I test from Windows to Raspberry Pi.

If you share your launch.json I might be able to give you some pointers.

MBJBOGO commented 6 years ago

Hi Pierson Lee

Thanks a lot for your help here – I’m almost up and running now. I did use the Git\bin\bash.exe for the ssh pibe and Yes I was probably facing a password issue here. Now I’m using the Plink command-line utility and I’m able to connect to the RaspberyPi target. The only issue I have left is that it don’t display the source files. My launch file looks like this:

"name": "(gdb) pipe remotePi2 Launch", "type": "cppdbg", "request": "launch", "program": "/home/pi/Code/Console/bin/ARM/Debug/Console.out", "args": [], "stopAtEntry": true, "cwd": "/home/pi/Code/Console", "environment": [], "externalConsole": true, "pipeTransport": { "debuggerPath": "/usr/bin/gdb", "pipeProgram": "C:\Program Files\PuTTY\plink.exe", "pipeArgs": [ "-pw", "mbjmbj", "-v", "pi@192.168.1.2" ],
"pipeCwd": "" }, "sourceFileMap": { "/home/pi/Code/Console": "C:\Compile\raspberryPi\Code\Console" }

The error message I get (without the sourceFileMap tag) Unable to open 'main.cpp': File not found (file:///home/pi/Code/Console/main.cpp). The error message I get (with the sourceFileMap tag) Debug adapter process has terminated unexpectedly

The first error message states the path to the target/remote source location (and that’s ok) but I guess it should look for the file on the local machine instead (to display it in VScode)? Then I tried the sourceFileMap option but then I get the last error. I’m not sure how I address it to the right location? I’m also not sure about how to use the cwd tag and the pipeCwd tag? Any suggestions….. thanks again

BR Morten

pieandcakes commented 6 years ago

@MBJBOGO I don't know if you specify them, but your sourceFileMap should have the second path escaped? c:\compile\raspberryPi\code\console should look like c:\\compile\\raspberrypi\\code\\console in your launch.json file.

Otherwise, if you enable "logging": { "engineLogging": true, "trace": true, "traceResponse": true } you might get more detail as to why it isn't working.

MBJBOGO commented 6 years ago

Thanks a lot for your help here - it is now working as expected :-)

jSquaredSolutions commented 5 years ago

I am having the same issue trying to get remote debugging to work. I have a very simple nodeJS file on my remote Raspberry Pi 3. Here is my launch.json { "type": "node", "request": "attach", "name": "attach to remote", "address": "192.168.1.104", "port": 9229 }

image

@MBJBOGO could you give a quick summary on how you fixed this?

jSquaredSolutions commented 5 years ago

Ok I figured it out in a little bit of a different way. I used this commend in my SSH Terminal: node --inspect-brk=your-ip-here:9229 yourNodefile.js

Works great, but after the debug has finished the listener on port 9229 automatically quits which means I need to go back into the SSH console and again run: node --inspect-brk=your-ip-here:9229 yourNodefile.js

pieandcakes commented 5 years ago

@jSquaredSolutions This is the issues page for the VS Code C++ extension.

N3jk0v commented 4 years ago

I am having a similar issue where breakpoints dont work. I tried configuring my jason file, but to not avail. (I followed the following guide: https://www.linkedin.com/pulse/python-remote-debugging-visual-studio-code-raspberry-pi-mircea-dogaru/) launch.json file { "version": "0.2.0", "configurations": [ { "name": "Python: Deploy And Run On Remote", "type": "python", "request": "attach", "port": 5678, "host": "${config:sshEndpoint}", "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "~/Documents/remote" } ], "preLaunchTask": "copyAndStartOnPi", "postDebugTask": "cleanupOnPi" } ] }