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 hashes)
Built Distribution
Close
Hashes for cxxfilt-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d846472835a02bc144e3c7630677102a46d25cb52bc4fbeac12183098fd475b9 |
|
MD5 | 0a816450ddd0148044aa2e59d8d6da8d |
|
BLAKE2b-256 | b9d95cb1e86e11adbca3fc521601a3630cee194595a26adb0f961acac493b791 |