[lldb] [Process/elf-core] Fix reading FPRs from FreeBSD/i386 cores
authorMichał Górny <mgorny@moritz.systems>
Thu, 22 Apr 2021 17:21:50 +0000 (19:21 +0200)
committerMichał Górny <mgorny@moritz.systems>
Wed, 12 May 2021 09:51:37 +0000 (11:51 +0200)
The FreeBSD coredumps from i386 systems contain only FSAVE-style
NT_FPREGSET.  Since we do not really support reading that kind of data
anymore, just use NT_X86_XSTATE to get FXSAVE-style data when available.

Differential Revision: https://reviews.llvm.org/D101086

lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
lldb/test/Shell/Register/Core/x86-32-freebsd-addr.test
lldb/test/Shell/Register/Core/x86-32-freebsd-fp.test [new file with mode: 0644]

index b048d39..ce07dfc 100644 (file)
@@ -96,6 +96,9 @@ DataExtractor getRegset(llvm::ArrayRef<CoreNote> Notes,
                         llvm::ArrayRef<RegsetDesc> RegsetDescs);
 
 constexpr RegsetDesc FPR_Desc[] = {
+    // FreeBSD/i386 core NT_FPREGSET is x87 FSAVE result but the XSAVE dump
+    // starts with FXSAVE struct, so use that instead if available.
+    {llvm::Triple::FreeBSD, llvm::Triple::x86, llvm::ELF::NT_X86_XSTATE},
     {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_FPREGSET},
     // In a i386 core file NT_FPREGSET is present, but it's not the result
     // of the FXSAVE instruction like in 64 bit files.
index c5a705f..06479a4 100644 (file)
@@ -10,4 +10,7 @@ register read --all
 # CHECK-DAG: ds = 0x0000003b
 # CHECK-DAG: es = 0x0000003b
 
-# TODO: fix reading fp registers
+# CHECK-DAG: fiseg = 0x00000000
+# CHECK-DAG: fioff = 0x00401c52
+# CHECK-DAG: foseg = 0x00000000
+# CHECK-DAG: fooff = 0xffffd8b8
diff --git a/lldb/test/Shell/Register/Core/x86-32-freebsd-fp.test b/lldb/test/Shell/Register/Core/x86-32-freebsd-fp.test
new file mode 100644 (file)
index 0000000..6001c0f
--- /dev/null
@@ -0,0 +1,3 @@
+# RUN: %lldb -b -s %s -c %p/Inputs/x86-32-freebsd.core | FileCheck %p/Inputs/x86-fp.check
+
+register read --all