from __future__ import print_function from textwrap import dedent 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 dedent("""\ aarch64 """), False else: return None, def readRegister(self, regnum): return "E01" def readRegisters(self): return "20000000000000002000000000000000f0c154bfffff00005daa985a8fea0b48f0b954bfffff0000ad13cce570150b48380000000000000070456abfffff0000a700000000000000000000000000000001010101010101010000000000000000f0c154bfffff00000f2700000000000008e355bfffff0000080e55bfffff0000281041000000000010de61bfffff00005c05000000000000f0c154bfffff000090fcffffffff00008efcffffffff00008ffcffffffff00000000000000000000001000000000000090fcffffffff000000d06cbfffff0000f0c154bfffff00000100000000000000d0b954bfffff0000e407400000000000d0b954bfffff0000e40740000000000000100000" class TestAArch64XMLRegOffsets(GDBRemoteTestBase): @skipIfXmlSupportMissing @skipIfRemote @skipIfLLVMTargetMissing("AArch64") def test_register_gpacket_offsets(self): """ Test that we correctly associate the register info with the eh_frame register numbers. """ target = self.createTarget("basic_eh_frame-aarch64.yaml") self.server.responder = MyResponder() if self.TraceOn(): self.runCmd("log enable gdb-remote packets") self.addTearDownHook( lambda: self.runCmd("log disable gdb-remote packets")) process = self.connect(target) lldbutil.expect_state_changes(self, self.dbg.GetListener(), process, [lldb.eStateStopped]) registerSet = process.GetThreadAtIndex( 0).GetFrameAtIndex(0).GetRegisters().GetValueAtIndex(0) reg_val_dict = { "x0": 0x0000000000000020, "x1": 0x0000000000000020, "x2": 0x0000ffffbf54c1f0, "x3": 0x480bea8f5a98aa5d, "x4": 0x0000ffffbf54b9f0, "x5": 0x480b1570e5cc13ad, "x6": 0x0000000000000038, "x7": 0x0000ffffbf6a4570, "x8": 0x00000000000000a7, "x9": 0x0000000000000000, "x10": 0x0101010101010101, "x11": 0x0000000000000000, "x12": 0x0000ffffbf54c1f0, "x13": 0x000000000000270f, "x14": 0x0000ffffbf55e308, "x15": 0x0000ffffbf550e08, "x16": 0x0000000000411028, "x17": 0x0000ffffbf61de10, "x18": 0x000000000000055c, "x19": 0x0000ffffbf54c1f0, "x20": 0x0000fffffffffc90, "x21": 0x0000fffffffffc8e, "x22": 0x0000fffffffffc8f, "x23": 0x0000000000000000, "x24": 0x0000000000001000, "x25": 0x0000fffffffffc90, "x26": 0x0000ffffbf6cd000, "x27": 0x0000ffffbf54c1f0, "x28": 0x0000000000000001, "x29": 0x0000ffffbf54b9d0, "x30": 0x00000000004007e4, "sp": 0x0000ffffbf54b9d0, "pc": 0x00000000004007e4, "cpsr": 0x00001000, "w0": 0x00000020, "w1": 0x00000020, "w2": 0xbf54c1f0, "w3": 0x5a98aa5d, "w4": 0xbf54b9f0, "w5": 0xe5cc13ad, "w6": 0x00000038, "w7": 0xbf6a4570, "w8": 0x000000a7, "w9": 0x00000000, "w10": 0x01010101, "w11": 0x00000000, "w12": 0xbf54c1f0, "w13": 0x0000270f, "w14": 0xbf55e308, "w15": 0xbf550e08, "w16": 0x00411028, "w17": 0xbf61de10, "w18": 0x0000055c, "w19": 0xbf54c1f0, "w20": 0xfffffc90, "w21": 0xfffffc8e, "w22": 0xfffffc8f, "w23": 0x00000000, "w24": 0x00001000, "w25": 0xfffffc90, "w26": 0xbf6cd000, "w27": 0xbf54c1f0, "w28": 0x00000001 } for reg in registerSet: self.assertEqual(reg.GetValueAsUnsigned(), reg_val_dict[reg.GetName()])