Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging in VS Code don't work with generated pdb-files #228

Open
fiddej opened this issue Feb 23, 2021 · 1 comment
Open

Debugging in VS Code don't work with generated pdb-files #228

fiddej opened this issue Feb 23, 2021 · 1 comment

Comments

@fiddej
Copy link

fiddej commented Feb 23, 2021

I don't get debugging in VS code when I build with Bazel. Does anyone have succeeded with this? Here is what I've tried with my executable Foo. If you have something working, it would be very appreciated if you could share how this is done.

I've created a task.js-file and a launch.js-file. I build with the specified command. The flag --compilation_mode=dbg generates .pdb-files as expected. The preLaunchTask in VS Code builds it and the program is executed. I've tried to both launch the generated Foo.exe_0.exe and the dotent.exe with Foo.exe as an argument. It starts and runs well. But it does not stop at the breakpoints.

I have tried to play around with sourceFileMap, but with no success. Is it anything wrong with my set up or is it not (yet) possible? The workaround is to build with .csproj-files with Visual Studio, then it is working, but then there is no point with Bazel really. Anyone who have any hints how to make it work?

task.js-file:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "./../bazelw build ///Foo/... --config=msvc64 --config=remotecache_download --compilation_mode=dbg,
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},
{
"label": "clean",
"command": "./../bazelw clean --expunge",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},
{
"label": "run tests",
"command": "./../bazelw test ///Foo/... --config=msvc64 --config=remotecache_download --test_output=all",
"dependsOn": "build",
"type": "shell",
"group": "test",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
}
]
}

launch.js-file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attempt 1",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "PathOrRelativePathToParentRepo\bazel-bin\Foo\Foo.exe\Foo.exe_0.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
},
{
"name": "Attempt 2",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "PathOrRelativePathToParentRepo\bazel-bin\Foo\Foo.exe\dotnet.exe",
"args": [
"PathOrRelativePathToParentRepo\bazel-bin\Foo\Foo.exe\Foo.exe"
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceFileMap":
{
"C:\build\4hga4mmj\execroot\RepoName": "PathOrRelativePathToParentRepo"
}
},
{
"name": "Built with Visual Studio - works fine - stops at breakpoints",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "PathOrRelativePathToParentRepo\Foo\bin\Debug\netcoreapp3.1\Foo.exe",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}

@andwak
Copy link

andwak commented Apr 22, 2022

I also ran into a similar issue.
For me using the "--sandbox_debug" flag allowed me to debug as expected. Not sure if it will solve your use case.
See #281

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants