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

allow getting task dump backtraces in a programmatic format #6975

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

arielb1
Copy link

@arielb1 arielb1 commented Nov 14, 2024

This PR creates structs that allow dumping backtraces in a programmatic format, for example JSON. A JSON serializer is not natively included to avoid creating a Tokio dependency on one, but serialization can be done by customers.

Fixes #6309.

@github-actions github-actions bot added R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR labels Nov 14, 2024
@arielb1 arielb1 force-pushed the programmatic-backtraces branch 3 times, most recently from df04fc7 to ede6e06 Compare November 14, 2024 18:00
@arielb1
Copy link
Author

arielb1 commented Nov 19, 2024

What is this waiting for?

@arielb1
Copy link
Author

arielb1 commented Nov 20, 2024

So @Darksonn is busy these days. Could @mox692 please review this?

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-taskdump --cfg tokio_taskdump labels Nov 21, 2024
Copy link
Member

@mox692 mox692 left a comment

Choose a reason for hiding this comment

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

Thank you! I left high level questions about suggested apis.

Comment on lines +62 to +70
/// Return the raw name of the symbol.
pub fn name_raw(&self) -> Option<&[u8]> {
self.name.as_deref()
}

/// Return the demangled name of the symbol.
pub fn name_demangled(&self) -> Option<&str> {
self.name_demangled.as_deref()
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we need both? I think users can construct demangled one by using name_raw.

Copy link
Author

Choose a reason for hiding this comment

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

I just had it since backtrace had that, and for some reason I thought the API was somewhat private. Apparently rustc_demangle is a perfectly fine public API.

Copy link
Member

@mox692 mox692 Nov 25, 2024

Choose a reason for hiding this comment

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

Ah, Never mind ... I missed you were using the Display impl of SymbolName to get a demangle name in 991434a. (I left comment above just because it looked like similar two fields were being added for the same already demangled data.)

To be clear, I think it's fine (or even better) to provide a name API that returns the demangled name, as the backtrace crate already does. (If users request a mangle API, which is probably unlikely, we can add it later.)

Copy link
Author

@arielb1 arielb1 Nov 25, 2024

Choose a reason for hiding this comment

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

So would you rather have the PR this way or with the name_raw and name_demangled functions?

I definitely don't want to have a version of the code that exposes only the demangled name, since AFAICT if it's a C symbol rather than a Rust symbol the demangling is lossy.

tokio/src/runtime/dump.rs Outdated Show resolved Hide resolved
tokio/src/runtime/dump.rs Show resolved Hide resolved
@arielb1 arielb1 force-pushed the programmatic-backtraces branch 2 times, most recently from 283eea6 to dd3f267 Compare November 22, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-taskdump --cfg tokio_taskdump R-loom-current-thread Run loom current-thread tests on this PR R-loom-multi-thread Run loom multi-thread tests on this PR R-loom-multi-thread-alt Run loom multi-thread alt tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support an API to extract backtrace information from taskdump
3 participants