From 4e8aeb97ca41eb202c9c90a9c640a630903c769b Mon Sep 17 00:00:00 2001 From: Muhammad Omair Javaid Date: Thu, 26 Nov 2020 12:55:29 +0500 Subject: [PATCH] Send SVE vg register in custom expedited registerset This patch ovverides GetExpeditedRegisterSet for NativeRegisterContextLinux_arm64 to send vector granule register in expedited register set if SVE mode is selected. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D82855 --- .../test/tools/lldb-server/gdbremote_testcase.py | 7 +++++ .../Linux/NativeRegisterContextLinux_arm64.cpp | 10 +++++++ .../Linux/NativeRegisterContextLinux_arm64.h | 3 ++ .../Process/Utility/RegisterInfoPOSIX_arm64.cpp | 2 ++ .../Process/Utility/RegisterInfoPOSIX_arm64.h | 1 + .../lldb-server/TestGdbRemoteExpeditedRegisters.py | 34 ++++++++++++++++++++-- 6 files changed, 55 insertions(+), 2 deletions(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py index ce700d9..a1c420d 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -992,6 +992,13 @@ class GdbRemoteTestCaseBase(TestBase): return reg_info return None + def find_register_with_name_and_dwarf_regnum(self, reg_infos, name, dwarf_num): + self.assertIsNotNone(reg_infos) + for reg_info in reg_infos: + if (reg_info["name"] == name) and (reg_info["dwarf"] == dwarf_num): + return reg_info + return None + def decode_gdbremote_binary(self, encoded_bytes): decoded_bytes = "" i = 0 diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp index 1fa87e1..49badd8 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp @@ -1125,4 +1125,14 @@ void *NativeRegisterContextLinux_arm64::GetSVEBuffer() { return m_sve_ptrace_payload.data(); } +std::vector NativeRegisterContextLinux_arm64::GetExpeditedRegisters( + ExpeditedRegs expType) const { + std::vector expedited_reg_nums = + NativeRegisterContext::GetExpeditedRegisters(expType); + if (m_sve_state == SVEState::FPSIMD || m_sve_state == SVEState::Full) + expedited_reg_nums.push_back(GetRegisterInfo().GetRegNumSVEVG()); + + return expedited_reg_nums; +} + #endif // defined (__arm64__) || defined (__aarch64__) diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h index da45f1c..3d0656d 100644 --- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h +++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h @@ -44,6 +44,9 @@ public: void InvalidateAllRegisters() override; + std::vector + GetExpeditedRegisters(ExpeditedRegs expType) const override; + // Hardware breakpoints/watchpoint management functions uint32_t NumSupportedHardwareBreakpoints() override; diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp index 701c88c..515c9f4 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp @@ -342,3 +342,5 @@ uint32_t RegisterInfoPOSIX_arm64::GetRegNumSVEFFR() const { return sve_ffr; } uint32_t RegisterInfoPOSIX_arm64::GetRegNumFPCR() const { return fpu_fpcr; } uint32_t RegisterInfoPOSIX_arm64::GetRegNumFPSR() const { return fpu_fpsr; } + +uint32_t RegisterInfoPOSIX_arm64::GetRegNumSVEVG() const { return sve_vg; } diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h index d5eaf4c..37f7c23 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h +++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h @@ -101,6 +101,7 @@ public: uint32_t GetRegNumSVEFFR() const; uint32_t GetRegNumFPCR() const; uint32_t GetRegNumFPSR() const; + uint32_t GetRegNumSVEVG() const; private: typedef std::map> diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py index f74143a..a6bca74 100644 --- a/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py +++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteExpeditedRegisters.py @@ -8,8 +8,8 @@ class TestGdbRemoteExpeditedRegisters( gdbremote_testcase.GdbRemoteTestCaseBase): mydir = TestBase.compute_mydir(__file__) - @skipIfDarwinEmbedded # lldb-server tests not updated to work on ios etc yet - + # lldb-server tests not updated to work on ios etc yet + @skipIfDarwinEmbedded def gather_expedited_registers(self): # Setup the stub and set the gdb remote command stream. procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:2"]) @@ -58,6 +58,25 @@ class TestGdbRemoteExpeditedRegisters( self.assertTrue(reg_info["lldb_register_index"] in expedited_registers) self.trace("{} reg_info:{}".format(generic_register_name, reg_info)) + def stop_notification_contains_aarch64_vg_register(self): + # Generate a stop reply, parse out expedited registers from stop + # notification. + expedited_registers = self.gather_expedited_registers() + self.assertIsNotNone(expedited_registers) + self.assertTrue(len(expedited_registers) > 0) + + # Gather target register infos. + reg_infos = self.gather_register_infos() + + # Find the vg register. + reg_info = self.find_register_with_name_and_dwarf_regnum( + reg_infos, 'vg', '46') + self.assertIsNotNone(reg_info) + + # Ensure the expedited registers contained it. + self.assertTrue(reg_info["lldb_register_index"] in expedited_registers) + self.trace("{} reg_info:{}".format('vg', reg_info)) + def stop_notification_contains_any_registers(self): # Generate a stop reply, parse out expedited registers from stop # notification. @@ -157,3 +176,14 @@ class TestGdbRemoteExpeditedRegisters( self.build() self.set_inferior_startup_launch() self.stop_notification_contains_sp_register() + + @llgs_test + @skipIf(archs=no_match(["aarch64"])) + @skipIf(oslist=no_match(['linux'])) + def test_stop_notification_contains_vg_register_llgs(self): + if not self.isAArch64SVE(): + self.skipTest('SVE registers must be supported.') + self.init_llgs_test() + self.build() + self.set_inferior_startup_launch() + self.stop_notification_contains_aarch64_vg_register() -- 2.7.4