Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4661,24 +4661,22 @@
}
}
- // If the target.xml includes an architecture entry like
+ // gdbserver does not implement the LLDB packets used to determine host
+ // or process architecture. If that is the case, attempt to use
+ // the field from target.xml, e.g.:
+ //
// i386:x86-64 (seen from VMWare ESXi)
- // arm (seen from Segger JLink on unspecified arm board)
- // use that if we don't have anything better.
+ // arm (seen from Segger JLink on unspecified
+ // arm board)
if (!arch_to_use.IsValid() && !target_info.arch.empty()) {
- if (target_info.arch == "i386:x86-64") {
- // We don't have any information about vendor or OS.
- arch_to_use.SetTriple("x86_64--");
- GetTarget().MergeArchitecture(arch_to_use);
- }
+ // We don't have any information about vendor or OS.
+ arch_to_use.SetTriple(llvm::StringSwitch(target_info.arch)
+ .Case("i386:x86-64", "x86_64")
+ .Default(target_info.arch) +
+ "--");
- // SEGGER J-Link jtag boards send this very-generic arch name,
- // we'll need to use this if we have absolutely nothing better
- // to work with or the register definitions won't be accepted.
- if (target_info.arch == "arm") {
- arch_to_use.SetTriple("arm--");
+ if (arch_to_use.IsValid())
GetTarget().MergeArchitecture(arch_to_use);
- }
}
if (arch_to_use.IsValid()) {
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -272,3 +272,141 @@
["ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 "
"0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 "
"0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}"])
+
+ @skipIfXmlSupportMissing
+ @skipIfRemote
+ def test_aarch64_regs(self):
+ """Test grabbing various aarch64 registers from gdbserver."""
+ reg_data = [
+ "0102030405060708", # x0
+ "1112131415161718", # x1
+ ] + 27 * [
+ "2122232425262728", # x2..x28
+ ] + [
+ "3132333435363738", # x29 (fp)
+ "4142434445464748", # x30 (lr)
+ "5152535455565758", # x31 (sp)
+ "6162636465666768", # pc
+ "71727374", # cpsr
+ "8182838485868788898a8b8c8d8e8f90", # v0
+ "9192939495969798999a9b9c9d9e9fa0", # v1
+ ] + 30 * [
+ "a1a2a3a4a5a6a7a8a9aaabacadaeafb0", # v2..v31
+ ] + [
+ "00000000", # fpsr
+ "00000000", # fpcr
+ ]
+
+ class MyResponder(MockGDBServerResponder):
+ def qXferRead(self, obj, annex, offset, length):
+ if annex == "target.xml":
+ return """
+
+
+ aarch64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ """, False
+ else:
+ return None, False
+
+ def readRegister(self, regnum):
+ return ""
+
+ def readRegisters(self):
+ return "".join(reg_data)
+
+ def writeRegisters(self, reg_hex):
+ return "OK"
+
+ def haltReason(self):
+ return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;"
+
+ self.server.responder = MyResponder()
+
+ target = self.createTarget("basic_eh_frame-aarch64.yaml")
+ process = self.connect(target)
+ lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
+ [lldb.eStateStopped])
+
+ # GPRs should be displayed as uints
+ self.match("register read x0",
+ ["x0 = 0x0807060504030201"])
+ self.match("register read x1",
+ ["x1 = 0x1817161514131211"])
+ self.match("register read sp",
+ ["sp = 0x5857565554535251"])
+ self.match("register read pc",
+ ["pc = 0x6867666564636261"])
+ self.match("register read cpsr",
+ ["cpsr = 0x74737271"])