A zero-copy parser for the contents of the __unwind_info
section of a mach-O binary.
Quickly look up the unwinding opcode for an address.
This crate is intended to be fast enough to be used in a sampling profiler. Re-parsing from scratch is cheap and can be done on every sample.
```rust use machounwindinfo::{UnwindInfo, OpcodeX86_64};
let unwindinfo = UnwindInfo::parse(data)?; if let Some(function) = unwindinfo.lookup(0x1234)? { match OpcodeX8664::parse(function.opcode) { OpcodeX8664::Null => println!("Null"), OpcodeX8664::FrameBased { .. } => println!("FrameBased"), OpcodeX8664::FramelessImmediate { .. } => println!("FramelessImmediate"), OpcodeX8664::FramelessIndirect => println!("FramelessIndirect"), OpcodeX8664::Dwarf { .. } => println!("Dwarf"), } } ```
This repository also contains two CLI executables. You can install them like so:
% cargo install --examples macho-unwind-info
Thanks a ton to @Gankra for documenting this format at https://gankra.github.io/blah/compact-unwinding/.
Licensed under either of
LICENSE-APACHE
or http://www.apache.org/licenses/LICENSE-2.0)LICENSE-MIT
or http://opensource.org/licenses/MIT)at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.