[Lldb-commits] [PATCH] D111496: [lldb] [test] Rewrite g/p/G/P tests not to rely on hardcoded ARM regs
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Oct 9 09:06:12 PDT 2021
mgorny created this revision.
mgorny added reviewers: labath, teemperor, jasonmolenda, krytarowski, emaste.
Herald added subscribers: omjavaid, pengfei, kristof.beyls.
mgorny requested review of this revision.
Rewrite the register reading/writing tests to use explicit qRegisterInfo
packets rather than relying on ARM registers being hardcoded in LLDB.
While at it, use x86_64 for tests -- since it was easier for me to get
the register lists from that architecture.
https://reviews.llvm.org/D111496
Files:
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
lldb/test/API/functionalities/gdb_remote_client/a.yaml
lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
Index: lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -200,6 +200,9 @@
return self.QEnvironment(packet)
if packet.startswith("QEnvironmentHexEncoded:"):
return self.QEnvironmentHexEncoded(packet)
+ if packet.startswith("qRegisterInfo"):
+ regnum = int(packet[len("qRegisterInfo"):], 16)
+ return self.qRegisterInfo(regnum)
return self.other(packet)
@@ -325,6 +328,9 @@
def QEnvironmentHexEncoded(self, packet):
return "OK"
+ def qRegisterInfo(self, num):
+ return ""
+
"""
Raised when we receive a packet for which there is no default action.
Override the responder class to implement behavior suitable for the test at
Index: lldb/test/API/functionalities/gdb_remote_client/a.yaml
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/a.yaml
+++ lldb/test/API/functionalities/gdb_remote_client/a.yaml
@@ -1,9 +1,9 @@
-!ELF
+--- !ELF
FileHeader:
- Class: ELFCLASS32
+ Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
- Machine: EM_ARM
+ Machine: EM_X86_64
Sections:
- Name: .text
Type: SHT_PROGBITS
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -9,8 +9,28 @@
class TestGDBRemoteClient(GDBRemoteTestBase):
class gPacketResponder(MockGDBServerResponder):
+ registers = [
+ "name:rax;bitsize:64;offset:0;encoding:uint;format:hex;set:General Purpose Registers;ehframe:0;dwarf:0;",
+ "name:rbx;bitsize:64;offset:8;encoding:uint;format:hex;set:General Purpose Registers;ehframe:3;dwarf:3;",
+ "name:rcx;bitsize:64;offset:16;encoding:uint;format:hex;set:General Purpose Registers;ehframe:2;dwarf:2;generic:arg4;",
+ "name:rdx;bitsize:64;offset:24;encoding:uint;format:hex;set:General Purpose Registers;ehframe:1;dwarf:1;generic:arg3;",
+ "name:rdi;bitsize:64;offset:32;encoding:uint;format:hex;set:General Purpose Registers;ehframe:5;dwarf:5;generic:arg1;",
+ "name:rsi;bitsize:64;offset:40;encoding:uint;format:hex;set:General Purpose Registers;ehframe:4;dwarf:4;generic:arg2;",
+ "name:rbp;bitsize:64;offset:48;encoding:uint;format:hex;set:General Purpose Registers;ehframe:6;dwarf:6;generic:fp;",
+ "name:rsp;bitsize:64;offset:56;encoding:uint;format:hex;set:General Purpose Registers;ehframe:7;dwarf:7;generic:sp;",
+ ]
+
+ def qRegisterInfo(self, num):
+ try:
+ return self.registers[num]
+ except IndexError:
+ return "E45"
+
def readRegisters(self):
- return '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
+ return len(self.registers) * 16 * '0'
+
+ def readRegister(self, register):
+ return "0000000000000000"
def test_connect(self):
"""Test connecting to a remote gdb server"""
@@ -88,6 +108,7 @@
"""Test reading registers using 'p' packets"""
self.dbg.HandleCommand(
"settings set plugin.process.gdb-remote.use-g-packet-for-reading false")
+ self.server.responder = self.gPacketResponder()
target = self.createTarget("a.yaml")
process = self.connect(target)
@@ -128,11 +149,11 @@
def read_registers(self, process):
self.for_each_gpr(
- process, lambda r: self.assertEquals("0x00000000", r.GetValue()))
+ process, lambda r: self.assertEquals("0x0000000000000000", r.GetValue()))
def write_registers(self, process):
self.for_each_gpr(
- process, lambda r: r.SetValueFromCString("0x00000000"))
+ process, lambda r: r.SetValueFromCString("0x0000000000000000"))
def for_each_gpr(self, process, operation):
registers = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetRegisters()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111496.378458.patch
Type: text/x-patch
Size: 5262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20211009/cbbc8295/attachment.bin>
More information about the lldb-commits
mailing list