Skip to main content

cxxfilt ci

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

Metadata

Release files for cxxfilt 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cxxfilt 0.3.0
File Size Uploaded Provenance Actions
cxxfilt-0.3.0.tar.gz 4.8 kB Without provenance Details for cxxfilt-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cxxfilt 0.3.0
File Interpreter ABI Platform Actions
cxxfilt-0.3.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for cxxfilt-0.3.0-py2.py3-none-any.whl

Total release size: 9.5 kB

Release files / cxxfilt-0.3.0.tar.gz

Download URL cxxfilt-0.3.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7df6464ba5e8efbf0d8974c0b2c78b32546676f06059a83515dbdfa559b34214
BLAKE2b-256 checksum
How to use checksums
d7dc71ac606f7dfa71d49e3dc126b49b18daefaf6bd953078858af30fde40702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Release files / cxxfilt-0.3.0-py2.py3-none-any.whl

Download URL cxxfilt-0.3.0-py2.py3-none-any.whl
Size 4.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
774e85a8d0157775ed43276d89397d924b104135762d86b3a95f81f203094e07
BLAKE2b-256 checksum
How to use checksums
1c2923572dc59bf4a3984fe3c5fc242f73be916785ee93387dd95c972dbf584e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

Security for cxxfilt 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page