This allows minidump process ABI to match the PE/COFF file ABI.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This dual environment thing is tricky.. MSVC is probably a better default, but it would still mean that the same bugs will appear if the situation is reversed (we assume MSVC environ, but the binary actually uses GNU). Have you looked at how this interacts with https://reviews.llvm.org/D127048 (and the setting introduced there) and whether you can achieve the same effect by changing that setting?
Add settings set plugin.process.minidump.abi msvc/gnu to override minidump abi triple.
Adding a new setting isn't exactly what I had in mind. I was actually hoping that it would be enough to fiddle with that setting and leave the minidump environment blank (because we have code to fill in the missing pieces of a target ArchSpec from other sources.
If that doesn't work then (besides knowing why), I'd like us try some kind of a single-setting solution, as I don't think it makes sense to have two different settings like this (happy to hear counterarguments to that). I'd consider either moving that environment setting to some place more generic (so it can be accessed from both plugins) or just having the minidump plugin fetch the setting from inside ObjectFilePECOFF (I'd say that a process->object dependency is kinda OK, and we already have ProcessMachCore depending on ObjectFileMachO).
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp | ||
---|---|---|
393 | Is "overrides" the correct word here? Are there any circumstances in which we are able to determine the environment from the minidump file? Because if it is, then I would expect this to be the other way around (that the environment from a specific file overrides the generic catch-all setting)... |
Overall, the ideal is if the user usually needs to twiddle one single setting. For a majority of cases, picking the default format (like is done for the objectfile setting, and afaik this one does too even though I didn't quite clearly see the codepath for it) will be what you'd want: If you're working with mingw tools, debugging with a mingw built lldb, then your app that you're debugging also probably uses mingw ABIs. But it's clearly not implausible to want to debug executables from the other ecosystem, so being able to change it with a single setting is good too.
And for the objectfile setting, it's possible to set it even on a per-DLL basis. This may sound contrieved, but it's actually totally reasonable. While the C++ ABIs are incompatible, such DLLs can interoperate over C APIs - this is not an uncommon scenario. Plus, every mingw executable links against msvcrt.dll or ucrtbase.dll (provided by the system) which use the MSVC C++ ABIs internally (if you use the versions of them with debug info).
So the ability to set it per DLL for the objectfile part is totally warranted. How that fits in towards minidump reading, I don't really know though (since the whole minidump contains stuff for the whole process). In which cases does the C++ ABI form matter for the minidump btw - since the actual interpretation of things still would be based on per-DLL debug info (either as DWARF or PDB)?
lldb creates AST for user input expression which uses the abi from minidump process. That AST's class layout info is imported from another AST created from debug info that uses the abi specified in debug info. The current situation is that minidump process uses itanium ABI (because it's not specified in minidump, falls back to use itanium), but the debug info uses msvc ABI. The inconsistent causes crash when lowering class.
It looks like it's impossible to make it works with DLLs that have different ABIs, no matter which ABI we set for minidump. Unless we change how clang interacts with external layout: https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/RecordLayoutBuilder.cpp#L1357. Maybe change it so that if using external layout failed due to mismatched ABI, try again with another ABI https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/RecordLayoutBuilder.cpp#L3302?
Or maybe for now, we should just choose the default ABI for windows minidump to be MSVC to at least to prevent that crash happening in our case. That's what I did in first diff.
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp | ||
---|---|---|
393 | Yeah, the word is not correct. It should be "sets". |
I think the module spec of the modules should reflect the value of the plugin.object-file.pe-coff.abi setting. Can ProcessMinidump take the module spec of the executable module to use its target environment?
Mixing MSVC and MinGW DLLs is a tricky case so I will not be surprised if something doesn't work correctly. It would be nice to have it working but that would be outside the scope of this review. (I don't yet have a use case for this but I am getting close with some COM / WinRT experiments.)
That's kinda what Target::MergeArchitecture is for.
Mixing MSVC and MinGW DLLs is a tricky case so I will not be surprised if something doesn't work correctly. It would be nice to have it working but that would be outside the scope of this review. (I don't yet have a use case for this but I am getting close with some COM / WinRT experiments.)
Sounds fun. :)
Did you look at the Target::MergeArchitecture function? Is there a suitable place where we could insert a call to that function so that the executable object file environment is automatically propagated to the target?
lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml | ||
---|---|---|
74 ↗ | (On Diff #477008) | Processor Arch is X86, so this should be i386. |
Is "overrides" the correct word here? Are there any circumstances in which we are able to determine the environment from the minidump file? Because if it is, then I would expect this to be the other way around (that the environment from a specific file overrides the generic catch-all setting)...