getunwind - Linux


Overview

getunwind is a command-line utility for generating unwind call frames, a crucial component in debugging C++ and Rust programs. It enables one to quickly and conveniently visualize the call stack, making it easier to trace code execution flow and identify potential issues.

Syntax

getunwind [options] <binary> <address>

Options/Flags

  • –arch : Specify the target architecture, such as x86_64 or aarch64. Default: auto-detect.
  • –type : Set the unwind type to use, either dwarf or eh_frame. Default: dwarf.
  • –offset : Adjust the address by an offset in bytes.
  • –demangle: Demangle C++ symbols for readability.
  • –raw: Output raw unwind information without demangling.
  • –help: Display help information and exit.

Examples

Simple usage:

getunwind ./my_program 0x12345678

Demangle symbols:

getunwind --demangle ./my_program 0x12345678

Specify unwind type:

getunwind --type eh_frame ./my_program 0x12345678

Common Issues

  • Missing debug symbols: Ensure the binary has debug symbols embedded.
  • Incorrect architecture: Verify that the specified architecture matches the target binary.
  • Invalid address: Check if the provided address is within the binary’s address space.

Integration

Integration withgdb: Use the output of getunwind to load unwind information into gdb:

gdb ./my_program
(gdb) unwind load <unwind information>

Command chaining: Combine getunwind with other commands for advanced analysis:

getunwind ./my_program 0x12345678 | less

Related Commands

  • addr2line: Translates addresses into source code lines.
  • c++filt: Demangles C++ symbols.
  • readelf: Displays ELF file header and section information.