cxxfilt


Namecxxfilt JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/afq984/python-cxxfilt
SummaryPython interface to c++filt / abi::__cxa_demangle
upload_time2021-08-21 16:48:04
maintainer
docs_urlNone
authorafq984
requires_python
licenseBSD
keywords c++ c++filt name mangling
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            cxxfilt |ci|
============

.. |ci| image:: https://github.com/afq984/python-cxxfilt/actions/workflows/test.yml/badge.svg
    :target: https://github.com/afq984/python-cxxfilt/actions/workflows/test.yml

Demangling C++ symbols in Python / interface to abi::__cxa_demangle

Usage
-----

Install::

    pip install cxxfilt

Use ``demangle`` to demangle a C++ mangled symbol name::

    >>> import cxxfilt
    >>> cxxfilt.demangle('_ZNSt22condition_variable_anyD2Ev')
    'std::condition_variable_any::~condition_variable_any()'

Non-mangled name will be kept intact::

    >>> cxxfilt.demangle('main')
    'main'

To demangle an internal symbol, use `external_only=False`::

    >>> cxxfilt.demangle('N3foo12BarExceptionE')
    'N3foo12BarExceptionE'
    >>> cxxfilt.demangle('N3foo12BarExceptionE', external_only=False)
    'foo::BarException'

Invalid mangled names will trigger an ``InvalidName`` exception::

    >>> cxxfilt.demangle('_ZQQ')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/path/to/python-cxxfilt/cxxfilt/__init__.py", line 77, in demangle
        return demangleb(mangled_name.encode()).decode()
      File "/path/to/python-cxxfilt/cxxfilt/__init__.py", line 69, in demangleb
        raise InvalidName(mangled_name)
    cxxfilt.InvalidName: b'_ZQQ'

Use ``demangleb`` to demangle name in ``bytes``::

    >>> cxxfilt.demangleb(b'_ZNSt22condition_variable_anyD2Ev')
    b'std::condition_variable_any::~condition_variable_any()'

Make custom `Demangler` objects to use specific C/C++ libraries::

    >>> from ctypes.util import find_library
    >>>
    >>> d = cxxfilt.Demangler(find_library('c'), find_library('stdc++'))
    >>> d
    <Demangler libc='libc.so.6' libcxx='libstdc++.so.6'>
    >>>
    >>> d = cxxfilt.Demangler(find_library('c'), find_library('c++'))
    >>> d
    <Demangler libc='libc.so.6' libcxx='libc++.so.1'>
    >>> d.demangle('_ZNSt22condition_variable_anyD2Ev')
    'std::condition_variable_any::~condition_variable_any()'

Supported environments
----------------------

Python 3.6 or greater.

Tested on Linux and macOS (see github actions). Should work on unix systems with libc and libc++/libstdc++.

Will not work on Windows (PR welcome though).

For Python 2.7 please use cxxfilt version < 0.3.

Changelog
---------

0.3.0
~~~~~

*   Added ``Demangler`` class.

*   ``import cxxfilt`` no longer fails when there are no C/C++ libraries available.
    To check whether the default demangler is valid,
    use the expression: ``not isinstance(cxxfilt.default_demangler, cxxfilt.DeferedErrorDemangler)``.


Testing
-------

