Skip to content
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

Custom backtrace output for Fuchsia #245

Merged
merged 17 commits into from
Sep 4, 2019

Conversation

cramertj
Copy link
Member

@cramertj cramertj commented Aug 27, 2019

Fuchsia can't do traditional target-side symbolization. Instead, it uses a custom format containing information about the current location of libraries in memory and the addresses of the stack frames.

r? @alexcrichton @JakeEhrlich

@cramertj cramertj force-pushed the fuchsia-bt branch 3 times, most recently from d4a9b67 to 8571cef Compare August 28, 2019 00:09
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Is this something stable enough to build on CI as well? If not that's ok, but if it is it seems reasonable to run a smoke check there to ensure that future changes don't accidentally regress this.

@cramertj
Copy link
Member Author

Is this something stable enough to build on CI as well?

Sure-- we can cargo check it. Building for the actual Fuchsia target won't really help anything because nothing's getting linked, but I'd love to make sure it doesn't get broken.

@cramertj
Copy link
Member Author

I see lots of dockerfiles and am not exactly sure how I'd set that up, though.

@alexcrichton
Copy link
Member

Looks great to me! Some minor things:

  • Looks like a rustfmt is needed
  • I don't think that the Iterator style API will be immediately usable by libstd because it's using inline iteration with backtrace frames. Perhaps some sort of struct with a method to print the context and then a method to call when the ip for each frame is learned?

Other than that seems all good to me!

@alexcrichton
Copy link
Member

It may be useful as well to develop the libstd patch to use this in tandem, which should be possible by using [patch] and compiling libstd for fuchsia

cramertj and others added 6 commits September 3, 2019 11:48
It's got enough code it's worth checking now!
This commit refactors the support needed to print Fuchsia's backtraces
to support all platforms as well. This ideally moves out the need to
have different code for printing a backtrace in libstd and this crate,
and now both can share the same implementation!

The implementation should produce the same output on fuchsia, but for
other platforms it should match the current output of the standard
library, including the full/short configuration options.
Delegate printing of paths to the creator of `BacktraceFmt` since it's
too unwieldy to implement here.
@alexcrichton
Copy link
Member

Ok I was struck with some inspiration while reading over this, and I hope you're ok that I went ahead and tacked on some more commits here. I'm hoping that these commits will also make it easier to integrate into libstd because we can basically just delete all of sys_common/backtrace.rs now and use the printing code here.

Mind taking a look and seeing how it works out? Do you think that the last few commits are too overzealous?

@cramertj
Copy link
Member Author

cramertj commented Sep 3, 2019

Looks reasonable enough for me! I'll pull this down and test locally to make sure things still work. Did you think about how you want to handle cutting out things after __rust_begin_short_backtrace like is currently done in libstd?

@cramertj
Copy link
Member Author

cramertj commented Sep 3, 2019

I'll pull this down and test locally to make sure things still work.

Still good on my end!

@alexcrichton
Copy link
Member

Yeah that was the one thing I left out since I don't think I've ever seen a backtrace get successfully truncated with that symbol, but it's harmelss enough to put back in and it probably should happen. Some filtering logic will still need to be in libstd like the max number of frames, but I think that's fine

@cramertj
Copy link
Member Author

cramertj commented Sep 3, 2019

SGTM!

@alexcrichton alexcrichton merged commit 2bb900b into rust-lang:master Sep 4, 2019
@cramertj cramertj deleted the fuchsia-bt branch September 4, 2019 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants