[Lldb-commits] [PATCH] D145940: [lldb] Add test for unavailable registers
David Spickett via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 13 07:41:58 PDT 2023
DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
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.
Repository:
rG LLVM Github Monorepo
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,57 @@
+""" 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):
+ # Only allow reads of rip.
+ if regnum in [0, 1, 2]:
+ return "E01"
+ return "5555555555555555"
+
+ def qXferRead(self, obj, annex, offset, length):
+ if annex == "target.xml":
+ return """<?xml version="1.0"?>
+ <target version="1.0">
+ <architecture>i386:x86-64</architecture>
+ <feature name="org.gnu.gdb.i386.core">
+ <reg name="rax" bitsize="64" regnum="0" group="general"/>
+ <reg name="rbx" bitsize="64" regnum="1" group="general"/>
+ <reg name="rsi" bitsize="64" regnum="2" group="other"/>
+ <reg name="rip" bitsize="64" regnum="3" group="general" generic="pc"/>
+ </feature>
+ </target>""", False
+ else:
+ return None, False
+
+class TestRegistersUnavailable(GDBRemoteTestBase):
+ @skipIfXmlSupportMissing
+ @skipIfRemote
+ 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])
+
+ self.expect("register read --all", substrs=[
+ "general:\n"
+ " rip = 0x5555555555555555\n"
+ "2 registers were unavailable.\n"
+ "\n"
+ "other:\n"
+ "1 registers were unavailable."])
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145940.504651.patch
Type: text/x-patch
Size: 2457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230313/75c0f076/attachment.bin>
More information about the lldb-commits
mailing list