Highlight files in stack frames#60336
Conversation
|
@jakobjpeters Are you still interested in this PR? If so, can you rebase on the latest Julia master, and fix the merge conflicts. Let me know after you've done that, and I'll re-ping Jameson for a review. If you're no longer interested, let me know and I'll close this PR. |
|
Yes, I'm still interested. I have time next weekend and will rebase and fix the test that I neglected to update. |
92c05cb to
70df07b
Compare
| # Print a stack frame where the module color is set manually with `modulecolor`. | ||
| function print_stackframe(io, i, frame::StackFrame, ndigits_max::Int, max_nested_cycles::Int, nactive_cycles::Int, ncycle_starts::Int, modulecolor; prefix = nothing) | ||
| # Print a stack frame where the module and file color is set manually with `modulecolor` and `filecolor`. | ||
| function print_stackframe(io, i, frame::StackFrame, ndigits_max::Int, max_nested_cycles::Int, nactive_cycles::Int, ncycle_starts::Int, modulecolor::Symbol, filecolor::Symbol; prefix = nothing) |
There was a problem hiding this comment.
Types are added here to prevent overwriting the previous print_stackframe method, which was previously distinct by parameter count.
| else | ||
| :default | ||
| modulecolor = :default | ||
| filecolor = get_filecolor(string(frame.file), Main; modulecolordict, modulecolorcycler) |
There was a problem hiding this comment.
This line handles the case of stackframe 2 in each of these examples, which has no module:
> julia --eval "error()"
ERROR:
Stacktrace:
[1] error()
@ Base ./error.jl:45
[2] top-level scope
@ none:1
[3] eval(m::Module, e::Any)
@ Core ./boot.jl:489
[4] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:283
[5] _start()
@ Base ./client.jl:550
julia> error()
ERROR:
Stacktrace:
[1] error()
@ Base ./error.jl:56
[2] top-level scope
@ REPL[10]:1
|
@DilumAluthge I added a few missing cases, fixed the broken test, and added more tests. Ready for review!
|
|
@tecosaur Would you be able to review this? |

Often, the important stack frames come from local files or the REPL. This highlights those files so that they are easier to identify visually. This should make it easier to debug errors by drawing the developer's eyes to stack frames from code that they "own".
The implementation is careful to match the file color with the cyclic module color. I'm not yet sure how to implement this for the top-level scope REPL case.