[lldb] Always use APFloat for FP dumping
authorPavel Labath <pavel@labath.sk>
Thu, 14 Jul 2022 10:49:35 +0000 (12:49 +0200)
committerPavel Labath <pavel@labath.sk>
Wed, 27 Jul 2022 12:30:35 +0000 (14:30 +0200)
commit1400a3cb8d53c8c10e23ecdd4f241ea9cff404b5
tree101bc938c7a464ab047e3130f32f131503a8320a
parentdde3cf2e83d2a2aec5b46bdac64efbc28a3b2b20
[lldb] Always use APFloat for FP dumping

The DumpDataExtractor function had two branches for printing floating
point values. One branch (APFloat) was used if we had a Target object
around and could query it for the appropriate semantics. If we didn't
have a Target, we used host operations to read and format the value.

This patch changes second path to use APFloat as well. To make it work,
I pick reasonable defaults for different byte size. Notably, I did not
include x87 long double in that list (as it is ambibuous and
architecture-specific). This exposed a bug where we were printing
register values using the target-less branch, even though the registers
definitely belong to a target, and we had it available. Fixing this
prompted the update of several tests for register values due to slightly
different floating point outputs.

The most dubious aspect of this patch is the change in
TypeSystemClang::GetFloatTypeSemantics to recognize `10` as a valid size
for x87 long double. This was necessary because because sizeof(long
double) on x86_64 is 16 even though it only holds 10 bytes of useful
data. This generalizes the hackaround present in the target-free branch
of the dumping function.

Differential Revision: https://reviews.llvm.org/D129750
lldb/include/lldb/Core/DumpRegisterValue.h
lldb/source/Commands/CommandObjectRegister.cpp
lldb/source/Core/DumpDataExtractor.cpp
lldb/source/Core/DumpRegisterValue.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
lldb/unittests/Core/DumpDataExtractorTest.cpp