C
C#7mo ago
PixxelKick

nvim-dap + netcoredbg: Unit Test Breakpoints not getting hit (sometimes)

Im currently using nvim-dap running netcoredbg, in order to debug net core apps. Here's the weird thing, I have the exact same identical nvim configuration (version controlled from github) on two devices. The first is my work laptop, running Ubuntu on WSL. The second is my personal machine, running normal Debian. The WSL Ubuntu machine does hit breakpoints inside of unit tests when I dotnet test with VSTEST_RUNNER_DEBUG=1 and I use "Attach to Process" The Debian machine, however, does not. Both are running the same SDK (8.0203), latest netcoredbg (3.1.0-1), and same nvim config. However I have set a bunch of different env vars over time on both machines, and I know there are random sporadic ones that matter for dotnet, so its distinctly possible I have one floating around messing with the debian machine, or, I have a "magic sauce" env var set on the WSL machine that is making stuff work. I have tried this with both nunit and xunit, neither have worked. The extra weird part is even though the breakpoints dont get hit on the Debian machine, it still does attach successfully. Dotnet waits and only proceeds with the tests after I attach, and the debugger disconnects and goes back to normal edit mode when the tests finish running. So dotnet test is detecting it got attached to... It's just specifically not wiring into the breakpoints? Breakpoints do get hit if I run normal "run the process with netcoredbg" via just running a plain ole net core app. However this doesnt of course work with unit tests since its a totally different command and would require a bunch of bespoke configuration if I wanna do stuff like pass in --filter or --logger or etc to dotnet test so Im not super interested in going down that alley... Especially since I know it clearly can work on one machine, I just cant figure out what secret sauce I am missing >_>;
4 Replies
PixxelKick
PixxelKick7mo ago
also just tested and breakpoints also get hit if I attach the debugger by process id to a "normal" application as well:
No description
PixxelKick
PixxelKick7mo ago
Another small interesting tidbit Ive noticed: When I run dotnet test with debug attach mode, it actually lists the process id twice, Ill have to go grab my work laptop to confirm the exact wording, but it prints out a process id before the "Waiting for Debugger to attach" line, then a second time after that. Whereas on my debian machine it only prints out the process id once, after the "Waiting for debugger to attach" line, so theres a small discrepency Nevermind Im dumb, I was using VSTEST_RUNNER_DEBUG=1 instead of VSTEST_HOST_DEBUG=1, the latter makes it start working, derp derp derp I have literally zero idea what the former does though, if anyone with info on wtf the difference is on the two, Id love to know the nuance of why the former still shows a proc id and can attach but cant hit breakpoints, but the latter can hit breakpoints and also why the latter shows the proc id twice... >_>;
mrphil2105
mrphil21057mo ago
Can I have a look at how you set up unit test debugging? I am using Neovim too
PixxelKick
PixxelKick7mo ago
Sure! Config: https://github.com/SteffenBlake/pixxel-nvim/blob/main/lua/dap-config/init.lua And my handy tool to auto detect project root to find .vs/launchSettings.json : https://github.com/SteffenBlake/pixxel-nvim/blob/main/lua/dap-config/proj-loader.lua This config let's me define 2 debugger options when I invoke build and run: "launch and debug" and "attach debugger" which will show a process Id picker with telescope Example launchSettings.json in a project here: https://github.com/SteffenBlake/Nomadik/blob/main/src/.vscode/launch.json In practice my steps are: Step 1 (once): export VSTEST_HOST_DEBUG=1 To enable attach mode Step 2: dotnet test --filter Name_Of_Test Step 3: it'll spit out the proc id and wait for attach, copy it Step 4: <leader>dr in Nvim for [D]ebugger > [R]un Step 5: telescope picker for "launch" or "attach to process", pick latter Step 6: telescope picker for proc ids, paste that id and hit enter Step 7: breakpoint gets hit shortly after So in nvim its pretty much: <leader>dr<down><enter><SC-v><enter
Want results from more Discord servers?
Add your server