run in shell::

    pytest



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/afq984/python-cxxfilt",
    "name": "cxxfilt",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "c++ c++filt name mangling",
    "author": "afq984",
    "author_email": "afg984@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d7/dc/71ac606f7dfa71d49e3dc126b49b18daefaf6bd953078858af30fde40702/cxxfilt-0.3.0.tar.gz",
    "platform": "",
    "description": "cxxfilt |ci|\n============\n\n.. |ci| image:: https://github.com/afq984/python-cxxfilt/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/afq984/python-cxxfilt/actions/workflows/test.yml\n\nDemangling C++ symbols in Python / interface to abi::__cxa_demangle\n\nUsage\n-----\n\nInstall::\n\n    pip install cxxfilt\n\nUse ``demangle`` to demangle a C++ mangled symbol name::\n\n    >>> import cxxfilt\n    >>> cxxfilt.demangle('_ZNSt22condition_variable_anyD2Ev')\n    'std::condition_variable_any::~condition_variable_any()'\n\nNon-mangled name will be kept intact::\n\n    >>> cxxfilt.demangle('main')\n    'main'\n\nTo demangle an internal symbol, use `external_only=False`::\n\n    >>> cxxfilt.demangle('N3foo12BarExceptionE')\n    'N3foo12BarExceptionE'\n    >>> cxxfilt.demangle('N3foo12BarExceptionE', external_only=False)\n    'foo::BarException'\n\nInvalid mangled names will trigger an ``InvalidName`` exception::\n\n    >>> cxxfilt.demangle('_ZQQ')\n    Traceback (most recent call last):\n      File \"<stdin>\", line 1, in <module>\n      File \"/path/to/python-cxxfilt/cxxfilt/__init__.py\", line 77, in demangle\n        return demangleb(mangled_name.encode()).decode()\n      File \"/path/to/python-cxxfilt/cxxfilt/__init__.py\", line 69, in demangleb\n        raise InvalidName(mangled_name)\n    cxxfilt.InvalidName: b'_ZQQ'\n\nUse ``demangleb`` to demangle name in ``bytes``::\n\n    >>> cxxfilt.demangleb(b'_ZNSt22condition_variable_anyD2Ev')\n    b'std::condition_variable_any::~condition_variable_any()'\n\nMake custom `Demangler` objects to use specific C/C++ libraries::\n\n    >>> from ctypes.util import find_library\n    >>>\n    >>> d = cxxfilt.Demangler(find_library('c'), find_library('stdc++'))\n    >>> d\n    <Demangler libc='libc.so.6' libcxx='libstdc++.so.6'>\n    >>>\n    >>> d = cxxfilt.Demangler(find_library('c'), find_library('c++'))\n    >>> d\n    <Demangler libc='libc.so.6' libcxx='libc++.so.1'>\n    >>> d.demangle('_ZNSt22condition_variable_anyD2Ev')\n    'std::condition_variable_any::~condition_variable_any()'\n\nSupported environments\n----------------------\n\nPython 3.6 or greater.\n\nTested on Linux and macOS (see github actions). Should work on unix systems with libc and libc++/libstdc++.\n\nWill not work on Windows (PR welcome though).\n\nFor Python 2.7 please use cxxfilt version < 0.3.\n\nChangelog\n---------\n\n0.3.0\n~~~~~\n\n*   Added ``Demangler`` class.\n\n*   ``import cxxfilt`` no longer fails when there are no C/C++ libraries available.\n    To check whether the default demangler is valid,\n    use the expression: ``not isinstance(cxxfilt.default_demangler, cxxfilt.DeferedErrorDemangler)``.\n\n\nTesting\n-------\n\nrun in shell::\n\n    pytest\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Python interface to c++filt / abi::__cxa_demangle",
    "version": "0.3.0",
    "split_keywords": [
        "c++",
        "c++filt",
        "name",
        "mangling"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c2923572dc59bf4a3984fe3c5fc242f73be916785ee93387dd95c972dbf584e",
                "md5": "aa14c9c709185a55fe6923c6d441a09d",
                "sha256": "774e85a8d0157775ed43276d89397d924b104135762d86b3a95f81f203094e07"
            },
            "downloads": -1,
            "filename": "cxxfilt-0.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa14c9c709185a55fe6923c6d441a09d",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 4649,
            "upload_time": "2021-08-21T16:48:02",
            "upload_time_iso_8601": "2021-08-21T16:48:02.953438Z",
            "url": "https://files.pythonhosted.org/packages/1c/29/23572dc59bf4a3984fe3c5fc242f73be916785ee93387dd95c972dbf584e/cxxfilt-0.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7dc71ac606f7dfa71d49e3dc126b49b18daefaf6bd953078858af30fde40702",
                "md5": "dbf5adaa4c1f34899b5df7be7286cc74",
                "sha256": "7df6464ba5e8efbf0d8974c0b2c78b32546676f06059a83515dbdfa559b34214"
            },
            "downloads": -1,
            "filename": "cxxfilt-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "dbf5adaa4c1f34899b5df7be7286cc74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4806,
            "upload_time": "2021-08-21T16:48:04",
            "upload_time_iso_8601": "2021-08-21T16:48:04.038766Z",
            "url": "https://files.pythonhosted.org/packages/d7/dc/71ac606f7dfa71d49e3dc126b49b18daefaf6bd953078858af30fde40702/cxxfilt-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-08-21 16:48:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "afq984",
    "github_project": "python-cxxfilt",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cxxfilt"
}
        
Elapsed time: 0.56654s