Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code debug C++ Node Addon

I try to setup debugging in visual studio code for a C++ Node-Addon compiled with GYP. I want to step through the source-code if possible. I use typescript as my server language and include the ".node" file compiled by gyp. This works fine but how do I set it up so I can step not only through the typescript code but also through the C++ code?

VSCode breakpoints for .cc file:

I know I can compile a debug-version with gyp node-gyp rebuild --debug, but I have no plan how to use that in vscode.

like image 534
Silvan Hau Avatar asked Nov 21 '16 12:11

Silvan Hau


People also ask

Can you debug C in Visual Studio?

To debug a C or C++ Win32 applicationOpen the project in Visual Studio. On the Debug menu, choose Start. Debug using the techniques discussed in First look at the debugger.


1 Answers

If you use Windows, this VSCode launch.json may help you:

{
  "version": "0.2.0",
  "configurations": [{
      "type": "cppvsdbg",
      "request": "launch",
      "name": "Addon Debug",
      "program": "node",
      "args": ["C:\\repos\\HighloadCup\\db.js"]
  }]
}

Make sure you build Node.js addon with correct architecture and other options.

like image 161
Inflight Avatar answered Nov 15 '22 09:11

Inflight