Learning zig with ziglings. cant figure out debug with vscode

zig is my only compiler type lang.
I can put together a basic script to do most of what I want.
I have zig installed and working on win10
zls is working in vscode.
build works for building the exe for the ziglings.
zig run whatever.zig works as well.
gdb is in my path
i get output in the terminal (vs code) from cpptools extension

  & 'c:\Users\fred\.vscode\extensions\ms-vscode.cpptools-1.18.5-win32-x64\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-zmypi4ow.3lx' '--stdout=Microsoft-MIEngine-Out-kep4yukr.agb' '--stderr=Microsoft-MIEngine-Error-lujxozlx.itz' '--pid=Microsoft-MIEngine-Pid-wmifhz3n.x5s' 
'--dbgExe=C:\morePrograms\w64devkit\bin\gdb.exe' '--interpreter=mi'

setting break points does not seem to do anything.

Im ignorant as F about a lot of this and i am kind of bashing my way through it, i have hit a mental wall with this. I can just ignore it and use the old method of print statements but I would love to at least try to do better.

I have probably left out useful information, i will provide it, just tell me what it is.
win10_64
vs code
zig .11 stable
zls
gdb latest from w64devkit
tried several launch and task configs for vs code like I said i get compile and output.

any help appreciated.

2 Likes

I am neither on windows nor using vscode, but I had it installed and gave it a try.
I have tested debugging using: CodeLLDB as an extension.
Open the project, switch to the “RUN AND DEBUG” sidebar and followed the prompt to create a lldb launch target.
Executing the code, breakpoints and variable output seems to all be working.
launch.json looks like this:

{
	"version": "0.2.0",
	"configurations": [
		{
			"type": "lldb",
			"request": "launch",
			"name": "Debug",
			"program": "${workspaceFolder}/zig-out/bin/{name-of-your-exe}",
			"args": [],
			"cwd": "${workspaceFolder}"
		}
	]
}

Everything is default other than the path to the exe.
I should mention I also use CodeLLDB as debug adapter from neovim and I am able to debug there as well.

5 Likes
{
            "label": "build_debug",
            "type": "shell",
            "command": "cls ; zig build-exe -O Debug  ${workspaceFolder}\\myTests.zig",
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": false
            }
        }
-----------------------------------------------------------
{
			"name": "(lldb) Debug",
			"type": "lldb",
			"request": "launch",
			"program": "${workspaceFolder}/myTests.exe",
			"args": [],
			"cwd": "${workspaceFolder}"
		}

I took some time to try a few things, but im still being dense about this.

I took he reply and adjusted it and i get the output from the zigling I was working on.
I pressed the debug button with the task name.
I use the command [ zig build-exe -O Debug ${workspaceFolder}\myTests.zig" ] to build the file for debug.
I am not sure but since it worked I assume it is close enough.

the program runs and exits with no pause, breakpoints are set.
I know I am missing something simple bear with my slowness please.
pretty sure I am missing something with vs code, maybe, maybe not.

did i build the debug correctly?
I think i should get a pause on set break points, but the file just finishes.

swapped cppvsdbg for lldb
and i can now step through the program.
i had been trying to use gdb with another set of settings but I took another look at some pages i had saved and saw the above change mentioned.
I think im good now. marking solved. sorry to be dense, the config of vscode is just another set of confusions on top of learning this.
thanks for the help.

2 Likes