Skip to main content

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


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)

Uploaded Source

Built Distribution

address_to_line-0.1.2-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page