From a228c46c2a1ec209ec1cc67ba2a58f8df4150668 Mon Sep 17 00:00:00 2001 From: Dimitar Vlahovski Date: Sun, 20 Nov 2016 21:24:49 +0000 Subject: [PATCH] ELF core: Adding parsing of the floating-point and SSE registers on x86 32/64 bit elf core files Summary: The floating-point and SSE registers could be present in the elf-core file in the note NT_FPREGSET for 64 bit ones, and in the note NT_PRXFPREG for 32 bit ones. The entire note is a binary blob matching the layout of the x87 save area that gets generated by the FXSAVE instruction (see Intel developers manual for more information). This CL mainly modifies the RegisterRead function in RegisterContextPOSIXCore_x86_64 for it to return the correct data both for GPR and FPR/SSE registers, and return false (meaning "this register is not available") for other registers. I added a test to TestElfCore.py that tests reading FPR/SSE registers both from a 32 and 64 bit elf-core file and I have inluded the source which I used to generate the core files. I tried to also add support for the AVX registers, because this info could also be present in the elf-core file (note NT_X86_XSTATE - that is the result of the newer XSAVE instruction). Parsing the contents from the file is easy. The problem is that the ymm registers are split into two halves and they are in different places in the note. For making this work one would either make a "hacky" approach, because there won't be any other way with the current state of the register contexts - they assume that "this register is of size N and at offset M" and don't have the notion of discontinuos registers. Reviewers: labath Subscribers: emaste, lldb-commits Differential Revision: https://reviews.llvm.org/D26300 llvm-svn: 287506 --- .../postmortem/elf-core/TestLinuxCore.py | 50 +++++++++++++++++++ .../postmortem/elf-core/fpr_sse.cpp | 38 +++++++++++++++ .../postmortem/elf-core/linux-fpr_sse_i386.core | Bin 0 -> 32768 bytes .../postmortem/elf-core/linux-fpr_sse_x86_64.core | Bin 0 -> 40960 bytes .../Process/Utility/RegisterContextLinux_i386.cpp | 4 ++ .../Process/Utility/RegisterContextLinux_i386.h | 2 + .../Utility/RegisterContextLinux_x86_64.cpp | 5 ++ .../Process/Utility/RegisterContextLinux_x86_64.h | 2 + .../Process/Utility/RegisterContextPOSIX_x86.cpp | 4 ++ .../Process/Utility/RegisterContextPOSIX_x86.h | 2 + .../Process/Utility/RegisterInfoInterface.h | 2 + .../Plugins/Process/elf-core/ProcessElfCore.cpp | 14 +++++- .../elf-core/RegisterContextPOSIXCore_x86_64.cpp | 53 ++++++++++++++------- .../elf-core/RegisterContextPOSIXCore_x86_64.h | 5 +- 14 files changed, 160 insertions(+), 21 deletions(-) create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_i386.core create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_x86_64.core diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py index 4254209..ed46ef1 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -104,6 +104,56 @@ class LinuxCoreTestCase(TestBase): # same pid self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions) + @skipIf(oslist=['windows']) + @skipIf(triple='^mips') + def test_FPR_SSE(self): + # check x86_64 core file + target = self.dbg.CreateTarget(None) + self.assertTrue(target, VALID_TARGET) + process = target.LoadCore("linux-fpr_sse_x86_64.core") + + values = {} + values["fctrl"] = "0x037f" + values["fstat"] = "0x0000" + values["ftag"] = "0xff" + values["fop"] = "0x0000" + values["fiseg"] = "0x00000000" + values["fioff"] = "0x0040011e" + values["foseg"] = "0x00000000" + values["fooff"] = "0x00000000" + values["mxcsr"] = "0x00001f80" + values["mxcsrmask"] = "0x0000ffff" + values["st0"] = "{0x99 0xf7 0xcf 0xfb 0x84 0x9a 0x20 0x9a 0xfd 0x3f}" + values["st1"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x3f}" + values["st2"] = "{0xfe 0x8a 0x1b 0xcd 0x4b 0x78 0x9a 0xd4 0x00 0x40}" + values["st3"] = "{0xac 0x79 0xcf 0xd1 0xf7 0x17 0x72 0xb1 0xfe 0x3f}" + values["st4"] = "{0xbc 0xf0 0x17 0x5c 0x29 0x3b 0xaa 0xb8 0xff 0x3f}" + values["st5"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80 0xff 0x3f}" + values["st6"] = "{0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}" + values["st7"] = "{0x35 0xc2 0x68 0x21 0xa2 0xda 0x0f 0xc9 0x00 0x40}" + values["xmm0"] = "{0x29 0x31 0x64 0x46 0x29 0x31 0x64 0x46 0x29 0x31 0x64 0x46 0x29 0x31 0x64 0x46}" + values["xmm1"] = "{0x9c 0xed 0x86 0x64 0x9c 0xed 0x86 0x64 0x9c 0xed 0x86 0x64 0x9c 0xed 0x86 0x64}" + values["xmm2"] = "{0x07 0xc2 0x1f 0xd7 0x07 0xc2 0x1f 0xd7 0x07 0xc2 0x1f 0xd7 0x07 0xc2 0x1f 0xd7}" + values["xmm3"] = "{0xa2 0x20 0x48 0x25 0xa2 0x20 0x48 0x25 0xa2 0x20 0x48 0x25 0xa2 0x20 0x48 0x25}" + values["xmm4"] = "{0xeb 0x5a 0xa8 0xc4 0xeb 0x5a 0xa8 0xc4 0xeb 0x5a 0xa8 0xc4 0xeb 0x5a 0xa8 0xc4}" + values["xmm5"] = "{0x49 0x41 0x20 0x0b 0x49 0x41 0x20 0x0b 0x49 0x41 0x20 0x0b 0x49 0x41 0x20 0x0b}" + values["xmm6"] = "{0xf8 0xf1 0x8b 0x4f 0xf8 0xf1 0x8b 0x4f 0xf8 0xf1 0x8b 0x4f 0xf8 0xf1 0x8b 0x4f}" + values["xmm7"] = "{0x13 0xf1 0x30 0xcd 0x13 0xf1 0x30 0xcd 0x13 0xf1 0x30 0xcd 0x13 0xf1 0x30 0xcd}" + + for regname, value in values.iteritems(): + self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)]) + + + # now check i386 core file + target = self.dbg.CreateTarget(None) + self.assertTrue(target, VALID_TARGET) + process = target.LoadCore("linux-fpr_sse_i386.core") + + values["fioff"] = "0x080480cc" + + for regname, value in values.iteritems(): + self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)]) + def check_memory_regions(self, process, region_count): region_list = process.GetMemoryRegions() self.assertEqual(region_list.GetSize(), region_count) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp new file mode 100644 index 0000000..e6826fc --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/fpr_sse.cpp @@ -0,0 +1,38 @@ +// fpr_sse_x86_64.core was generated with: +// ./make-core.sh fpr_sse.cpp +// +// fpr_sse_i386.core was generated with: +// export CFLAGS=-m32 +// ./make-core.sh fpr_sse.cpp + +void _start(void) { + __asm__("fldpi;" + "fldz;" + "fld1;" + "fldl2e;" + "fldln2;" + "fldl2t;" + "fld1;" + "fldlg2;"); + + unsigned int values[8] = { + 0x46643129, 0x6486ed9c, 0xd71fc207, 0x254820a2, + 0xc4a85aeb, 0x0b204149, 0x4f8bf1f8, 0xcd30f113, + }; + + __asm__("vbroadcastss %0, %%xmm0;" + "vbroadcastss %1, %%xmm1;" + "vbroadcastss %2, %%xmm2;" + "vbroadcastss %3, %%xmm3;" + "vbroadcastss %4, %%xmm4;" + "vbroadcastss %5, %%xmm5;" + "vbroadcastss %6, %%xmm6;" + "vbroadcastss %7, %%xmm7;" + + ::"m"(values[0]), + "m"(values[1]), "m"(values[2]), "m"(values[3]), "m"(values[4]), + "m"(values[5]), "m"(values[6]), "m"(values[7])); + + volatile int *a = 0; + *a = 0; +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_i386.core b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_i386.core new file mode 100644 index 0000000000000000000000000000000000000000..b0fdaf67ca4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%C+U6 zsy>&2pDI6=%b=68puDa^!OrkNZ`-zC|0H(h@Lp->xB5d}!2!GrgPlISm$I(huz+u= z#v3JF(A z$fn{#%NCcE%($F^Hoi8WijTSK8k(Co$((BN9_8|D4X>1~fsSx{08f0EC`DXj(HK!J zbF77F(UXB~!QQ^G>WGh7a7xb>e}guX#4nZ7`?W>xbRs_J+JjHh?h!_WT90$H(_Nd+ zh^al%y|qFz+UV6;${ovTHD$RhY6Y@N5zD19d_g9s-chc1wIZ$DYO%kuU!l*X^VtZ# zh>K6@2&p(em5Y11xQ_Pj@J_sFv1AB$^|twgv~G}xgxf#0qcvxM+fk=FgIQCE7oXi(Lan?LBwiGt+D zqOWUvm(PPAvZZC!qJXCLs5BhU)#AUXn8}I}{I+$JYuno8?-=mW_m$A^U?-0Y23Cc2 z(G6WY(h2&Ck*gciSWF61JR-Q7oo=qHw`1{yrlm5Q)T%4moNB)-G*B)jo-K%JQnv_$ z_`Z=4k$m#Bjt=H?wYflh&yHXybFY6>ERSbq^X7UX;%*YXjgf}IMo&a+7MdCxqk|1i zb#>l)tT^fR7(~B1_q7KTo7c)LQXf_+d|_HYtrWH1M9(LqNf+0J^?Pq0-{U*rke>iF zZxUiImx*UY$89;TqxZcZ9I-TqalUHol{K?mr3s7kox%3rZhxT17f<5b)TyC(jB5`J z^mX}n`C8m^=lVmKgEY*6{zcDeYCn8ctP>z@q5gi_im>t6S=**Qpyg#Wnp+UG)Wx>0 z-T`%fE$Sh4Qgc*xLql19R)|0e3x9gj>z@%j{dmFj_6LHyu6|TFcM5rYz&jh4_Tk&x dSgFhVlo*XqEp1lf_=NZS_N6cOL2z|v`rj!?IVAu9 literal 0 HcmV?d00001 diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_x86_64.core b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-fpr_sse_x86_64.core new file mode 100644 index 0000000000000000000000000000000000000000..5fb39ee115b2a6fbf04dbfddf5e78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$4&b~LD#3Nu#Uvr~&O{XWBXcV5VOpJ)DvJ6jU{z=YIV1=y8lIS-TT41r0(B`6$u?T`SM3D zh8~rl+YD;s2Owd)+7&fQpCjrXzIXqRH#uBs14uf36*7uJcV>o(64yZoBxSeJ291e)n6u%)TA(UMZe9 zD(*O0;a>zpVnwC6^&QjJn~6^)v$ZFm-Q^zn0LJWjkW7Z`GdN^lEezQgPaU#OP$gaV zsBXv}@EOM3`LfA|>{aTJ?SUcNI?tE;58uIG=>>&rdu%eS&2+o~V3 zS)4)Wko_*$=|=1`Y{Zs**ob`;GJsyY&u=(RM=Z>O$7YS@%TF$V)?8ek2L+f9ZwHc} zdnZP4R`jWTbNqFr*pG|nBbbVyTXds#(^y&(5$^rRw%HGiuTTv~$NSX&dhjSze0(NE zOjY^vA+UfaMtK_P(kb@s<6+R>wgzifKE4w8w@0Br{tn(Y$XIbh2Tnr=2E~<-#lV1t zjgLO)zu>}~pb0Ap#R&a!_0CZ(jJTR0$$;HnS^NY(k4?tCV53aS?OBM8oU4G|p_K0! zpOKqo-@bY$9mhC2U--xOCMKQ-lj{Vd@e$yk0X_}D&Bft^(j3EHye=i^ZpRq>g)#V6K1YrEv<4!>S{O4VQBft^h N2yg^A0-qfO{uj~x1?K<& literal 0 HcmV?d00001 diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp index 6563796..2eebadd 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp @@ -111,6 +111,10 @@ RegisterContextLinux_i386::RegisterContextLinux_i386( size_t RegisterContextLinux_i386::GetGPRSize() const { return sizeof(GPR); } +size_t RegisterContextLinux_i386::GetFXSAVEOffset() const { + return (LLVM_EXTENSION offsetof(UserArea, i387)); +} + const RegisterInfo *RegisterContextLinux_i386::GetRegisterInfo() const { switch (m_target_arch.GetMachine()) { case llvm::Triple::x86: diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h index fbf8037..bb6707b 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h @@ -18,6 +18,8 @@ public: size_t GetGPRSize() const override; + size_t GetFXSAVEOffset() const override; + const lldb_private::RegisterInfo *GetRegisterInfo() const override; uint32_t GetRegisterCount() const override; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp index 526b3ec..6f4bb80 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp @@ -179,6 +179,11 @@ RegisterContextLinux_x86_64::RegisterContextLinux_x86_64( size_t RegisterContextLinux_x86_64::GetGPRSize() const { return sizeof(GPR); } +size_t RegisterContextLinux_x86_64::GetFXSAVEOffset() const { + return (LLVM_EXTENSION offsetof(UserArea, fpr) + + LLVM_EXTENSION offsetof(FPR, xstate)); +} + const std::vector * RegisterContextLinux_x86_64::GetDynamicRegisterInfoP() const { return &d_register_infos; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h index 99a4cb7..e9e3e8b 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h @@ -18,6 +18,8 @@ public: size_t GetGPRSize() const override; + size_t GetFXSAVEOffset() const override; + const lldb_private::RegisterInfo *GetRegisterInfo() const override; uint32_t GetRegisterCount() const override; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp index 77f3fcb..d6f67cb 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -419,6 +419,10 @@ size_t RegisterContextPOSIX_x86::GetGPRSize() { return m_register_info_ap->GetGPRSize(); } +size_t RegisterContextPOSIX_x86::GetFXSAVEOffset() { + return m_register_info_ap->GetFXSAVEOffset(); +} + const RegisterInfo *RegisterContextPOSIX_x86::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and // specialized. diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h index 22f3493..c5afe08 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h @@ -38,6 +38,8 @@ public: virtual size_t GetGPRSize(); + virtual size_t GetFXSAVEOffset(); + virtual unsigned GetRegisterSize(unsigned reg); virtual unsigned GetRegisterOffset(unsigned reg); diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h b/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h index 12db366..a077640 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h @@ -29,6 +29,8 @@ public: virtual size_t GetGPRSize() const = 0; + virtual size_t GetFXSAVEOffset() const { return 0; } + virtual const lldb_private::RegisterInfo *GetRegisterInfo() const = 0; // Returns the number of registers including the user registers and the diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index 840a792..f03f8db 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -400,7 +400,8 @@ enum { NT_TASKSTRUCT, NT_PLATFORM, NT_AUXV, - NT_FILE = 0x46494c45 + NT_FILE = 0x46494c45, + NT_PRXFPREG = 0x46e62b7f, }; namespace FREEBSD { @@ -552,7 +553,11 @@ Error ProcessElfCore::ParseThreadContextsFromNoteSegment( thread_data->gpregset = DataExtractor(note_data, header_size, len); break; case NT_FPREGSET: - thread_data->fpregset = note_data; + // In a i386 core file NT_FPREGSET is present, but it's not the result + // of the FXSAVE instruction like in 64 bit files. + // The result from FXSAVE is in NT_PRXFPREG for i386 core files + if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64) + thread_data->fpregset = note_data; break; case NT_PRPSINFO: have_prpsinfo = true; @@ -586,6 +591,11 @@ Error ProcessElfCore::ParseThreadContextsFromNoteSegment( default: break; } + } else if (note.n_name == "LINUX") { + switch (note.n_type) { + case NT_PRXFPREG: + thread_data->fpregset = note_data; + } } offset += note_size; diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp index 8157401..b0148c2 100644 --- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp @@ -21,18 +21,27 @@ RegisterContextCorePOSIX_x86_64::RegisterContextCorePOSIX_x86_64( size_t size, len; size = GetGPRSize(); - m_gpregset = new uint8_t[size]; - len = gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset); - assert(len == size); -} + m_gpregset.reset(new uint8_t[size]); + len = + gpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_gpregset.get()); + if (len != size) + m_gpregset.reset(); -RegisterContextCorePOSIX_x86_64::~RegisterContextCorePOSIX_x86_64() { - delete[] m_gpregset; + size = sizeof(FXSAVE); + m_fpregset.reset(new uint8_t[size]); + len = + fpregset.ExtractBytes(0, size, lldb::eByteOrderLittle, m_fpregset.get()); + if (len != size) + m_fpregset.reset(); } -bool RegisterContextCorePOSIX_x86_64::ReadGPR() { return m_gpregset != NULL; } +bool RegisterContextCorePOSIX_x86_64::ReadGPR() { + return m_gpregset != nullptr; +} -bool RegisterContextCorePOSIX_x86_64::ReadFPR() { return false; } +bool RegisterContextCorePOSIX_x86_64::ReadFPR() { + return m_fpregset != nullptr; +} bool RegisterContextCorePOSIX_x86_64::WriteGPR() { assert(0); @@ -46,15 +55,27 @@ bool RegisterContextCorePOSIX_x86_64::WriteFPR() { bool RegisterContextCorePOSIX_x86_64::ReadRegister(const RegisterInfo *reg_info, RegisterValue &value) { - switch (reg_info->byte_size) { - case 4: - value = *(uint32_t *)(m_gpregset + reg_info->byte_offset); - return true; - case 8: - value = *(uint64_t *)(m_gpregset + reg_info->byte_offset); - return true; + const uint8_t *src; + size_t offset; + const size_t fxsave_offset = reg_info->byte_offset - GetFXSAVEOffset(); + // make the offset relative to the beginning of the FXSAVE structure + // because this is the data that we have (not the entire UserArea) + + if (m_gpregset && reg_info->byte_offset < GetGPRSize()) { + src = m_gpregset.get(); + offset = reg_info->byte_offset; + } else if (m_fpregset && fxsave_offset < sizeof(FXSAVE)) { + src = m_fpregset.get(); + offset = fxsave_offset; + } else { + return false; } - return false; + + Error error; + value.SetFromMemoryData(reg_info, src + offset, reg_info->byte_size, + lldb::eByteOrderLittle, error); + + return error.Success(); } bool RegisterContextCorePOSIX_x86_64::ReadAllRegisterValues( diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h index eeb36b6..c27e091 100644 --- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h +++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h @@ -24,8 +24,6 @@ public: const lldb_private::DataExtractor &gpregset, const lldb_private::DataExtractor &fpregset); - ~RegisterContextCorePOSIX_x86_64() override; - bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value) override; @@ -48,7 +46,8 @@ protected: bool WriteFPR() override; private: - uint8_t *m_gpregset; + std::unique_ptr m_gpregset; + std::unique_ptr m_fpregset; }; #endif // liblldb_RegisterContextCorePOSIX_x86_64_h_ -- 2.7.4