Skip to main content

Python interface to c++filt / abi::__cxa_demangle

Project description

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()'

Supported environments

Python 2.7 / 3.3+

Tested on Arch Linux and FreeBSD. Should work on unix systems with libc and libc++/libstdc++

Will not work on Windows.

Testing

run in shell:

pytest

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

cxxfilt-0.2.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cxxfilt-0.2.1-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cxxfilt-0.2.1.tar.gz.

File metadata

  • Download URL: cxxfilt-0.2.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for cxxfilt-0.2.1.tar.gz
Algorithm Hash digest
SHA256 cd5b2f7679209866f1f22251d015b7268f0e23424eb719bd7b49aebc08911973
MD5 d3738510174e4eb975dd0153541d5ed4
BLAKE2b-256 75c9cbd1aa604996d6713810af63d8fd6d51e63d02938f77b570688f358a970e

See more details on using hashes here.

File details

Details for the file cxxfilt-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: cxxfilt-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for cxxfilt-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d846472835a02bc144e3c7630677102a46d25cb52bc4fbeac12183098fd475b9
MD5 0a816450ddd0148044aa2e59d8d6da8d
BLAKE2b-256 b9d95cb1e86e11adbca3fc521601a3630cee194595a26adb0f961acac493b791

See more details on using hashes here.

Supported by

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