[Lldb-commits] [lldb] eb78886 - [lldb] Add test for unavailable registers
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 22 02:42:27 PDT 2023
Author: David Spickett
Date: 2023-03-22T09:42:21Z
New Revision: eb78886246da610bd78e4a8be82d3b820e12ee2b
URL: https://github.com/llvm/llvm-project/commit/eb78886246da610bd78e4a8be82d3b820e12ee2b
DIFF: https://github.com/llvm/llvm-project/commit/eb78886246da610bd78e4a8be82d3b820e12ee2b.diff
LOG: [lldb] Add test for unavailable registers
Prior to this the only check was that we did not print
this message when reading registers that should exist.
I thought there was an indentation bug here so I wrote a test
for it. There is not, but we could do with the coverage anyway.
Reviewed By: rupprecht
Differential Revision: https://reviews.llvm.org/D145940
Added:
lldb/test/API/commands/register/register/TestRegistersUnavailable.py
Modified:
Removed:
################################################################################
diff --git a/lldb/test/API/commands/register/register/TestRegistersUnavailable.py b/lldb/test/API/commands/register/register/TestRegistersUnavailable.py
new file mode 100644
index 0000000000000..006be849bdbb2
--- /dev/null
+++ b/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."
+ ])
More information about the lldb-commits
mailing list