# Zig Debugging with LLDB

**URL:** <https://ziggit.dev/t/zig-debugging-with-lldb/3931>\
**Category:** Explain\
**Created:** [April 12, 2024, 6:22pm UTC](https://ziggit.dev/t/zig-debugging-with-lldb/3931 "2024-04-12T18:22:56Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [October 30, 2024, 7:19pm UTC](https://ziggit.dev/t/zig-debugging-with-lldb/3931/7 "2024-10-30T19:19:15Z")

</div>

Yes, there are ways to debug tests.

`zig build test` actually produces an executable and then runs the executable.

Calling [`addTest`](https://ziglang.org/documentation/master/std/#std.Build.addTest), without calling [`addRunArtifact`](https://ziglang.org/documentation/master/std/#std.Build.addRunArtifact) the test executable is produced but it is not run.

You can run `lldb` using the [`addSystemCommand`](https://ziglang.org/documentation/master/std/#std.Build.addSystemCommand):

```zig
    const unit_tests = b.addTest({
        // TODO add here the test options
    });

    const lldb = b.addSystemCommand(&.{
        "lldb",
        // add lldb flags before --
        "--",
    });
    // appends the unit_tests executable path to the lldb command line
    lldb.addArtifactArg(unit_tests);
    // lldb.addArg can add arguments after the executable path

    const lldb_step = b.step("debug", "run the tests under lldb");
    lldb_step.dependOn(&lldb.step);

```

---

_[View the full topic](https://ziggit.dev/t/zig-debugging-with-lldb/3931)._
