-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add Frames Iterator for Backtrace #81022
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
r? @KodrAus |
The job Click to see the possible cause of the failure (guessed by this bot)
|
library/std/src/backtrace.rs
Outdated
@@ -147,11 +147,15 @@ fn _assert_send_sync() { | |||
_assert::<Backtrace>(); | |||
} | |||
|
|||
struct BacktraceFrame { | |||
/// A single frame of a backtrace. | |||
#[derive(Debug)] |
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.
I think we’ll probably want to implement Debug
manually for this type to match the format produced by Backtrace
.
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.
Is that within scope for this PR? Or should that perhaps go in a separate one?
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.
I think it would be within scope, since we're making this type public now.
@KodrAus I added a
So some frames are skipped and not printed. I'm not sure what to do in the same situation for a single |
Thanks @seanchen1991! This looks good to me. The main thing I was looking at with the debug format was trying to make symbols look the same. I think we're ready to merge this! Would you be happy to squash your commits down? r=me after that. I did have one more thought on making the return type some |
0023c45
to
050643a
Compare
@bors r=KodrAus |
@yaahc: 🔑 Insufficient privileges: Not in reviewers |
@bors r=KodrAus |
@seanchen1991: 🔑 Insufficient privileges: Not in reviewers |
@bors r+ |
📌 Commit 050643a has been approved by |
…as-schievink Rollup of 11 pull requests Successful merges: - rust-lang#80629 (Add lint for 2229 migrations) - rust-lang#81022 (Add Frames Iterator for Backtrace) - rust-lang#81481 (move some tests) - rust-lang#81485 (Add some tests for associated-type-bounds issues) - rust-lang#81492 (rustdoc: Note why `rustdoc::html::markdown` is public) - rust-lang#81577 (const_evaluatable: consider sub-expressions to be evaluatable) - rust-lang#81599 (Implement `TrustedLen` for `Fuse<I: TrustedLen>`) - rust-lang#81608 (Improve handling of spans around macro result parse errors) - rust-lang#81609 (Remove the remains of query categories) - rust-lang#81630 (Fix overflowing text on mobile when sidebar is displayed) - rust-lang#81631 (Remove unneeded `mut` variable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
impl<'a> Backtrace { | ||
/// Returns an iterator over the backtrace frames. | ||
#[unstable(feature = "backtrace_frames", issue = "79676")] | ||
pub fn frames(&'a self) -> &'a [BacktraceFrame] { |
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.
Wouldn't it be better if this were an iterator? That could make lazily walking the stack cheaper at some point in the future.
E.g. Java introduced a StackWalker API to make partial stack traces cheaper.
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.
This was indeed discussed. There's some additional discussion and context that isn't apparent because it's in the previous iteration of this PR. Apologies for that.
You can read some of that discussion here.
Second attempt at adding the ability to iterate over the frames of a Backtrace by exposing the frames method.