Convert addresses to source file and line number
Project description
address_to_line
Translate return addresses into source locations using the readelf and addr2line utilities from the GNU Binutils package.
Requirements
This package depends on the readelf and addr2line utilities from the GNU Binutils package.
Usage
Converting return addresses captured from within some process requires a copy of that process' /proc/[pid]/maps file.
Command line:
python3 -m address_to_line <proc_map_file> <addresses>
where proc_map_file is a copy of a process' /proc/[pid]/maps file and addresses is a text file containing 1 (hexaecimal) return address per line.
Code:
from address_to_line import resolve_source_locations
proc_map_file = "memory_map.txt" # The relevant /proc/[pid]/maps file
addresses_file = "addresses.txt" # Contains 1 (hexadecimal) return address per line
with open(addresses_file, "r") as f:
addresses = [int(line, base=16) for line in f.readlines()]
# A list of named tuples of address, function, source file and line
source_locations = resolve_source_locations("memory_map.txt", addresses)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file address_to_line-0.1.2.tar.gz.
File metadata
- Download URL: address_to_line-0.1.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8a785d2de2e154a9ac24ef423815d70ad1839fd86894e0b0e768fa77951ccdc
|
|
| MD5 |
ca8a7fe2fd028f6a59cf034feafe8cd4
|
|
| BLAKE2b-256 |
713442d50e8f9e74f3cf088ff717e32bb8c90ffdacffdeb2ce7b222aedefdeec
|
File details
Details for the file address_to_line-0.1.2-py3-none-any.whl.
File metadata
- Download URL: address_to_line-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73f2a59b8ba76df160d4e9f1e2790c852c0c905ea21b8e7d3b4e56eb481ef6ea
|
|
| MD5 |
aa680f9dd52a03916d5d9b6717a33d7c
|
|
| BLAKE2b-256 |
f6387b9dae4708728a8d054d29ffdac0bff066a1c545b5d977bafba218a2f9ff
|