[Lldb-commits] [lldb] [LLDB] Handle i686 mingw32 mangling prefix (PR #160930)

Martin Storsjö via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 30 02:36:50 PDT 2025


mstorsjo wrote:

> > Exactly. The extra underscore prefix on i386 isn't mingw specific either, it's on MSVC as well - for regular C symbols. For other calling conventions (like fastcall or vectorcall) the prefix is different though, and for MSVC C++ mangled symbols, there's a different prefix. But Itanium C++ ABI on i386 works through the regular (cdecl) mangling, which adds a `_` prefix, just like all regular plain C functions.
> 
> Ah, thank you for the clarification. Looking at [MS' docs](https://learn.microsoft.com/en-us/cpp/build/reference/decorated-names?view=msvc-170#FormatC), I think we should instead have some preprocessing function in the PDB plugin that strips the C mangling to then pass the potentially mangled name to `Mangled`. For example, on non-64bit, `_CFuncParamStdCall at 4` would be stripped to `CFuncParamStdCall` and then passed to `Mangled`. Similarly, the leading underscore of `__RNvCsj4CZ6flxxfE_7___rustc12___rust_alloc` would be removed. Does this sound reasonable? If so, I'd close this PR and implement this when relanding #149701.

Hmm. I'm unsure which way it is best to do the layering here.

I think we should be able to look at `llvm/lib/Demangle` for inspiration as well.

The suggested layering, which demangles cdecl, `_cdeclfunc` into `cdeclfunc` and stdcall `_CFuncParamStdCall at 4` into `CFuncParamStdCall` before doing other C++ demangling (itanium or MS C++ ABI demangling) doesn't fit entirely right wrt the MS C++ ABI, because those symbols don't have either of the cdecl or stdcall decorations, as the MS C++ ABI mangling is on the same level there (there's no extra underscore prefix on them).

I think it's plausible that `llvm/lib/Demangle` also just accepts `__Z` as itanium prefix - which I presume that this PR does (I haven't had time to look at the code yet).

https://github.com/llvm/llvm-project/pull/160930


More information about the lldb-commits mailing list