rust-lang / backtrace-rs

Backtraces in Rust

Home Page:https://docs.rs/backtrace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement Eq/PartialEq, Hash and Clone for Backtrace?

hrydgard opened this issue · comments

When building things like built-in memory profilers and similar, it's quite useful to be able to deduplicate captured callstacks without having to resolve them - since resolving stack traces can be kinda expensive, you ideally shouldn't do that until it's time to display things or produce the final report.

To do this, one convenient way would be to put the captured Backtrace-s in some kind of hash map pointing at counters for example, but this isn't currently possible since Backtrace doesn't implement the traits from this issue title (Eq/PartialEq, Hash and Clone).

Would a PR be accepted that implemented these for the structures in dbghelp.rs? I guess it really needs implementation in libunwind.rs and miri.rs though?

I think this could make sense for the Backtrace type but probably not for the raw underlying types since those are typically OS-specific pointers which aren't otherwise persisted.