LLDB says "TypeSystem for language zig doesn't exist" in Alpine container

I want to use frame variable to inspect variables in Zig but it doesn’t show any output.

When I run a Zig program, LLDB says:

warning: This version of LLDB has no plugin for the language "zig". Inspection of frame variables will be limited.

I’m running Zig in a Podman container based on Alpine Edge, with the Alpine-provided Zig 0.15.2 with these options:

podman run -it --rm --security-opt seccomp=unconfined --cap-add=SYS_PTRACE -v $(pwd):/usr/src/myproject mycontainer /bin/sh

Inside the container I try to set a breakpoint like this, but I get a warning about “TypeSystem for language zig doesn’t exist”:

# zig build && lldb zig-out/bin/myproject
(lldb) target create "zig-out/bin/myproject"
Current executable set to '/usr/src/myproject/zig-out/bin/myproject' (x86_64).
(lldb) breakpoint set -f main.zig -l 4
Breakpoint 1: where = myproject`main.main + 8, address = 0x000000000113d2a8
(lldb) run
warning: This version of LLDB has no plugin for the language "zig". Inspection of frame variables will be limited.
Process 127 launched: '/usr/src/myproject/zig-out/bin/myproject' (x86_64)
Process 127 stopped
* thread #1, name = 'myproject', stop reason = breakpoint 1.1
    frame #0: 0x000000000113d2a8 myproject`main.main at main.zig:4:5
   1    const std = @import("std");
   2   
   3    pub fn main() !void {
-> 4        var n:u32 = 5;
   5        n += 10;
   6        std.debug.print("All {} of your {s} are belong to us.\n", .{n, "codebase"});
   7    }
(lldb) frame variable
(lldb) p n
error: Could not find type system for language zig: TypeSystem for language zig doesn't exist

Note, the frame variable command shows empty output, the p command shows an error.

I already found lldb_pretty_printers.py in the Zig source tree and I am attempting to use it in my Dockerfile like this:

FROM alpine:edge

RUN apk update
RUN apk add file lldb py3-lldb zig
RUN mkdir /opt/zig-tools && \
    wget https://codeberg.org/ziglang/zig/raw/tag/0.15.2/tools/lldb_pretty_printers.py \
    -O /opt/zig-tools/lldb_pretty_printers.py && \
    echo -e 'command script import /opt/zig-tools/lldb_pretty_printers.py\ntype category enable zig.lang\ntype category enable zig.std\n' > /root/.lldbinit

WORKDIR /usr/src/myproject

CMD ["/bin/sh"]

How do I tell lldb about Zig’s type system?

you should add “use_llvm = true” in your module config of build.zig

3 Likes

Thanks, that worked!