- Make sure you build the binary with debug symbols. For example:
RUSTFLAGS=-g cargo build --release
- Use rust-gdb to start the binary and load the script:
rust-gdb rust_binary -x memlayout-rust.py
- Break anywhere you like, and use the command
mem-layout VARIABLE_NAME
to print the layout of that variable:
- Custom structures are also supported:
struct S1 {
v1: Vec<i32>,
b2: u8,
c3: Box<Vec<usize>>,
}
- Some pointers may not be translated correctly. If you see a member's type is 'None' and has size of 0x8, that's a pointer.