# How to print a slice as a string in lldb?

**URL:** <https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853>\
**Category:** Help\
**Tags:** debugger\
**Created:** [October 5, 2026, 3:29pm UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853 "2026-10-05T15:29:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nilsj](https://ziggit.dev/user_avatar/ziggit.dev/nilsj/32/9379_2.png) [@nilsj](https://ziggit.dev/u/nilsj)\
**Post date:** [October 5, 2026, 3:29pm UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853/1 "2026-10-05T15:29:59Z")

</div>

I want to be able to read it, currently i get:

```zig
(lldb) print path
([]const u8) len=7 {
  [0] = 116
  [1] = 101
  [2] = 115
  [3] = 116
  [4] = 46
  [5] = 109
  [6] = 100
}

```

I’m using Jacobs fork.

---

<div class="post-metadata">

**Author:** ![gonzo](https://ziggit.dev/user_avatar/ziggit.dev/gonzo/32/54_2.png) [@gonzo](https://ziggit.dev/u/gonzo)\
**Post date:** [October 5, 2026, 10:27pm UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853/2 "2026-10-05T22:27:23Z")

</div>

Did you try `print path.ptr`?

---

<div class="post-metadata">

**Author:** ![nilsj](https://ziggit.dev/user_avatar/ziggit.dev/nilsj/32/9379_2.png) [@nilsj](https://ziggit.dev/u/nilsj)\
**Post date:** [October 6, 2026, 8:04am UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853/3 "2026-10-06T08:04:48Z")

</div>

Yeah,

```zig
(lldb) p path.ptr
([*]const u8) 0x000000000130526d
(lldb) p path.ptr.*
(u8) 102

```

---

<div class="post-metadata">

**Author:** ![gonzo](https://ziggit.dev/user_avatar/ziggit.dev/gonzo/32/54_2.png) [@gonzo](https://ziggit.dev/u/gonzo)\
**Post date:** [October 6, 2026, 9:25am UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853/4 "2026-10-06T09:25:44Z")

</div>

So I guess this would work: `p *(char(*)[path.len])path.ptr`. If it does, you could save that as a shorthand command – not sure what the correct incantation for that is in LLDB.

---

<div class="post-metadata">

**Author:** ![nilsj](https://ziggit.dev/user_avatar/ziggit.dev/nilsj/32/9379_2.png) [@nilsj](https://ziggit.dev/u/nilsj)\
**Post date:** [October 6, 2026, 9:56am UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853/5 "2026-10-06T09:56:56Z")

</div>

This doesn’t work either it’s somehitng to do with the fact that it’s a fork.

---

<div class="post-metadata">

**Author:** ![nilsj](https://ziggit.dev/user_avatar/ziggit.dev/nilsj/32/9379_2.png) [@nilsj](https://ziggit.dev/u/nilsj)\
**Post date:** [October 10, 2026, 8:25pm UTC](https://ziggit.dev/t/how-to-print-a-slice-as-a-string-in-lldb/17853/6 "2026-10-10T20:25:46Z")

</div>

```zig
v/s -D0 path

```

short for

```zig
frame variable -D 0 -f s path

```

[#compiler \> lldb-zig @ 💬](https://zsf.zulipchat.com/#narrow/channel/454360-compiler/topic/lldb-zig/near/618648770)[#compiler \> lldb-zig @ 💬](https://zsf.zulipchat.com/#narrow/channel/454360-compiler/topic/lldb-zig/near/618648770)
