from __future__ import print_function
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
from gdbclientutils import *
class MyResponder(MockGDBServerResponder):
def qXferRead(self, obj, annex, offset, length):
if annex == "target.xml":
return """
i386:x86-64
""", False
else:
return None, False
def qC(self):
return "QC1"
def haltReason(self):
return "T05thread:00000001;06:9038d60f00700000;07:98b4062680ffffff;10:c0d7bf1b80ffffff;"
def readRegister(self, register):
regs = {0x0: "00b0060000610000",
0xa: "68fe471c80ffffff",
0xc: "60574a1c80ffffff",
0xd: "18f3042680ffffff",
0xe: "be8a4d7142000000",
0xf: "50df471c80ffffff",
0x10: "c0d7bf1b80ffffff" }
if register in regs:
return regs[register]
else:
return "0000000000000000"
class TestTargetXMLArch(GDBRemoteTestBase):
@skipIfXmlSupportMissing
@expectedFailureAll(archs=["i386"])
@skipIfRemote
def test(self):
"""
Test lldb's parsing of the tag in the target.xml register
description packet.
"""
self.server.responder = MyResponder()
interp = self.dbg.GetCommandInterpreter()
result = lldb.SBCommandReturnObject()
if self.TraceOn():
self.runCmd("log enable gdb-remote packets")
self.addTearDownHook(
lambda: self.runCmd("log disable gdb-remote packets"))
target = self.dbg.CreateTarget('')
self.assertEqual('', target.GetTriple())
process = self.connect(target)
if self.TraceOn():
interp.HandleCommand("target list", result)
print(result.GetOutput())
self.assertTrue(target.GetTriple().startswith('x86_64-unknown-unknown'))
@skipIfXmlSupportMissing
@skipIfRemote
def test_register_augmentation(self):
"""
Test that we correctly associate the register info with the eh_frame
register numbers.
"""
target = self.createTarget("basic_eh_frame.yaml")
self.server.responder = MyResponder()
process = self.connect(target)
lldbutil.expect_state_changes(self, self.dbg.GetListener(), process,
[lldb.eStateStopped])
self.filecheck("image show-unwind -n foo", __file__,
"--check-prefix=UNWIND")
# UNWIND: eh_frame UnwindPlan:
# UNWIND: row[0]: 0: CFA=rsp+128 => rip=[CFA-8]