-
Notifications
You must be signed in to change notification settings - Fork 514
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
Make stack trace format more user friendly #592
Conversation
Current format, from Duktape 1.4.0:
|
The current draft produces something along the lines of what @HouQiming proposed:
|
That synthetic call stack entry (duk_js_var.c:1259) could maybe be:
Adding "at" might give an impression it's a call stack entry (when it's not):
This pull could also deal with anonymous function names which now print out as:
so they're not distinguishable from a function actually named "anon". The function name could just be omitted in that case:
Or a single space could be used:
Or the placeholder could contain something which would make it unlikely to be an actual function name:
|
Yet another option for the synthetic native throw site would be a flag-like indicator:
A fake (anon) function name could be added:
|
Added brackets to anon and "at" to the synthetic call site, so things look like this now:
The synthetic entry is different now in that it's missing a function name entirely so it doesn't match anonymous functions (it's not a function so maybe that's logical). |
I think a flag would work better. When one is debugging some code, the On Tue, Feb 16, 2016 at 4:49 PM, Sami Vaarala notifications@github.com
|
@HouQiming do you have a suggestion for a flag name? :) I'll let this pull sit for a while in case there are more suggestions. Also while the stack trace format is not under any versioning guarantees, it'd be nice to make enough changes here so that it wouldn't be then touched in a while. |
eca6fd3
to
ec20227
Compare
How about "internal" or "api"? I totally agree with letting it sit for a while. I just hope to eventually On Tue, Feb 16, 2016 at 4:56 PM, Sami Vaarala notifications@github.com
|
@HouQiming I'm sure others share your goal :) |
So here's the current state, with the internal call site flagged 'internal' and
|
ec20227
to
4d0f0d8
Compare
Using a tab for indent seems to also divide opinions a little bit. With tab = 8 it's actually a rather deep indent, so it could be changed to 4 spaces here. |
I think 4 spaces is better in practice. Editors don't really care, so On Tue, Feb 16, 2016 at 5:26 PM, Sami Vaarala notifications@github.com
|
I have a hard time wrapping my head around that native entry - you say it's not a real callstack entry, so is it logically related to the actual top call? |
For the example stack trace above, the ReferenceError is thrown from Ecmascript code and the line related to the topmost activation is The synthetic entry in this case indicates the exact internal throw site which is in variable lookup code, at |
4d0f0d8
to
d41c005
Compare
Rebased and made the indent use 4 spaces instead of a tab. Current state:
Another example: function bar() {
aiee;
}
function foo() {
bar();
}
foo(); Results in:
|
Unless there are any more suggestions for improvement, I'll fix the testcases, update the website documentation etc and we have a new, improved traceback format in master :) |
I like that with |
@fatcerberus It was the best compromise I could figure: brackets can't appear in legitimate function names so it should very rarely be ambiguous (it can though if you forcible edit the function name and set it to a specific value). Using the empty string would mean there'd be two spaces there (or if one was omitted, one field would just be missing). |
That looks really nice. Does is happen to show calls when the 'this' binding is not the global env? As in, fake methods like "Foo.doSomething()" ? Or would that make no sense? |
The current traceback format doesn't show the "this" binding in any way right now, unfortunately. Can you provide an example what/how would be shown? |
One thing I don't like too much is "preventsyield" internal flag which is relevant but too long. Maybe "noyield"? |
What does that flag mean anyway? |
It means that a thread yield cannot happen because that call is in the call stack. |
Ah, "noyield" would be okay with me then. |
Well, what I did on the debug client was check the if the current function on the callstack is not anonymous, if not, then I check if 'this' evaluated to an object and if that object was not the global object, I got the constructor name and prefixed it to the function name as such:
Don't know how you feel about that though. |
Though I think it would be visually appealing and helpful if it weren't an issue as you guys have described. |
@fatcerberus Because _Tracedata refers to it that won't be the case. The same thing happens now for functions: all functions in the throw site are referenced by the _Tracedata as long as the error object itself is reachable. |
@svaarala Awesome, thanks! 👍 |
The current native flag names are here: #592 (comment)
Suggestions for making these a bit shorter?
|
I agree on tailcalled -> tailcall. "noyield" I'm not sure yet if it would be misleading. |
After re-reading it carefully, I think we should also bracket "input" since About miscellaneous data like "this" binding, I think the ultimate solution I think it should be a DUK_OPT since most people probably won't need it. On Sun, Feb 21, 2016 at 9:52 AM, Bruce Pascoe notifications@github.com
|
@HouQiming The "input" in this example is actually the Re: adding a formatting callback, it wouldn't help because the "this" binding is no longer available when the stack trace is being formatted. So we wouldn't be able to give it to the callback. |
Re: adding options and/or callbacks, that would technically be possible but I'd prefer we didn't: there are always special needs which are difficult to account for. One can add callbacks to format entries etc, but it's easy to add a lot of stuff (and worry about versioning all of them) and still fail to add that one special thing that is needed in some specific environment. However, the good news is that it's actually quite easy to just replace the whole
Both will rely on There's currently no support to access Duktape internal headers from outside, but that's actually a separate issue and would be nice to fix, so that one could write functions that peeked into the internals, knowing that you have no versioning guarantees. Anyway, this pull request is about what to do with the default format :) |
345432e
to
336b6f9
Compare
Current state:
@fatcerberus Opinions on "noyield" vs. "preventsyield" or some alternative? I'd prefer "noyield" because it's shorter and less prominent. It's cryptic anyway if you don't know what it means beforehand. |
I was under the impression that noyield functions prevent a yield if they are anywhere on the callstack, at least that was the impression I got from your description above. If that's the case then "noyield" is misleading because it implies it's only that function that can't yield. |
@fatcerberus That impression is correct, and I agree with your reasoning, preventsyield is clearer (but long). I'd like to find a shorter alternative if possible :) "prevyield" would be ambiguous too (could be mistaken for "previous yield" or something). Well, if there are no better suggestions I'll grudgingly change it back to "preventsyield" ;) |
Maybe "preventyield" (without the 's')? |
f57782f
to
8f4e050
Compare
* Add 'at foo' to indicate function name * Put file/line into parentheses for better readability * Use [anon] for anymous functions, which is better than an empty string but distinguishable from a function actually named 'anon' * Rename tailcalled flag to tailcall * Switch from tab indent to 4 space indent
acd2dfc
to
a3c755a
Compare
Also fix DUK_OPT_LIGHTFUNC_BUILTINS testcase (test-dev-lightfunc.js) which had a few regressions.
a3c755a
to
0beaaa6
Compare
Restored "preventsyield", merging once the tests pass. |
Make stack trace format more user friendly
Make stack trace format a little bit more user friendly. Fixes #588.
Tasks: