See [lix-project/lix#1156], but basically currently the `:st <n>` debugger command doesn't allow any negative indices, and putting a plus sign in front of the arg doesn't change anything; thus, we can exploit that "design space" to allow users to move between different stack frames easily, by simply prepending their arg with a +/- sign. The actual behavior is little more nuanced when you account for errors: as suggested by @pennae (thanks! :), when the user inputs an offset that would result in an invalid frame index, the debugger instead clamps it to the closest bound (i.e. 0 for negative offsets, $maxFrame for positive ones) and just prints a warning. Fixes #1156 [lix-project/lix#1156]: https://git.lix.systems/lix-project/lix/issues/1156 Change-Id: I02a0cdb6aaebbdb0515308880a3bf9c0d2fcd25e
65 lines
1.5 KiB
Plaintext
65 lines
1.5 KiB
Plaintext
@args --debugger
|
|
nix-repl> let f = _: throw "x_x"; x = f 5; in x
|
|
error: x_x
|
|
|
|
absolute indices still work:
|
|
nix-repl> :st 1
|
|
|
|
1: while calling a function
|
|
«string»:1:12
|
|
|
|
1| let f = _: throw "x_x"; x = f 5; in x
|
|
| ^
|
|
|
|
Env level 0
|
|
static: _
|
|
|
|
Env level 1
|
|
static: f x
|
|
|
|
Env level 2
|
|
static:
|
|
|
|
Env level 3
|
|
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
|
|
|
|
index with + goes up the stack relative to current (1 in this case):
|
|
nix-repl> :st +3
|
|
|
|
4: while evaluating a 'let' expression
|
|
«string»:1:1
|
|
|
|
1| let f = _: throw "x_x"; x = f 5; in x
|
|
| ^
|
|
|
|
Env level 0
|
|
static: f x
|
|
|
|
Env level 1
|
|
static:
|
|
|
|
Env level 2
|
|
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
|
|
|
|
index with - goes down and is also relative to current (4):
|
|
nix-repl> :st -1
|
|
|
|
3: while calling a function
|
|
«string»:1:29
|
|
|
|
1| let f = _: throw "x_x"; x = f 5; in x
|
|
| ^
|
|
|
|
Env level 0
|
|
static: f x
|
|
|
|
Env level 1
|
|
static:
|
|
|
|
Env level 2
|
|
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
|
|
|
|
quit
|
|
nix-repl> :quit
|
|
error: x_x
|