VS Code debug C ++ Node Addon

I am trying to configure debugging in visual studio code for C ++ Node -Addon compiled with GYP. I want, if possible, to execute the source code. I use typescript as my server language and include the ".node" file compiled by gyp. This works great, but how do I configure it so that I can step not only using typescript code, but also using C ++ code?

VSCode breakpoints for .cc file:

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

+6
source share
2 answers

You can add breakpoints in VS to your code, and then after executing the require statement in js. Use the VS attach function to join the node's running process (you will get a list of possible processes when you click attach). Your breakpoint will now stop code execution in VS in c or c ++.

0
source

If you are using Windows, this VSCode launch.json can 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 create the Node.js addon with the correct architecture and other options.

0
source

Source: https://habr.com/ru/post/1260076/


All Articles