Nerixyz wrote:

> The suggested layering, which demangles cdecl, `_cdeclfunc` into `cdeclfunc` 
> and stdcall `_CFuncParamStdCall@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).

Right, anything that starts with a question mark (~> MS C++ name) would be 
ignored. Much like in LLVM:
https://github.com/llvm/llvm-project/blob/170b5fde8fc23525049ebbde8377f59971ee9b3f/llvm/lib/IR/Mangler.cpp#L49-L50

> 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).

That's the case, and also why just checking for `__Z` isn't enough. For one, 
this doesn't play nice with Rust, which also has two underscores on i686. And 
secondly, C names are displayed incorrectly right now. For example, you'd see 
`_main` instead of `main` and a function like `void Zone()` would become 
`_Zone` and interpreted as an itanium name.

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

Currently, there's nothing that demangles these C decorated names in 
`llvm/lib/Demangle`. One thing that's a bit unfortunate is that you'd need to 
know whether the binary is 64bit or not.

I was wrong, we don't just need to do it for PDB, but also for DWARF (i.e. 
anything that creates `Mangled`). For this, we could store flags in `Mangled` 
for a Windows target and a 64 bit environment.

https://github.com/llvm/llvm-project/pull/160930
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to