Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(demangle): tweak MSVC demangling flags #640

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

mstange
Copy link
Contributor

@mstange mstange commented Jul 28, 2022

These flags create more visually pleasing results for function names
which are demangled from the MSVC mangling scheme.

Here are two examples from oleaut32.pdb A128178EA85DAE837E96C39303FF06381:

Before: SafeGetLocaleInfoPooled(struct tagDATEINFO *,unsigned long,unsigned short * *,int *)
After: SafeGetLocaleInfoPooled(tagDATEINFO*, unsigned long, unsigned short**, int*)

Before: CTypeInfo2::Invoke(void *,long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)
After: CTypeInfo2::Invoke(void*, long, unsigned short, tagDISPPARAMS*, tagVARIANT*, tagEXCEPINFO*, unsigned int*)

The flags in detail:

  • SPACE_AFTER_COMMA: Adds a space after each comma.
  • HUG_TYPE: Removes the space in front of "*" and "&".
  • NO_CLASS_TYPE: Removes "struct" / "class" / "enum" / "union" keywords from argument types.
  • NO_MS_KEYWORDS: Removes __cdecl and similar distracting keywords.

The new output is more consistent with the output that we produce for
functions which were mangled with the Itanium C++ ABI scheme, i.e. which
are going down the cpp_demangle path.
For comparison, here are two demangled functions from a macOS mozglue.dylib;
you can see that these already follow the same "space after comma", "no class/struct keyword",
"no space before *" rules:

mozilla::baseprofiler::ParseFeaturesFromStringArray(char const**, unsigned int, bool)
double_conversion::RoundUp(double_conversion::Vector<char>, int*, int*)

These flags create more visually pleasing results for function names
which are demangled from the MSVC mangling scheme.

Here's are two examples from oleaut32.pdb A128178EA85DAE837E96C39303FF06381:

Before: `SafeGetLocaleInfoPooled(struct tagDATEINFO *,unsigned long,unsigned short * *,int *)`
After: `SafeGetLocaleInfoPooled(tagDATEINFO*, unsigned long, unsigned short**, int*)`

Before: `CTypeInfo2::Invoke(void *,long,unsigned short,struct tagDISPPARAMS *,struct tagVARIANT *,struct tagEXCEPINFO *,unsigned int *)`
After: `CTypeInfo2::Invoke(void*, long, unsigned short, tagDISPPARAMS*, tagVARIANT*, tagEXCEPINFO*, unsigned int*)`

The flags in detail:

 * `SPACE_AFTER_COMMA`: Adds a space after each comma.
 * `HUG_TYPE`: Removes the space in front of "*" and "&".
 * `NO_CLASS_TYPE`: Removes "struct" / "class" / "enum" / "union" keywords from argument types.
 * `NO_MS_KEYWORDS`: Removes `__cdecl` and similar distracting keywords.

The new output is more consistent with the output that we produce for
functions which were mangled with the Itanium C++ ABI scheme, i.e. which
are going down the `cpp_demangle` path.
For comparison, here are two demangled functions from a macOS mozglue.dylib;
you can see that these already follow the same "space after comma", "no class/struct keyword",
"no space before *" rules:

`mozilla::baseprofiler::ParseFeaturesFromStringArray(char const**, unsigned int, bool)`
`double_conversion::RoundUp(double_conversion::Vector<char>, int*, int*)`
@mstange mstange requested a review from a team July 28, 2022 19:31
@codecov-commenter
Copy link

Codecov Report

Merging #640 (7ca9a3b) into master (a0360d3) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #640      +/-   ##
==========================================
- Coverage   71.20%   71.20%   -0.01%     
==========================================
  Files          96       96              
  Lines       18408    18412       +4     
==========================================
+ Hits        13108    13110       +2     
- Misses       5300     5302       +2     

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants