#demangle #symbolicate #c-plus-plus #cpp

cplus_demangle

Rust wrapper for GNU libiberty’s cplus_demangle to demangle C++ symbols

3 releases

0.1.2 Apr 5, 2022
0.1.1 Sep 16, 2020
0.1.0 Sep 16, 2020

#147 in Debugging

MIT/Apache

7KB
86 lines

cplus_demangle

cplus_demangle

crates.io docs.rs

This library converts C++ mangled symbol names to human-readable strings. It is a safe Rust wrapper to GNU libiberty's C function cplus_demangle. I found it much faster and more robust than other Rust-native implementations that I found.

Example

Suppose you compile the following C++ program:

namespace test {
  void myfn(int x) { }
}

In the resulting binary, the symbol that gets generated for myfn is _ZN4test4myfnEi. We can convert it back with this Rust code:

assert_eq!(cplus_demangle::demangle("_ZN4test4myfnEi").unwrap(), "test::myfn(int)");

lib.rs:

cplus_demangle

crates.io docs.rs

This library converts C++ mangled symbol names to human-readable strings. It is a safe Rust wrapper to GNU libiberty's C function cplus_demangle.

Example

Suppose you compile the following C++ program:

namespace test {
  void myfn(int x) { }
}

In the resulting binary, the symbol that gets generated for myfn is _ZN4test4myfnEi. We can convert it back with this Rust code:

assert_eq!(cplus_demangle::demangle("_ZN4test4myfnEi").unwrap(), "test::myfn(int)");

Dependencies

~175KB