-
Notifications
You must be signed in to change notification settings - Fork 1.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
Offer stable access to stacktrace call stack #42916
Comments
IIRC this is what https://pub.dev/packages/stack_trace does: // https://pub.dev/documentation/stack_trace/latest/stack_trace/Trace/Trace.from.html
var trace = Trace.from(stackTrace); The problem with including this natively in the language (or SDK) is that you would incur a rather high fixed cost for all apps versus the package that is able to be optional (e.g. just used in say, testing, or debug builds). |
Yeah, I learned about that package after posting this. The reference to a high fixed cost is interesting. Can you elaborate on what that cost would be? If The existence of that package is probably a reasonable functional solution to this ticket. However, I'm still curious about this notion of implicitly structuring |
I am the wrong person to give that specific information, but I know for sure that ...
Ah. That is is not true. Dart has multiple runtime and compile-time formats:
At least a few of these (the compile-to-JS variants) use the built-in VM's Stack Trace format, which differs from the "native" (Dart) VM format fairly significantly. On those platforms, there isn't any serialization of Stack Traces (at least none that Dart itself performs other than perhaps some munging/transformation to try and normalize the results to some extent). It's also possible future compiled formats (LLVM, Web Assembly) might use the native stack trace format instead of the Dart VMs for performance and usability reasons, for example. |
Basically tl;dr - what you are asking for already exists in a way that is much easier to iterate on and is more guaranteed to work the same as more platforms become available |
Thanks for the info. This continues to be interesting :) This new information certainly changes the perspective quite a bit. Based on your description, I would tend to agree that this original ticket is misguided. The interesting thing is that it's misguided due to a complete lack of context on my part. For example, here is the official API docs for this https://api.flutter.dev/flutter/dart-core/StackTrace/toString.html The information you mentioned might be available somewhere, but whatever my path was to get here, it was easy for me to remain ignorant of those important details that you described. At a minimum, could this information be added to the
|
I think those are valid questions, but probably are a better fit for There is also https://pub.dev/packages/native_stack_traces, I have no idea what this is though. |
It's definitely an SDK question, we don't want to specify the stack trace format in the language specification (for all the reasons Matan has mentioned, mainly that we want to just use native stack traces when compiling to JavaScript and other potential future native platforms). Parsing the stack trace to figure out who called you is a kind of reflection, so I'm OK with that costing extra for the code doing so, and not adding the cost to other code which just propagates a stack trace and eventually prints it. |
Thanks for the replies. I've filed the following issue in the SDK repo: I'm going to close this issue because it sounds like there is nothing more to do on the language front. If there is any internal tracking reason to leave this open then please feel free to re-open. |
StackTrace
s are used by various logging packages to print the class name and/or method name from which a log originates. This is currently solved by ad hoc parsing ofStackTrace
toString()
results, e.g.,https://github.com/magillus/flutter-fimber/blob/master/fimber/lib/fimber_base.dart#L242
I suggest that
StrackTrace
introduce a first-class, structured representation of the stack trace instead of an implied protocol intoString()
.Relying on
toString()
introduces the following issues:toString()
does not imply stable return values, it could conceivably change at any timeThe text was updated successfully, but these errors were encountered: