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
address_to_line-0.1.2.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for address_to_line-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73f2a59b8ba76df160d4e9f1e2790c852c0c905ea21b8e7d3b4e56eb481ef6ea |
|
MD5 | aa680f9dd52a03916d5d9b6717a33d7c |
|
BLAKE2b-256 | f6387b9dae4708728a8d054d29ffdac0bff066a1c545b5d977bafba218a2f9ff |