libcmd/repl: print backtraces from outer to innermost frame
before this change, the innermost frame was all the way at the top, which means that in very nested code you'd have to scroll though dozens or hundreds of frames before even seeing where you are, because the last lines (which are immediately visible when the command returns) would be the nix code's entry point and other outer frames instead, which is rarely relevant. this CL reverses this order, so that the innermost frames are the last ones printed, and thus are immediately visible. (note that this is already how errors are printed by nix in other contexts anyway, the debugger's :bt is the only thing that prints the trace in "forward" order.) because `DebugState.traces()` use the homegrown `libutil::Generator` instead of an stdlib container, we have to do that reversing ourselves, in this case by just storing every element in an `std::list` (in reverse order) and then traversing it. this is feels kinda dirty, but i don't know any other way, and it's not exactly performance-critical. Change-Id: I9f23e40e57f72a251d65a335b3bba3c3f77b935d
This commit is contained in:
@@ -48,13 +48,14 @@
|
||||
|
||||
we can now inspect state
|
||||
nix-repl> :bt
|
||||
0: error: undefined variable 'a'
|
||||
|
||||
1: error: Fake frame for debugging purposes
|
||||
«string»:1:10
|
||||
|
||||
1| with {}; a
|
||||
| ^
|
||||
|
||||
1: error: Fake frame for debugging purposes
|
||||
0: error: undefined variable 'a'
|
||||
«string»:1:10
|
||||
|
||||
1| with {}; a
|
||||
@@ -92,13 +93,13 @@ leaving the debugger from a toplevel error and entering it again doesn't leave o
|
||||
|
||||
nix-repl> :bt
|
||||
|
||||
0: error: undefined variable 'b'
|
||||
1: error: Fake frame for debugging purposes
|
||||
«string»:1:10
|
||||
|
||||
1| with {}; b
|
||||
| ^
|
||||
|
||||
1: error: Fake frame for debugging purposes
|
||||
0: error: undefined variable 'b'
|
||||
«string»:1:10
|
||||
|
||||
1| with {}; b
|
||||
|
||||
Reference in New Issue
Block a user