Crate cpp_demangle
source ·Expand description
This crate can parse a C++ “mangled” linker symbol name into a Rust value
describing what the name refers to: a variable, a function, a virtual table,
etc. The description type implements Display
, producing human-readable
text describing the mangled name. Debuggers and profilers can use this crate
to provide more meaningful output.
C++ requires the compiler to choose names for linker symbols consistently across compilation units, so that two compilation units that have seen the same declarations can pair up definitions in one unit with references in another. Almost all platforms other than Microsoft Windows follow the Itanium C++ ABI’s rules for this.
For example, suppose a C++ compilation unit has the definition:
namespace space {
int foo(int x, int y) { return x+y; }
}
The Itanium C++ ABI specifies that the linker symbol for that function must
be named _ZN5space3fooEii
. This crate can parse that name into a Rust
value representing its structure. Formatting the value with the format!
macro or the std::string::ToString::to_string
trait method yields the
string space::foo(int, int)
, which is more meaningful to the C++
developer.
Modules§
- Abstract syntax tree types for mangled symbols.
- Custom
Error
andResult
types for thecpp_demangle
crate.
Structs§
- Options to control the demangling process.
- Options to control the parsing process.
- A mangled symbol that has been parsed into an AST.
Enums§
- The type of a demangled AST node. This is only partial, not all nodes are represented.
Traits§
- Sink for demangled text that reports syntactic structure.
Type Aliases§
- A
Symbol
which borrows the underlying storage for the mangled name. - A
Symbol
which owns the underlying storage for the mangled name.