Debugging Zig (with a debugger)

I have been successful in running LLDB debugger from vscode on Linux, Mac and Windows with the following settings:

  • llvm-vs-code-extensions.lldb-dap visual code extension
  • lldp-dap executable must be in your path. Check that exists using lldb-dap --version. To install it on Windows run winget install LLVM.LLVM, on Mac brew install llvm, on Linux use your distribution package manager to install llvm/lldb.
  • Create an entry for the “LLDB DAP Debugger” in launch.json like:
    {
      "version": "0.2.0",
      "configurations": [
          {
              "type": "lldb-dap",
              "request": "launch",
              "name": "Debug",
              "program": "${workspaceFolder}/zig-out/bin/<your program>",
              "args": [],
              "env": [],
              "cwd": "${workspaceFolder}"
          }
      ]
    }
    
  • In the vscode settings for the zig extension set "zig.debugAdapter": "lldb-dap". This allows to debug main and tests using the arrows in your code.
3 Likes

working on windows

When i have the courage i will maybe try sometime again :slight_smile:
That’s the only thing I really miss since my delphi and C# days: just working out of the box.

1 Like

Delphi especially. Came in an actual box too. :smiley:

If I had to write a Windows GUI program right now, odds are high that’s still how I’d do it.

all my working clion and vscode settings - for linux

Off topic :slight_smile:
Yes. I looked at C# for GUI’s but the amount of possiblities to choose from is dazzling and paralyzes me.

1 Like