[Lldb-commits] [PATCH] D145940: [lldb] Add test for unavailable registers

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 22 02:42:27 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb78886246da: [lldb] Add test for unavailable registers (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145940/new/

https://reviews.llvm.org/D145940

Files:
  lldb/test/API/commands/register/register/TestRegistersUnavailable.py


Index: lldb/test/API/commands/register/register/TestRegistersUnavailable.py
===================================================================
--- /dev/null
+++ lldb/test/API/commands/register/register/TestRegistersUnavailable.py
@@ -0,0 +1,53 @@
+""" Check that unavailable registers are reported when reading register sets."""
+
+from textwrap import dedent
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase
+
+class MyResponder(MockGDBServerResponder):
+    def readRegisters(self):
+        return "E01"
+
+    def readRegister(self, regnum):
+        if regnum in [0, 1, 2]:
+            return "E01"
+        return "5555555555555555"
+
+    def qHostInfo(self):
+        # The triple is hex encoded ASCII "x86_64-linux-gnu".
+        return "triple:7838365F36342D6C696E75782D676E75;"
+
+class TestRegistersUnavailable(GDBRemoteTestBase):
+    @skipIfRemote
+    # So that we have multiple register sets.
+    @skipIfLLVMTargetMissing("X86")
+    def test_unavailable_registers(self):
+        self.server.responder = MyResponder()
+        target = self.dbg.CreateTarget('')
+
+        if self.TraceOn():
+            self.runCmd("log enable gdb-remote packets process")
+            self.addTearDownHook(
+                lambda: self.runCmd("log disable gdb-remote packets process"))
+
+        process = self.connect(target)
+        lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+                                      [lldb.eStateStopped])
+
+        # We are using a long regex pattern here to check that the indentation
+        # is correct when you have multiple register sets and they all have
+        # some missing registers.
+        self.expect("register read --all", patterns=[
+            "(?sm)^general purpose registers:\n"
+            "^\s+rdx = 0x5555555555555555\n"
+            ".*"
+            "^3 registers were unavailable.\n"
+            "\n"
+            "^supplementary registers:\n"
+            "^\s+edx = 0x55555555\n"
+            ".*"
+            "^12 registers were unavailable."
+        ])


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145940.507284.patch
Type: text/x-patch
Size: 2210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230322/e36d98b0/attachment.bin>


More information about the lldb-commits mailing list