-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include ClearStacktrace.jl in Base #36134
include ClearStacktrace.jl in Base #36134
Conversation
Thanks! This is also going to need the code for handling keyword arguments in |
I have followed your other suggestions, but I'm not quite sure what you mean by this. How should keyword arguments be handled? They do not appear in the specialization types because methods are not specialized for them, should we still print their names and the types of the passed arguments?
Should I replace the show method with what I have? In what contexts is that other function used, I'm not sure what use cases I have to think about when merging. |
There is a bunch of code in the StackFrame module that is only relevant for the previous stacktrace printing, for example: Lines 219 to 222 in 855a08b
So either that should be removed or the code here should replace it. |
Can submodules be so different that it would make sense to distinguish them? Otherwise that's a good idea. I don't know by what logic they are usually used, I don't really use submodules. Another thing is that I had a heuristic before to find a module for inlined functions by copying that of another non-inlined function from the same file. But I guess that could also produce the wrong result. Is there a failsafe way to do this? |
In many cases it is just an implementation detail of the package so I think it makes sense to keep them the same color. |
The current printing is:
The magic is done starting at Line 228 in 095e92d
|
I have added keyword printing as well, but I couldn't just copy paste the code from |
base/errorshow.jl
Outdated
line = getline(frame) | ||
|
||
# add file and line info for accessing frame locations from the repl | ||
push!(LAST_SHOWN_LINE_INFOS, (file, line)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just mentioning it here: Once #35556 is merged the global LAST_SHOWN_LINE_INFOS
should be replaced by get(io, :LAST_SHOWN_LINE_INFOS, Tuple{String, Int}[])
.
Do we really want opposite directions here ( |
Well the reason is that by default the user directory is part of the file path, so it has to be explicitly contracted. And the base files are just file names, so their file paths have to be explicitly expanded :) Those are the different behaviors compared to the current state |
I guess if we said that the new default is to print base file paths completely, then the option could be named contract base paths to get the old behavior. It's a bit annoying that those paths tend to be super long but I personally love being able to click them in VSCode. The options are meant so everybody can decide how terse or verbose they want their traces. To me for example, even though a short stack trace can be nice without line breaks, after a certain length I don't care about the overall trace size anymore, it's all about being able to visually parse it at all |
Seems clearer to me if they both are expand or contract but have different defaults. |
To proceed, I need help with the following:
|
this loses the ability to "infer" modules of inlined code, though but this probably needs a better implementation anyway
The expanded stacktrace printing introduced in #36134 and the fact that we no longer print errors in red (#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in red. Also remove exception numbering, which was arguably not very helpful.
The expanded stacktrace printing introduced in #36134 and the fact that we no longer print errors in red (#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in error_color(). Also remove exception numbering which was arguably not very helpful.
The expanded stacktrace printing introduced in #36134 and the fact that we no longer print errors in red (#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in error_color(). Also remove exception numbering which was arguably not very helpful.
* tweak how stacktraces are printed Co-authored-by: KristofferC <kcarlsson89@gmail.com>
The expanded stacktrace printing introduced in JuliaLang#36134 and the fact that we no longer print errors in red (JuliaLang#36015) makes it harder to distinguish distinct exceptions in the stack. Add a newline for this, and print the "caused by" in error_color(). Also remove exception numbering which was arguably not very helpful.
I think two factors make this look a bit worse in your case. First, the contrast between white and gray is very strong, and the contrast between gray and background very low (almost unreadable). That makes the types look unimportant and the colons very important. It could be different again with another color theme. The other thing is that your signatures are super short. The colons are supposed to be a bit more visible because they give you a visual anchor to where types / arguments begin when you have some long ones in there. It doesn't work the other way around because lower contrast is not salient between higher contrast. |
This also seems a bit odd to me. The intention is to make it easier to spot where the n-th type starts. An alternative would be to print the outermost type normally, and its (possibly long) type parameters in the dim (bright_black?) now used for the whole type. That way useful data marks the same division. |
One idea would be to print the outermost type in the same color as the Edit: I see now that it was mentioned in #36026 (comment) but saw no further discussion about it. |
I made a fork which implemented roughly this, to make it easy to try things on various terminals. Pictures here now updated to be on a dark background, and not to highlight the argument name: Besides the colons, IMO it's not necessary to use super-bright colours for the modules, it's better not to out-shine the function names. And it would be a little nicer to have them in a rainbow-ish order, starting near the red of the error. Edit: it also omits the colour from |
That looks like an improvement to me. Make a PR? |
I think it is slightly better but it is becoming a little bit of a "color salad" where it is hard to scan for the information you want. Worth trying out though. |
Any thoughts on how to un-salidify it? Would using fewer colours help, like maybe just the first 3 above, then re-use? (Since Terminal contrast alters this a lot too, e.g. the light-mode screenshots (at my link) have much less distinction between normal and dim text. Will try a PR when I get a minute. |
FWIW, I think the colors are fine. |
The current ones or the ones in the last screenshot? |
Last screenshot. |
Not a PR yet, but here's a paste-able patch: |
I just installed 1.6 and noticed that the function names are not bold anymore, making them stick out less than I originally intended (especially if they are above and below colored Modules). This must have gotten lost in a rewrite? I've tried to follow to the point where functions are printed, but I couldn't find it. The new implementation seems to go quite deep into special cases, but the gist is that the function name is printed non-bold in the end. If they were all bold, you could see a nice vertical bold group for easy orientation. See here, it's hard to see the function names. |
It might have gotten lost, yes. Should be easy to put back though. |
I tried here: ada29c2. (Without really understanding how they used to be made bold, before this.) Comparison picture here: #37773 (comment) |
This PR broke cycle detection in stack trace printing in some cases 😮 I've tracked the breakage down to this PR, where you can see a before/after that shows the stack trace not reporting the recursion cycle: julia> versioninfo() # before
Julia Version 1.6.0-DEV.353
Commit 7dba98808a* (2020-07-02 01:54 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
julia> foo() = foo()
foo (generic function with 1 method)
julia> foo()
ERROR: StackOverflowError:
Stacktrace:
[1] foo() at ./REPL[2]:1 (repeats 79984 times) julia> versioninfo() # after
Julia Version 1.6.0-DEV.354
Commit 30b09dfd2b* (2020-07-02 08:02 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
julia> foo() = foo()
foo (generic function with 1 method)
julia> foo()
ERROR: StackOverflowError:
Stacktrace:
[1] foo()
@ Main ./REPL[2]:1 The new printing is super pretty and I love it -- can we try to track down and fix this regression so that cycle detection still works with this new framework? :) Thanks! |
cf. issue #36026
The base functionality works. I added handling of stackoverflow traces, too.
I have not dealt with any tests, yet. Also, somebody in the know should check if my methods of retrieving different parts of information about each frame are valid.
I am also checking for three boolean ENV variables in the code, to make printing a bit more customizable. They are: