Reputation: 6497
I have a Unity project that uses some C++ code via a DLL compiled in a separate project. Can I attach the visual studio code debugger to my Unity project such that I can debug the DLL's source code using break points?
Here are some things I tried so far:
launch.json
like this{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to process",
"type":"clr",
"request": "attach",
"processId": "${command:pickProcess}"
}]
}
--> this should allow me to pick the process I want to connect to interactively
my/path/to/Unity.exe
--> attaching seems to work, but when I "unpause" my Unity game it never hits a break point.Is my launch.json wrong?
Some additional info:
sourceMap
which directs the debugger to the root of my source files. Not sure if anything similar would be needed here as well?Moving forward
Meanwhile I've refactored my launch.json a bit. Thanks to a comment I assume "type" : "clr"
stand for Common Language Runtime which seems to be for debugging scripting languages but not C/C++. So I changed it to "type":"cppdbg"
. After installing gdb via Msys2, I'm referencing the path to that gdb in the launch.json. This is an updated version of my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to process",
"type":"cppdbg",
"request": "attach",
"processId": "${command:pickProcess}",
"program": "${workspaceRoot}/Packages/com.github.homuler.mediapipe/Runtime/Plugins/mediapipe_c.dll",
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
}]
}
Spoiler: It's still not working, but inside VS Code debug console / terminal I see some output when I start the game in Unity editor. So there seems to be some traffic between VS Code and Unity at least.
One new problem:
Upvotes: 1
Views: 1693
Reputation: 1
The C++ DLL library Project in VS be compiled debug first, also need add the /Zi parameter.
Follow steps:
Upvotes: 0
Reputation: 6497
While I couldn't figure out a solution for VS Code, I found a solution for
the solution goes roughly like this
--> the game should now break when hitting the breakpoint
Upvotes: 2