Open Diggsey opened 3 years ago
This is deliberate. The Symbol
may borrow for example the name field from the mmapped object file. This is the case for the gimli backend. The gimli backend uses an LRU cache for those mmaps, so the Symbol
may become invalid later on: https://github.com/rust-lang/backtrace-rs/blob/e7f61cc6b52791e0299bbd6ecfaa25e8ae02034a/src/symbolize/gimli.rs#L582
The Backtrace
type can be resolved before it is formatted, but as a result of Symbol
not being Clone
, there's no way to do this with the raw API?
Changing Symbol
to be Clone
will require adding a lifetime parameter to Symbol
(because the 'static
is a lie, the real lifetime is shorter than that). Doing that isn't going to solve the problem you have because you still won't be able to store the symbol for later use.
Yes unfortunately Symbol
can't easily be Clone
unless it has some sort of cow-like representation. What might make sense though is to do something like impl From<&Symbol> for BacktraceSymbol
which already does the cow-like thing, and that should give you an owned struct to persist.
Yep 👍 I think I would also need a similar conversion for Frame
in order to use the formatter?
Yes I believe a similar conversion from &Frame
to BacktraceFrame
should be possible.
It does not appear possible to use the raw backtrace functionality effectively, because the
Symbol
struct does not implementClone
, and theresolve_frame
callback is passed a&Symbol
reference which is not'static
. As a result, there's no way to store that symbol for later use.