Skip to content

Highlight files in stack frames#60336

Open
jakobjpeters wants to merge 6 commits intoJuliaLang:masterfrom
jakobjpeters:highlight-files-in-stack-frames
Open

Highlight files in stack frames#60336
jakobjpeters wants to merge 6 commits intoJuliaLang:masterfrom
jakobjpeters:highlight-files-in-stack-frames

Conversation

@jakobjpeters
Copy link
Contributor

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.

Screenshot from 2025-12-05 23-43-59

@DilumAluthge
Copy link
Member

@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.

@jakobjpeters
Copy link
Contributor Author

Yes, I'm still interested. I have time next weekend and will rebase and fix the test that I neglected to update.

@jakobjpeters jakobjpeters force-pushed the highlight-files-in-stack-frames branch from 92c05cb to 70df07b Compare February 16, 2026 05:32
# 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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jakobjpeters
Copy link
Contributor Author

jakobjpeters commented Feb 17, 2026

@DilumAluthge I added a few missing cases, fixed the broken test, and added more tests. Ready for review!

Screenshot from 2026-02-16 22-16-42

@DilumAluthge
Copy link
Member

@tecosaur Would you be able to review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants