GitXplorerGitXplorer
p

cpython-unwind

public
4 stars
0 forks
0 issues

Commits

List of commits on branch main.

No commits found

There are no commits on branch main.

README

The README file for this repository.

Python Stack Unwinder

This Python C extension provides stack unwinding capabilities using three different methods:

  • GNU Backtrace
  • libunwind
  • libdw (DWARF debug info)

Unwinders

  • get_stack_gnu(): Stack unwinding using GNU's backtrace functions
  • get_stack_unwind(): Stack unwinding using libunwind
  • get_stack_dwarf(): Stack unwinding using libdw

Requirements

The following libraries are required to build the extension:

  • libunwind
  • libdw
  • libelf
  • Python development headers

Installing Dependencies

On Debian/Ubuntu:

sudo apt-get install python3-dev libunwind-dev libdw-dev libelf-dev

On Fedora/RHEL:

sudo dnf install python3-devel libunwind-devel elfutils-devel

On Arch Linux:

sudo pacman -S python libunwind elfutils

Installation

  1. Clone this repository:
git clone <repository-url>
cd python-stack-unwinder
  1. Build the extension:
python setup.py build_ext --inplace

Usage

import stackunwind

# Get stack trace using GNU backtrace
stack = stackunwind.get_stack_gnu()
print("GNU Backtrace:")
for frame in stack:
    print(f"  {frame}")

# Get stack trace using libunwind
stack = stackunwind.get_stack_unwind()
print("\nlibunwind:")
for frame in stack:
    print(f"  {frame}")

# Get stack trace using libdw
stack = stackunwind.get_stack_dwarf()
print("\nlibdw:")
for frame in stack:
    print(f"  {frame}")