address-to-line


Nameaddress-to-line JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryConvert addresses to source file and line number
upload_time2023-05-11 16:11:15
maintainer
docs_urlNone
authorAdam Tuft
requires_python
licenseBSD 3-Clause License Copyright (c) 2023, Adam Tuft All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `address_to_line`

Translate return addresses into source locations using the `readelf` and `addr2line` utilities from the [GNU Binutils](https://www.gnu.org/software/binutils/) package.

## Requirements

This package depends on the `readelf` and `addr2line` utilities from the [GNU Binutils](https://www.gnu.org/software/binutils/) package.

## Usage

Converting return addresses captured from within some process requires a copy of that process' `/proc/[pid]/maps` file.

### Command line:

```commandline
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:

```python
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)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "address-to-line",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Adam Tuft",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/71/34/42d50e8f9e74f3cf088ff717e32bb8c90ffdacffdeb2ce7b222aedefdeec/address_to_line-0.1.2.tar.gz",
    "platform": null,
    "description": "# `address_to_line`\n\nTranslate return addresses into source locations using the `readelf` and `addr2line` utilities from the [GNU Binutils](https://www.gnu.org/software/binutils/) package.\n\n## Requirements\n\nThis package depends on the `readelf` and `addr2line` utilities from the [GNU Binutils](https://www.gnu.org/software/binutils/) package.\n\n## Usage\n\nConverting return addresses captured from within some process requires a copy of that process' `/proc/[pid]/maps` file.\n\n### Command line:\n\n```commandline\npython3 -m address_to_line <proc_map_file> <addresses>\n```\n\nwhere `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.\n\n### Code:\n\n```python\nfrom address_to_line import resolve_source_locations\nproc_map_file = \"memory_map.txt\" # The relevant /proc/[pid]/maps file\naddresses_file = \"addresses.txt\" # Contains 1 (hexadecimal) return address per line\nwith open(addresses_file, \"r\") as f:\n    addresses = [int(line, base=16) for line in f.readlines()]\n# A list of named tuples of address, function, source file and line\nsource_locations = resolve_source_locations(\"memory_map.txt\", addresses)\n```\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License  Copyright (c) 2023, Adam Tuft All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "Convert addresses to source file and line number",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6387b9dae4708728a8d054d29ffdac0bff066a1c545b5d977bafba218a2f9ff",
                "md5": "aa680f9dd52a03916d5d9b6717a33d7c",
                "sha256": "73f2a59b8ba76df160d4e9f1e2790c852c0c905ea21b8e7d3b4e56eb481ef6ea"
            },
            "downloads": -1,
            "filename": "address_to_line-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa680f9dd52a03916d5d9b6717a33d7c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7910,
            "upload_time": "2023-05-11T16:11:13",
            "upload_time_iso_8601": "2023-05-11T16:11:13.222565Z",
            "url": "https://files.pythonhosted.org/packages/f6/38/7b9dae4708728a8d054d29ffdac0bff066a1c545b5d977bafba218a2f9ff/address_to_line-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "713442d50e8f9e74f3cf088ff717e32bb8c90ffdacffdeb2ce7b222aedefdeec",
                "md5": "ca8a7fe2fd028f6a59cf034feafe8cd4",
                "sha256": "a8a785d2de2e154a9ac24ef423815d70ad1839fd86894e0b0e768fa77951ccdc"
            },
            "downloads": -1,
            "filename": "address_to_line-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ca8a7fe2fd028f6a59cf034feafe8cd4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5491,
            "upload_time": "2023-05-11T16:11:15",
            "upload_time_iso_8601": "2023-05-11T16:11:15.012245Z",
            "url": "https://files.pythonhosted.org/packages/71/34/42d50e8f9e74f3cf088ff717e32bb8c90ffdacffdeb2ce7b222aedefdeec/address_to_line-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-11 16:11:15",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "address-to-line"
}
        
Elapsed time: 1.45867s