debugger: allow :st argument to be relative to current frame index #1156

Closed
opened 2026-03-16 17:53:52 +00:00 by blokyk · 1 comment

Because of nix's functional nature, debugging often involves swapping between a bunch of stack frames to trace the execution up to this point. In my experience, this involves a cycle of doing :st <n> -> :env -> :p <var> -> ... -> :st <n+1>. Debugging is an activity where you already have to keep a lot of mental context constantly, and even though it might seem tiny, remember the n and incrementing it every time is a little additional mental load that quickly gets annoying and distracting.

A way to go up/down a certain number of stack frames relative to the current frame would be a tiny addition that could really smooth over that friction.

Describe the solution you'd like

Since right now stack frame indices are absolute and always positive, they never require a + or - sign in front of them. We could take advantage of that by making :st +<n> and :st -<n> indicate that n is relative to the current frame index, while :st <n> is an absolute index. This avoids breaking any current workflow, since I can't imagine anyone would type the + sign despite not being needed.

Naturally, :st +<n> would increase the frame index (i.e. go up the stack), while :st -<n> would decrease it (i.e. going down the stack).

Describe alternatives you've considered

A different command, such as :str (stack trace relative), could be introduced, but imo that would just complicate the experience and mental model just to duplicate an existing command.

Additional context

Since that change requires barely a few lines, I've already implemented it just to try to get more familiar with hacking on lix. If this is a wanted change (and the proposed design is ok), I'd be happy to submit a CL for it (though this'd be my first time using gerrit)

## Is your feature request related to a problem? Please describe. Because of nix's functional nature, debugging often involves swapping between a bunch of stack frames to trace the execution up to this point. In my experience, this involves a cycle of doing `:st <n>` -> `:env` -> `:p <var>` -> ... -> `:st <n+1>`. Debugging is an activity where you already have to keep a lot of mental context constantly, and even though it might seem tiny, remember the `n` and incrementing it every time is a little additional mental load that quickly gets annoying and distracting. A way to go up/down a certain number of stack frames _relative_ to the current frame would be a tiny addition that could really smooth over that friction. ## Describe the solution you'd like Since right now stack frame indices are absolute and always positive, they never require a + or - sign in front of them. We could take advantage of that by making `:st +<n>` and `:st -<n>` indicate that `n` is relative to the current frame index, while `:st <n>` is an absolute index. This avoids breaking any current workflow, since I can't imagine anyone would type the + sign despite not being needed. Naturally, `:st +<n>` would increase the frame index (i.e. go up the stack), while `:st -<n>` would decrease it (i.e. going down the stack). ## Describe alternatives you've considered A different command, such as `:str` (stack trace relative), could be introduced, but imo that would just complicate the experience and mental model just to duplicate an existing command. ## Additional context Since that change requires barely a few lines, I've already implemented it just to try to get more familiar with hacking on lix. If this is a wanted change (and the proposed design is ok), I'd be happy to submit a CL for it (though this'd be my first time using gerrit)
blokyk changed title from debugger: allow :st argument to be relative to debugger: allow :st argument to be relative to current frame index 2026-03-16 19:07:09 +00:00
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/5411 ("libcmd/repl: allow :st argument to be relative to current stack index")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/5411", "number": 5411, "kind": "commit message"}], "cl_meta": {"5411": {"change_title": "libcmd/repl: allow :st argument to be relative to current stack index"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/5411](https://gerrit.lix.systems/c/lix/+/5411) ("libcmd/repl: allow :st argument to be relative to current stack index")
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1156
No description provided.