-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
allow getting task dump backtraces in a programmatic format #6975
base: master
Are you sure you want to change the base?
Conversation
df04fc7
to
ede6e06
Compare
What is this waiting for? |
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.
Thank you! I left high level questions about suggested apis.
tokio/src/runtime/dump.rs
Outdated
/// 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() | ||
} |
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.
Do we need both? I think users can construct demangled one by using name_raw
.
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 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.
tokio/src/runtime/dump.rs
Outdated
/// Resolve and return a list of backtraces that are involved in polls in this task. | ||
pub fn resolve_backtraces(&self) -> Vec<Vec<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.
Is it possible for one Trace
to return multiple backtraces? If such a case does not exist, I feel it would be clearer to return Vec<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.
I suspect this may have to do with tokio::join!
and similar.
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.
Added documentation to that effect.
let mut backtrace = backtrace::Backtrace::from(backtrace.clone()); | ||
backtrace.resolve(); | ||
backtrace | ||
.frames() | ||
.iter() | ||
.map(BacktraceFrame::from_resolved_backtrace_frame) | ||
.collect() |
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.
Perhaps we can fix this in the follow up PR, but if we are going to have our own Backtrace
type, I think we can avoid this conversion by making trace_leaf
function construct tokio's Backtrace struct directly.
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 resolves the backtrace, and therefore is expensive (see warning in docs), and therefore shouldn't be done in trace_leaf
0521d0a
to
283eea6
Compare
283eea6
to
dd3f267
Compare
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.