You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/design_docs/async_stack_traces.md
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -709,6 +709,42 @@ Or, we could simply omit the frames and have non-consecutive frame numbers.
709
709
In an interactive context, such as a debugger, the `...` approach is probably best, since it could also provide an option to expand that section and see the frames that are missing.
710
710
In non-interactive cases, such as printing a backtrace with some `RUST_BACKTRACE` setting, it may be better to omit the frame numbers that were skipped since that leads to a slightly more compact backtrace.
711
711
712
+
### Generate more informative symbol names
713
+
714
+
Currently `async` functions result in a function name like `foo::generator$0`.
715
+
This can be confusing to users, since it leaks implementation details about `async` functions.
716
+
We probably have a lot of flexibility in the generated names, so `rustc` could encode more information about where this symbol came from.
717
+
Backtrace printers could then decode these names to give the information to the user in a meaningful way.
718
+
719
+
Here is an example of what this might look like in practice:
720
+
```
721
+
panicked at 'explicit panic', C:\Users\ericholk\repo\backtrace-examples\async-common\src\lib.rs:10:5
722
+
Backtrace:
723
+
0 [12]: async fn common::baz
724
+
at C:\Users\ericholk\repo\backtrace-examples\async-common\src\lib.rs:10
725
+
1 [14]: async fn common::bar
726
+
at C:\Users\ericholk\repo\backtrace-examples\async-common\src\lib.rs:6
727
+
2 [16]: async fn common::foo
728
+
at C:\Users\ericholk\repo\backtrace-examples\async-common\src\lib.rs:2
729
+
3 [18]: async fn async_tokio::main
730
+
at C:\Users\ericholk\repo\backtrace-examples\async-tokio\src\main.rs:5
731
+
4 [30]: fn async_tokio::main
732
+
at C:\Users\ericholk\repo\backtrace-examples\async-tokio\src\main.rs:5
733
+
```
734
+
735
+
Here we have done aggressive filtering on the backtrace to remove runtime-internal frames.
736
+
The raw frame numbers are still listed in brackets, however, so the user can see if frames have been hidden.
737
+
The function names are now printed as either `fn foo` or `async fn bar` to indicate what kind of function was called.
738
+
739
+
We could support a couple of suffixes on generated functions, such as:
740
+
-`foo::generator$0` - current suffix, but would be used only for generator blocks
741
+
-`foo::async_fn$` - indicates that this is the body of an `async fn`
742
+
-`foo::async$0` - the function came from an `async {}` block within another function[^async-block]
743
+
-`foo::generator_fn$` - analogous to `foo::async_fn$` for when generator functions are supported
744
+
For the block suffixes, we could potentially encode the line number or the block or some other way of identifying multiple blocks that would be useful to the user.
745
+
746
+
[^async-block]: How we want stack traces involving async blocks to look is still an open question.
747
+
712
748
## References
713
749
714
750
*[Beautiful tracebacks in Trio v0.7.0 (Python)](https://vorpus.org/blog/beautiful-tracebacks-in-trio-v070/)
0 commit comments