#[non_exhaustive]pub struct DemangleConfig {
pub fix_namespaced_global_constructor_bug: bool,
pub fix_array_length_arg: bool,
pub demangle_global_keyed_frames: bool,
pub ellipsis_emit_space_after_comma: bool,
pub fix_extension_int: bool,
pub fix_array_in_return_position: bool,
pub fix_function_pointers_in_template_lists: bool,
}Expand description
Tweak how a symbol should be disassembled.
The constructors provide sensible defaults, so there’s usually no need to override each option.
Refer to each option to see what it does and examples.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.fix_namespaced_global_constructor_bug: boolRecreate a c++filt bug where it won’t emit the “global constructors keyed to “ prefix for a namespaced function.
This is just another c++filt compatibility setting.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_namespaced_global_constructor_bug = false;
let demangled = demangle("_GLOBAL_$I$__Q210Scenegraph10Scenegraph", &config);
assert_eq!(
demangled.as_deref(),
Ok("Scenegraph::Scenegraph::Scenegraph(void)")
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_namespaced_global_constructor_bug = true;
let demangled = demangle("_GLOBAL_$I$__Q210Scenegraph10Scenegraph", &config);
assert_eq!(
demangled.as_deref(),
Ok("global constructors keyed to Scenegraph::Scenegraph::Scenegraph(void)")
);fix_array_length_arg: boolBy default g++ subtracts 1 from the length of array arguments, thus producing a confusing mangled name.
c++filt uses this length as-is, which produces a demangled symbol that does not match the original C++ symbol.
This setting adds 1 to the length, making the demangled symbol match more accurately the real symbol.
This is just another c++filt compatibility setting.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_array_length_arg = false;
let demangled = demangle("simpler_array__FPA41_A24_Ci", &config);
assert_eq!(
demangled.as_deref(),
Ok("simpler_array(int const (*)[41][24])")
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_array_length_arg = true;
let demangled = demangle("simpler_array__FPA41_A24_Ci", &config);
assert_eq!(
demangled.as_deref(),
Ok("simpler_array(int const (*)[42][25])")
);demangle_global_keyed_frames: boolRecognize and demangle symbols prefixed by _GLOBAL_$F$.
c++filt does not recognizes this prefix, so it tries to demangle it as other mangled kinds, like functions, methods, etc.
When turned on, the symbol gets demangled the same way _GLOBAL_$I$
and _GLOBAL_$D$ are demangled, but the word “frames” is used instead
of “constructors” or “destructors”. This name is made-up based on some
usages from projects that have this symbol present.
This is just another c++filt compatibility setting.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.demangle_global_keyed_frames = false;
let demangled = demangle("_GLOBAL_$F$__7istreamiP9streambufP7ostream", &config);
assert_eq!(
demangled.as_deref(),
Ok("istream::_GLOBAL_$F$(int, streambuf *, ostream *)")
);
let demangled = demangle("_GLOBAL_$F$__default_terminate", &config);
assert!(
demangled.is_err()
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.demangle_global_keyed_frames = true;
let demangled = demangle("_GLOBAL_$F$__7istreamiP9streambufP7ostream", &config);
assert_eq!(
demangled.as_deref(),
Ok("global frames keyed to istream::istream(int, streambuf *, ostream *)")
);
let demangled = demangle("_GLOBAL_$F$__default_terminate", &config);
assert_eq!(
demangled.as_deref(),
Ok("global frames keyed to __default_terminate")
);ellipsis_emit_space_after_comma: boolEmit an space between a comma and an ellipsis (...) in the argument
list.
This is just another c++filt compatibility setting.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.ellipsis_emit_space_after_comma = false;
let demangled = demangle("Printf__7ConsolePce", &config);
assert_eq!(
demangled.as_deref(),
Ok("Console::Printf(char *,...)")
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.ellipsis_emit_space_after_comma = true;
let demangled = demangle("Printf__7ConsolePce", &config);
assert_eq!(
demangled.as_deref(),
Ok("Console::Printf(char *, ...)")
);fix_extension_int: boolIf enabled, emit __int128_t and __uint128_t types instead of
int128_t and unsigned int128_t.
The former is valid syntax in g++ for this GNU integer extension type, while the latter is the syntax used by c++filt, but not accepted by g++.
This is just another c++filt compatibility setting.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_extension_int = false;
let demangled = demangle("testing_func__FRCI80", &config);
assert_eq!(
demangled.as_deref(),
Ok("testing_func(int128_t const &)")
);
let demangled = demangle("testing_func__FRCUI80", &config);
assert_eq!(
demangled.as_deref(),
Ok("testing_func(unsigned int128_t const &)")
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_extension_int = true;
let demangled = demangle("testing_func__FRCI80", &config);
assert_eq!(
demangled.as_deref(),
Ok("testing_func(__int128_t const &)")
);
let demangled = demangle("testing_func__FRCUI80", &config);
assert_eq!(
demangled.as_deref(),
Ok("testing_func(__uint128_t const &)")
);fix_array_in_return_position: boolIf enabled, emit proper syntax for arrays as return types in templated functions.
Disabling this option make it mimic the c++filt behavior for arrays in return position, which is not valid C++ but is simpler to read.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_array_in_return_position = false;
let demangled = demangle("an_array__H1Zi_X01_PA3_f", &config);
assert_eq!(
demangled.as_deref(),
Ok("float (*)[3] an_array<int>(int)")
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_array_in_return_position = true;
let demangled = demangle("an_array__H1Zi_X01_PA3_f", &config);
assert_eq!(
demangled.as_deref(),
Ok("float (*an_array<int>(int))[3]")
);fix_function_pointers_in_template_lists: boolIf enabled, emit proper syntax for return types of function pointers in template lists.
Disabling this option make it mimic the c++filt behavior for function pointers in template lists, which is not valid C++ but is simpler to read.
The c++filt behavior also omits the return type of the function pointer while this option does explicitly shows it.
§Examples
Turning off this setting (mimicking c++filt behavior):
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_function_pointers_in_template_lists = false;
let demangled = demangle("alloc__t5Table1PFUi_Pv16DefaultFunc__FUiUi", &config);
assert_eq!(
demangled.as_deref(),
Ok("Table<&DefaultFunc(unsigned int)>::alloc(unsigned int)")
);The setting turned on:
use gnuv2_demangle::{demangle, DemangleConfig};
let mut config = DemangleConfig::new();
config.fix_function_pointers_in_template_lists = true;
let demangled = demangle("alloc__t5Table1PFUi_Pv16DefaultFunc__FUiUi", &config);
assert_eq!(
demangled.as_deref(),
Ok("Table<(void *(*)(unsigned int)) &DefaultFunc>::alloc(unsigned int)")
);Implementations§
Trait Implementations§
Source§impl Clone for DemangleConfig
impl Clone for DemangleConfig
Source§fn clone(&self) -> DemangleConfig
fn clone(&self) -> DemangleConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more