18567f4d4SMichał Górnyimport lldb 28567f4d4SMichał Górnyfrom lldbsuite.test.lldbtest import * 38567f4d4SMichał Górnyfrom lldbsuite.test.decorators import * 433c0f93fSPavel Labathfrom lldbsuite.test.gdbclientutils import * 533c0f93fSPavel Labathfrom lldbsuite.test.lldbgdbclient import GDBRemoteTestBase 68567f4d4SMichał Górny 78567f4d4SMichał Górny 88567f4d4SMichał Górnyclass TestGDBServerTargetXML(GDBRemoteTestBase): 98567f4d4SMichał Górny @skipIfXmlSupportMissing 108567f4d4SMichał Górny @skipIfRemote 118567f4d4SMichał Górny @skipIfLLVMTargetMissing("X86") 128567f4d4SMichał Górny def test_x86_64_regs(self): 138567f4d4SMichał Górny """Test grabbing various x86_64 registers from gdbserver.""" 14*2238dcc3SJonas Devlieghere 158567f4d4SMichał Górny class MyResponder(MockGDBServerResponder): 16e7418906SMichał Górny reg_data = ( 17*2238dcc3SJonas Devlieghere ( 18e7418906SMichał Górny "0102030405060708" # rcx 19e7418906SMichał Górny "1112131415161718" # rdx 20e7418906SMichał Górny "2122232425262728" # rsi 21e7418906SMichał Górny "3132333435363738" # rdi 22e7418906SMichał Górny "4142434445464748" # rbp 23e7418906SMichał Górny "5152535455565758" # rsp 24e7418906SMichał Górny "6162636465666768" # r8 25e7418906SMichał Górny "7172737475767778" # r9 26e7418906SMichał Górny "8182838485868788" # rip 27e7418906SMichał Górny "91929394" # eflags 28e7418906SMichał Górny "0102030405060708090a" # st0 29e7418906SMichał Górny "1112131415161718191a" # st1 30*2238dcc3SJonas Devlieghere ) 31*2238dcc3SJonas Devlieghere + 6 * ("2122232425262728292a") # st2..st7 32*2238dcc3SJonas Devlieghere + ( 33e7418906SMichał Górny "8182838485868788898a8b8c8d8e8f90" # xmm0 34e7418906SMichał Górny "9192939495969798999a9b9c9d9e9fa0" # xmm1 35*2238dcc3SJonas Devlieghere ) 36*2238dcc3SJonas Devlieghere + 14 * ("a1a2a3a4a5a6a7a8a9aaabacadaeafb0") # xmm2..xmm15 37*2238dcc3SJonas Devlieghere + ("00000000") # mxcsr 38*2238dcc3SJonas Devlieghere + ( 39e7418906SMichał Górny "b1b2b3b4b5b6b7b8b9babbbcbdbebfc0" # ymm0h 40e7418906SMichał Górny "c1c2c3c4c5c6c7c8c9cacbcccdcecfd0" # ymm1h 41*2238dcc3SJonas Devlieghere ) 42*2238dcc3SJonas Devlieghere + 14 * ("d1d2d3d4d5d6d7d8d9dadbdcdddedfe0") # ymm2h..ymm15h 43e7418906SMichał Górny ) 44e7418906SMichał Górny 458567f4d4SMichał Górny def qXferRead(self, obj, annex, offset, length): 468567f4d4SMichał Górny if annex == "target.xml": 47*2238dcc3SJonas Devlieghere return ( 48*2238dcc3SJonas Devlieghere """<?xml version="1.0"?> 498567f4d4SMichał Górny <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 508567f4d4SMichał Górny <target> 518567f4d4SMichał Górny <architecture>i386:x86-64</architecture> 528567f4d4SMichał Górny <osabi>GNU/Linux</osabi> 538567f4d4SMichał Górny <feature name="org.gnu.gdb.i386.core"> 548567f4d4SMichał Górny <reg name="rcx" bitsize="64" type="int64" regnum="2"/> 558567f4d4SMichał Górny <reg name="rdx" bitsize="64" type="int64" regnum="3"/> 568567f4d4SMichał Górny <reg name="rsi" bitsize="64" type="int64" regnum="4"/> 578567f4d4SMichał Górny <reg name="rdi" bitsize="64" type="int64" regnum="5"/> 588567f4d4SMichał Górny <reg name="rbp" bitsize="64" type="data_ptr" regnum="6"/> 598567f4d4SMichał Górny <reg name="rsp" bitsize="64" type="data_ptr" regnum="7"/> 608567f4d4SMichał Górny <reg name="r8" bitsize="64" type="int64" regnum="8"/> 618567f4d4SMichał Górny <reg name="r9" bitsize="64" type="int64" regnum="9"/> 628567f4d4SMichał Górny <reg name="rip" bitsize="64" type="code_ptr" regnum="16"/> 638567f4d4SMichał Górny <reg name="eflags" bitsize="32" type="i386_eflags" regnum="17"/> 648567f4d4SMichał Górny <reg name="st0" bitsize="80" type="i387_ext" regnum="24"/> 658567f4d4SMichał Górny <reg name="st1" bitsize="80" type="i387_ext" regnum="25"/> 668567f4d4SMichał Górny <reg name="st2" bitsize="80" type="i387_ext" regnum="26"/> 678567f4d4SMichał Górny <reg name="st3" bitsize="80" type="i387_ext" regnum="27"/> 688567f4d4SMichał Górny <reg name="st4" bitsize="80" type="i387_ext" regnum="28"/> 698567f4d4SMichał Górny <reg name="st5" bitsize="80" type="i387_ext" regnum="29"/> 708567f4d4SMichał Górny <reg name="st6" bitsize="80" type="i387_ext" regnum="30"/> 718567f4d4SMichał Górny <reg name="st7" bitsize="80" type="i387_ext" regnum="31"/> 728567f4d4SMichał Górny </feature> 738567f4d4SMichał Górny <feature name="org.gnu.gdb.i386.sse"> 748567f4d4SMichał Górny <reg name="xmm0" bitsize="128" type="vec128" regnum="40"/> 758567f4d4SMichał Górny <reg name="xmm1" bitsize="128" type="vec128" regnum="41"/> 768567f4d4SMichał Górny <reg name="xmm2" bitsize="128" type="vec128" regnum="42"/> 778567f4d4SMichał Górny <reg name="xmm3" bitsize="128" type="vec128" regnum="43"/> 788567f4d4SMichał Górny <reg name="xmm4" bitsize="128" type="vec128" regnum="44"/> 798567f4d4SMichał Górny <reg name="xmm5" bitsize="128" type="vec128" regnum="45"/> 808567f4d4SMichał Górny <reg name="xmm6" bitsize="128" type="vec128" regnum="46"/> 818567f4d4SMichał Górny <reg name="xmm7" bitsize="128" type="vec128" regnum="47"/> 828567f4d4SMichał Górny <reg name="xmm8" bitsize="128" type="vec128" regnum="48"/> 838567f4d4SMichał Górny <reg name="xmm9" bitsize="128" type="vec128" regnum="49"/> 848567f4d4SMichał Górny <reg name="xmm10" bitsize="128" type="vec128" regnum="50"/> 858567f4d4SMichał Górny <reg name="xmm11" bitsize="128" type="vec128" regnum="51"/> 868567f4d4SMichał Górny <reg name="xmm12" bitsize="128" type="vec128" regnum="52"/> 878567f4d4SMichał Górny <reg name="xmm13" bitsize="128" type="vec128" regnum="53"/> 888567f4d4SMichał Górny <reg name="xmm14" bitsize="128" type="vec128" regnum="54"/> 898567f4d4SMichał Górny <reg name="xmm15" bitsize="128" type="vec128" regnum="55"/> 908567f4d4SMichał Górny <reg name="mxcsr" bitsize="32" type="i386_mxcsr" regnum="56" group="vector"/> 918567f4d4SMichał Górny </feature> 928567f4d4SMichał Górny <feature name="org.gnu.gdb.i386.avx"> 938567f4d4SMichał Górny <reg name="ymm0h" bitsize="128" type="uint128" regnum="60"/> 948567f4d4SMichał Górny <reg name="ymm1h" bitsize="128" type="uint128" regnum="61"/> 958567f4d4SMichał Górny <reg name="ymm2h" bitsize="128" type="uint128" regnum="62"/> 968567f4d4SMichał Górny <reg name="ymm3h" bitsize="128" type="uint128" regnum="63"/> 978567f4d4SMichał Górny <reg name="ymm4h" bitsize="128" type="uint128" regnum="64"/> 988567f4d4SMichał Górny <reg name="ymm5h" bitsize="128" type="uint128" regnum="65"/> 998567f4d4SMichał Górny <reg name="ymm6h" bitsize="128" type="uint128" regnum="66"/> 1008567f4d4SMichał Górny <reg name="ymm7h" bitsize="128" type="uint128" regnum="67"/> 1018567f4d4SMichał Górny <reg name="ymm8h" bitsize="128" type="uint128" regnum="68"/> 1028567f4d4SMichał Górny <reg name="ymm9h" bitsize="128" type="uint128" regnum="69"/> 1038567f4d4SMichał Górny <reg name="ymm10h" bitsize="128" type="uint128" regnum="70"/> 1048567f4d4SMichał Górny <reg name="ymm11h" bitsize="128" type="uint128" regnum="71"/> 1058567f4d4SMichał Górny <reg name="ymm12h" bitsize="128" type="uint128" regnum="72"/> 1068567f4d4SMichał Górny <reg name="ymm13h" bitsize="128" type="uint128" regnum="73"/> 1078567f4d4SMichał Górny <reg name="ymm14h" bitsize="128" type="uint128" regnum="74"/> 1088567f4d4SMichał Górny <reg name="ymm15h" bitsize="128" type="uint128" regnum="75"/> 1098567f4d4SMichał Górny </feature> 110*2238dcc3SJonas Devlieghere </target>""", 111*2238dcc3SJonas Devlieghere False, 112*2238dcc3SJonas Devlieghere ) 1138567f4d4SMichał Górny else: 1148567f4d4SMichał Górny return None, False 1158567f4d4SMichał Górny 1168567f4d4SMichał Górny def readRegister(self, regnum): 1178567f4d4SMichał Górny return "" 1188567f4d4SMichał Górny 1198567f4d4SMichał Górny def readRegisters(self): 120e7418906SMichał Górny return self.reg_data 1218567f4d4SMichał Górny 1228567f4d4SMichał Górny def writeRegisters(self, reg_hex): 123e7418906SMichał Górny self.reg_data = reg_hex 1248567f4d4SMichał Górny return "OK" 1258567f4d4SMichał Górny 1268567f4d4SMichał Górny def haltReason(self): 1278567f4d4SMichał Górny return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;" 1288567f4d4SMichał Górny 1298567f4d4SMichał Górny self.server.responder = MyResponder() 1308567f4d4SMichał Górny 1318567f4d4SMichał Górny target = self.createTarget("basic_eh_frame.yaml") 1328567f4d4SMichał Górny process = self.connect(target) 133*2238dcc3SJonas Devlieghere lldbutil.expect_state_changes( 134*2238dcc3SJonas Devlieghere self, self.dbg.GetListener(), process, [lldb.eStateStopped] 135*2238dcc3SJonas Devlieghere ) 1368567f4d4SMichał Górny 1378567f4d4SMichał Górny # test generic aliases 138*2238dcc3SJonas Devlieghere self.match("register read arg4", ["rcx = 0x0807060504030201"]) 139*2238dcc3SJonas Devlieghere self.match("register read arg3", ["rdx = 0x1817161514131211"]) 140*2238dcc3SJonas Devlieghere self.match("register read arg2", ["rsi = 0x2827262524232221"]) 141*2238dcc3SJonas Devlieghere self.match("register read arg1", ["rdi = 0x3837363534333231"]) 142*2238dcc3SJonas Devlieghere self.match("register read fp", ["rbp = 0x4847464544434241"]) 143*2238dcc3SJonas Devlieghere self.match("register read sp", ["rsp = 0x5857565554535251"]) 144*2238dcc3SJonas Devlieghere self.match("register read arg5", ["r8 = 0x6867666564636261"]) 145*2238dcc3SJonas Devlieghere self.match("register read arg6", ["r9 = 0x7877767574737271"]) 146*2238dcc3SJonas Devlieghere self.match("register read pc", ["rip = 0x8887868584838281"]) 147*2238dcc3SJonas Devlieghere self.match("register read flags", ["eflags = 0x94939291"]) 14866249323SMichał Górny 149bda5fe8fSMichał Górny # both stX and xmmX should be displayed as vectors 150*2238dcc3SJonas Devlieghere self.match( 151*2238dcc3SJonas Devlieghere "register read st0", 152*2238dcc3SJonas Devlieghere ["st0 = {0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a}"], 153*2238dcc3SJonas Devlieghere ) 154*2238dcc3SJonas Devlieghere self.match( 155*2238dcc3SJonas Devlieghere "register read st1", 156*2238dcc3SJonas Devlieghere ["st1 = {0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a}"], 157*2238dcc3SJonas Devlieghere ) 158*2238dcc3SJonas Devlieghere self.match( 159*2238dcc3SJonas Devlieghere "register read xmm0", 160*2238dcc3SJonas Devlieghere [ 161*2238dcc3SJonas Devlieghere "xmm0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 " 162*2238dcc3SJonas Devlieghere "0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}" 163*2238dcc3SJonas Devlieghere ], 164*2238dcc3SJonas Devlieghere ) 165*2238dcc3SJonas Devlieghere self.match( 166*2238dcc3SJonas Devlieghere "register read xmm1", 167*2238dcc3SJonas Devlieghere [ 168*2238dcc3SJonas Devlieghere "xmm1 = {0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 " 169*2238dcc3SJonas Devlieghere "0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0}" 170*2238dcc3SJonas Devlieghere ], 171*2238dcc3SJonas Devlieghere ) 172bda5fe8fSMichał Górny 1732712d181SMichał Górny # test pseudo-registers 174*2238dcc3SJonas Devlieghere self.filecheck( 175*2238dcc3SJonas Devlieghere "register read --all", 176*2238dcc3SJonas Devlieghere os.path.join(os.path.dirname(__file__), "amd64-partial-regs.FileCheck"), 177*2238dcc3SJonas Devlieghere ) 1782712d181SMichał Górny 1792712d181SMichał Górny # test writing into pseudo-registers 1802712d181SMichał Górny self.runCmd("register write ecx 0xfffefdfc") 181*2238dcc3SJonas Devlieghere self.match("register read rcx", ["rcx = 0x08070605fffefdfc"]) 1822712d181SMichał Górny 1832712d181SMichał Górny self.runCmd("register write cx 0xfbfa") 184*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0xfffefbfa"]) 185*2238dcc3SJonas Devlieghere self.match("register read rcx", ["rcx = 0x08070605fffefbfa"]) 1862712d181SMichał Górny 1872712d181SMichał Górny self.runCmd("register write ch 0xf9") 188*2238dcc3SJonas Devlieghere self.match("register read cx", ["cx = 0xf9fa"]) 189*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0xfffef9fa"]) 190*2238dcc3SJonas Devlieghere self.match("register read rcx", ["rcx = 0x08070605fffef9fa"]) 1912712d181SMichał Górny 1922712d181SMichał Górny self.runCmd("register write cl 0xf8") 193*2238dcc3SJonas Devlieghere self.match("register read cx", ["cx = 0xf9f8"]) 194*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0xfffef9f8"]) 195*2238dcc3SJonas Devlieghere self.match("register read rcx", ["rcx = 0x08070605fffef9f8"]) 1962712d181SMichał Górny 1972712d181SMichał Górny self.runCmd("register write mm0 0xfffefdfcfbfaf9f8") 198*2238dcc3SJonas Devlieghere self.match( 199*2238dcc3SJonas Devlieghere "register read st0", 200*2238dcc3SJonas Devlieghere ["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"], 201*2238dcc3SJonas Devlieghere ) 2022712d181SMichał Górny 203*2238dcc3SJonas Devlieghere self.runCmd( 204*2238dcc3SJonas Devlieghere 'register write xmm0 "{0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 ' 205*2238dcc3SJonas Devlieghere '0xf8 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0}"' 206*2238dcc3SJonas Devlieghere ) 207*2238dcc3SJonas Devlieghere self.match( 208*2238dcc3SJonas Devlieghere "register read ymm0", 209*2238dcc3SJonas Devlieghere [ 210*2238dcc3SJonas Devlieghere "ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 " 211f290efc3SMichał Górny "0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xb1 0xb2 0xb3 0xb4 0xb5 " 212*2238dcc3SJonas Devlieghere "0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf 0xc0}" 213*2238dcc3SJonas Devlieghere ], 214*2238dcc3SJonas Devlieghere ) 215f290efc3SMichał Górny 216*2238dcc3SJonas Devlieghere self.runCmd( 217*2238dcc3SJonas Devlieghere 'register write ymm0h "{0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 ' 218*2238dcc3SJonas Devlieghere '0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}"' 219*2238dcc3SJonas Devlieghere ) 220*2238dcc3SJonas Devlieghere self.match( 221*2238dcc3SJonas Devlieghere "register read ymm0", 222*2238dcc3SJonas Devlieghere [ 223*2238dcc3SJonas Devlieghere "ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 " 224f290efc3SMichał Górny "0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xef 0xee 0xed 0xec 0xeb " 225*2238dcc3SJonas Devlieghere "0xea 0xe9 0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}" 226*2238dcc3SJonas Devlieghere ], 227*2238dcc3SJonas Devlieghere ) 228f290efc3SMichał Górny 229*2238dcc3SJonas Devlieghere self.runCmd( 230*2238dcc3SJonas Devlieghere 'register write ymm0 "{0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 ' 231f290efc3SMichał Górny "0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 " 232f290efc3SMichał Górny "0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec " 233*2238dcc3SJonas Devlieghere '0xed 0xee 0xef}"' 234*2238dcc3SJonas Devlieghere ) 235*2238dcc3SJonas Devlieghere self.match( 236*2238dcc3SJonas Devlieghere "register read ymm0", 237*2238dcc3SJonas Devlieghere [ 238*2238dcc3SJonas Devlieghere "ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 " 239f290efc3SMichał Górny "0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 " 240*2238dcc3SJonas Devlieghere "0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}" 241*2238dcc3SJonas Devlieghere ], 242*2238dcc3SJonas Devlieghere ) 243f290efc3SMichał Górny 24466249323SMichał Górny @skipIfXmlSupportMissing 24566249323SMichał Górny @skipIfRemote 24666249323SMichał Górny @skipIfLLVMTargetMissing("X86") 24766249323SMichał Górny def test_i386_regs(self): 24866249323SMichał Górny """Test grabbing various i386 registers from gdbserver.""" 249*2238dcc3SJonas Devlieghere 25066249323SMichał Górny class MyResponder(MockGDBServerResponder): 251e7418906SMichał Górny reg_data = ( 252*2238dcc3SJonas Devlieghere ( 253e7418906SMichał Górny "01020304" # eax 254e7418906SMichał Górny "11121314" # ecx 255e7418906SMichał Górny "21222324" # edx 256e7418906SMichał Górny "31323334" # ebx 257e7418906SMichał Górny "41424344" # esp 258e7418906SMichał Górny "51525354" # ebp 259e7418906SMichał Górny "61626364" # esi 260e7418906SMichał Górny "71727374" # edi 261e7418906SMichał Górny "81828384" # eip 262e7418906SMichał Górny "91929394" # eflags 263e7418906SMichał Górny "0102030405060708090a" # st0 264e7418906SMichał Górny "1112131415161718191a" # st1 265*2238dcc3SJonas Devlieghere ) 266*2238dcc3SJonas Devlieghere + 6 * ("2122232425262728292a") # st2..st7 267*2238dcc3SJonas Devlieghere + ( 268e7418906SMichał Górny "8182838485868788898a8b8c8d8e8f90" # xmm0 269e7418906SMichał Górny "9192939495969798999a9b9c9d9e9fa0" # xmm1 270*2238dcc3SJonas Devlieghere ) 271*2238dcc3SJonas Devlieghere + 6 * ("a1a2a3a4a5a6a7a8a9aaabacadaeafb0") # xmm2..xmm7 272*2238dcc3SJonas Devlieghere + ("00000000") # mxcsr 273*2238dcc3SJonas Devlieghere + ( 274e7418906SMichał Górny "b1b2b3b4b5b6b7b8b9babbbcbdbebfc0" # ymm0h 275e7418906SMichał Górny "c1c2c3c4c5c6c7c8c9cacbcccdcecfd0" # ymm1h 276*2238dcc3SJonas Devlieghere ) 277*2238dcc3SJonas Devlieghere + 6 * ("d1d2d3d4d5d6d7d8d9dadbdcdddedfe0") # ymm2h..ymm7h 278e7418906SMichał Górny ) 279e7418906SMichał Górny 28066249323SMichał Górny def qXferRead(self, obj, annex, offset, length): 28166249323SMichał Górny if annex == "target.xml": 282*2238dcc3SJonas Devlieghere return ( 283*2238dcc3SJonas Devlieghere """<?xml version="1.0"?> 28466249323SMichał Górny <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 28566249323SMichał Górny <target> 28666249323SMichał Górny <architecture>i386</architecture> 28766249323SMichał Górny <osabi>GNU/Linux</osabi> 28866249323SMichał Górny <feature name="org.gnu.gdb.i386.core"> 28966249323SMichał Górny <reg name="eax" bitsize="32" type="int32" regnum="0"/> 29066249323SMichał Górny <reg name="ecx" bitsize="32" type="int32" regnum="1"/> 29166249323SMichał Górny <reg name="edx" bitsize="32" type="int32" regnum="2"/> 29266249323SMichał Górny <reg name="ebx" bitsize="32" type="int32" regnum="3"/> 29366249323SMichał Górny <reg name="esp" bitsize="32" type="data_ptr" regnum="4"/> 29466249323SMichał Górny <reg name="ebp" bitsize="32" type="data_ptr" regnum="5"/> 29566249323SMichał Górny <reg name="esi" bitsize="32" type="int32" regnum="6"/> 29666249323SMichał Górny <reg name="edi" bitsize="32" type="int32" regnum="7"/> 29766249323SMichał Górny <reg name="eip" bitsize="32" type="code_ptr" regnum="8"/> 29866249323SMichał Górny <reg name="eflags" bitsize="32" type="i386_eflags" regnum="9"/> 29966249323SMichał Górny <reg name="st0" bitsize="80" type="i387_ext" regnum="16"/> 30066249323SMichał Górny <reg name="st1" bitsize="80" type="i387_ext" regnum="17"/> 30166249323SMichał Górny <reg name="st2" bitsize="80" type="i387_ext" regnum="18"/> 30266249323SMichał Górny <reg name="st3" bitsize="80" type="i387_ext" regnum="19"/> 30366249323SMichał Górny <reg name="st4" bitsize="80" type="i387_ext" regnum="20"/> 30466249323SMichał Górny <reg name="st5" bitsize="80" type="i387_ext" regnum="21"/> 30566249323SMichał Górny <reg name="st6" bitsize="80" type="i387_ext" regnum="22"/> 30666249323SMichał Górny <reg name="st7" bitsize="80" type="i387_ext" regnum="23"/> 30766249323SMichał Górny </feature> 30866249323SMichał Górny <feature name="org.gnu.gdb.i386.sse"> 30966249323SMichał Górny <reg name="xmm0" bitsize="128" type="vec128" regnum="32"/> 31066249323SMichał Górny <reg name="xmm1" bitsize="128" type="vec128" regnum="33"/> 31166249323SMichał Górny <reg name="xmm2" bitsize="128" type="vec128" regnum="34"/> 31266249323SMichał Górny <reg name="xmm3" bitsize="128" type="vec128" regnum="35"/> 31366249323SMichał Górny <reg name="xmm4" bitsize="128" type="vec128" regnum="36"/> 31466249323SMichał Górny <reg name="xmm5" bitsize="128" type="vec128" regnum="37"/> 31566249323SMichał Górny <reg name="xmm6" bitsize="128" type="vec128" regnum="38"/> 31666249323SMichał Górny <reg name="xmm7" bitsize="128" type="vec128" regnum="39"/> 31766249323SMichał Górny <reg name="mxcsr" bitsize="32" type="i386_mxcsr" regnum="40" group="vector"/> 31866249323SMichał Górny </feature> 31966249323SMichał Górny <feature name="org.gnu.gdb.i386.avx"> 32066249323SMichał Górny <reg name="ymm0h" bitsize="128" type="uint128" regnum="42"/> 32166249323SMichał Górny <reg name="ymm1h" bitsize="128" type="uint128" regnum="43"/> 32266249323SMichał Górny <reg name="ymm2h" bitsize="128" type="uint128" regnum="44"/> 32366249323SMichał Górny <reg name="ymm3h" bitsize="128" type="uint128" regnum="45"/> 32466249323SMichał Górny <reg name="ymm4h" bitsize="128" type="uint128" regnum="46"/> 32566249323SMichał Górny <reg name="ymm5h" bitsize="128" type="uint128" regnum="47"/> 32666249323SMichał Górny <reg name="ymm6h" bitsize="128" type="uint128" regnum="48"/> 32766249323SMichał Górny <reg name="ymm7h" bitsize="128" type="uint128" regnum="49"/> 32866249323SMichał Górny </feature> 329*2238dcc3SJonas Devlieghere </target>""", 330*2238dcc3SJonas Devlieghere False, 331*2238dcc3SJonas Devlieghere ) 33266249323SMichał Górny else: 33366249323SMichał Górny return None, False 33466249323SMichał Górny 33566249323SMichał Górny def readRegister(self, regnum): 33666249323SMichał Górny return "" 33766249323SMichał Górny 33866249323SMichał Górny def readRegisters(self): 339e7418906SMichał Górny return self.reg_data 34066249323SMichał Górny 34166249323SMichał Górny def writeRegisters(self, reg_hex): 342e7418906SMichał Górny self.reg_data = reg_hex 34366249323SMichał Górny return "OK" 34466249323SMichał Górny 34566249323SMichał Górny def haltReason(self): 34666249323SMichał Górny return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;" 34766249323SMichał Górny 34866249323SMichał Górny self.server.responder = MyResponder() 34966249323SMichał Górny 35066249323SMichał Górny target = self.createTarget("basic_eh_frame-i386.yaml") 35166249323SMichał Górny process = self.connect(target) 352*2238dcc3SJonas Devlieghere lldbutil.expect_state_changes( 353*2238dcc3SJonas Devlieghere self, self.dbg.GetListener(), process, [lldb.eStateStopped] 354*2238dcc3SJonas Devlieghere ) 35566249323SMichał Górny 35666249323SMichał Górny # test generic aliases 357*2238dcc3SJonas Devlieghere self.match("register read fp", ["ebp = 0x54535251"]) 358*2238dcc3SJonas Devlieghere self.match("register read sp", ["esp = 0x44434241"]) 359*2238dcc3SJonas Devlieghere self.match("register read pc", ["eip = 0x84838281"]) 360*2238dcc3SJonas Devlieghere self.match("register read flags", ["eflags = 0x94939291"]) 36166249323SMichał Górny 3622712d181SMichał Górny # test pseudo-registers 363*2238dcc3SJonas Devlieghere self.match("register read cx", ["cx = 0x1211"]) 364*2238dcc3SJonas Devlieghere self.match("register read ch", ["ch = 0x12"]) 365*2238dcc3SJonas Devlieghere self.match("register read cl", ["cl = 0x11"]) 366*2238dcc3SJonas Devlieghere self.match("register read mm0", ["mm0 = 0x0807060504030201"]) 367*2238dcc3SJonas Devlieghere self.match("register read mm1", ["mm1 = 0x1817161514131211"]) 3682712d181SMichał Górny 369bda5fe8fSMichał Górny # both stX and xmmX should be displayed as vectors 370*2238dcc3SJonas Devlieghere self.match( 371*2238dcc3SJonas Devlieghere "register read st0", 372*2238dcc3SJonas Devlieghere ["st0 = {0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a}"], 373*2238dcc3SJonas Devlieghere ) 374*2238dcc3SJonas Devlieghere self.match( 375*2238dcc3SJonas Devlieghere "register read st1", 376*2238dcc3SJonas Devlieghere ["st1 = {0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1a}"], 377*2238dcc3SJonas Devlieghere ) 378*2238dcc3SJonas Devlieghere self.match( 379*2238dcc3SJonas Devlieghere "register read xmm0", 380*2238dcc3SJonas Devlieghere [ 381*2238dcc3SJonas Devlieghere "xmm0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 " 382*2238dcc3SJonas Devlieghere "0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}" 383*2238dcc3SJonas Devlieghere ], 384*2238dcc3SJonas Devlieghere ) 385*2238dcc3SJonas Devlieghere self.match( 386*2238dcc3SJonas Devlieghere "register read xmm1", 387*2238dcc3SJonas Devlieghere [ 388*2238dcc3SJonas Devlieghere "xmm1 = {0x91 0x92 0x93 0x94 0x95 0x96 0x97 0x98 " 389*2238dcc3SJonas Devlieghere "0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f 0xa0}" 390*2238dcc3SJonas Devlieghere ], 391*2238dcc3SJonas Devlieghere ) 392bda5fe8fSMichał Górny 3932712d181SMichał Górny # test writing into pseudo-registers 3942712d181SMichał Górny self.runCmd("register write cx 0xfbfa") 395*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0x1413fbfa"]) 3962712d181SMichał Górny 3972712d181SMichał Górny self.runCmd("register write ch 0xf9") 398*2238dcc3SJonas Devlieghere self.match("register read cx", ["cx = 0xf9fa"]) 399*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0x1413f9fa"]) 4002712d181SMichał Górny 4012712d181SMichał Górny self.runCmd("register write cl 0xf8") 402*2238dcc3SJonas Devlieghere self.match("register read cx", ["cx = 0xf9f8"]) 403*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0x1413f9f8"]) 4042712d181SMichał Górny 4052712d181SMichał Górny self.runCmd("register write mm0 0xfffefdfcfbfaf9f8") 406*2238dcc3SJonas Devlieghere self.match( 407*2238dcc3SJonas Devlieghere "register read st0", 408*2238dcc3SJonas Devlieghere ["st0 = {0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff 0x09 0x0a}"], 409*2238dcc3SJonas Devlieghere ) 4102712d181SMichał Górny 411*2238dcc3SJonas Devlieghere self.runCmd( 412*2238dcc3SJonas Devlieghere 'register write xmm0 "{0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 ' 413*2238dcc3SJonas Devlieghere '0xf8 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0}"' 414*2238dcc3SJonas Devlieghere ) 415*2238dcc3SJonas Devlieghere self.match( 416*2238dcc3SJonas Devlieghere "register read ymm0", 417*2238dcc3SJonas Devlieghere [ 418*2238dcc3SJonas Devlieghere "ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 " 419f290efc3SMichał Górny "0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xb1 0xb2 0xb3 0xb4 0xb5 " 420*2238dcc3SJonas Devlieghere "0xb6 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf 0xc0}" 421*2238dcc3SJonas Devlieghere ], 422*2238dcc3SJonas Devlieghere ) 423f290efc3SMichał Górny 424*2238dcc3SJonas Devlieghere self.runCmd( 425*2238dcc3SJonas Devlieghere 'register write ymm0h "{0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 ' 426*2238dcc3SJonas Devlieghere '0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}"' 427*2238dcc3SJonas Devlieghere ) 428*2238dcc3SJonas Devlieghere self.match( 429*2238dcc3SJonas Devlieghere "register read ymm0", 430*2238dcc3SJonas Devlieghere [ 431*2238dcc3SJonas Devlieghere "ymm0 = {0xff 0xfe 0xfd 0xfc 0xfb 0xfa 0xf9 0xf8 0xf7 0xf6 " 432f290efc3SMichał Górny "0xf5 0xf4 0xf3 0xf2 0xf1 0xf0 0xef 0xee 0xed 0xec 0xeb " 433*2238dcc3SJonas Devlieghere "0xea 0xe9 0xe8 0xe7 0xe6 0xe5 0xe4 0xe3 0xe2 0xe1 0xe0}" 434*2238dcc3SJonas Devlieghere ], 435*2238dcc3SJonas Devlieghere ) 436f290efc3SMichał Górny 437*2238dcc3SJonas Devlieghere self.runCmd( 438*2238dcc3SJonas Devlieghere 'register write ymm0 "{0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 ' 439f290efc3SMichał Górny "0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 " 440f290efc3SMichał Górny "0xe2 0xe3 0xe4 0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec " 441*2238dcc3SJonas Devlieghere '0xed 0xee 0xef}"' 442*2238dcc3SJonas Devlieghere ) 443*2238dcc3SJonas Devlieghere self.match( 444*2238dcc3SJonas Devlieghere "register read ymm0", 445*2238dcc3SJonas Devlieghere [ 446*2238dcc3SJonas Devlieghere "ymm0 = {0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7 0xd8 0xd9 " 447f290efc3SMichał Górny "0xda 0xdb 0xdc 0xdd 0xde 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 " 448*2238dcc3SJonas Devlieghere "0xe5 0xe6 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef}" 449*2238dcc3SJonas Devlieghere ], 450*2238dcc3SJonas Devlieghere ) 451f290efc3SMichał Górny 45266249323SMichał Górny @skipIfXmlSupportMissing 45366249323SMichał Górny @skipIfRemote 45466249323SMichał Górny @skipIfLLVMTargetMissing("AArch64") 45566249323SMichał Górny def test_aarch64_regs(self): 45666249323SMichał Górny """Test grabbing various aarch64 registers from gdbserver.""" 457*2238dcc3SJonas Devlieghere 45866249323SMichał Górny class MyResponder(MockGDBServerResponder): 459583f67cbSMichał Górny reg_data = ( 460*2238dcc3SJonas Devlieghere ("0102030405060708" "1112131415161718") # x0 # x1 461*2238dcc3SJonas Devlieghere + 27 * ("2122232425262728") # x2..x28 462*2238dcc3SJonas Devlieghere + ( 463583f67cbSMichał Górny "3132333435363738" # x29 (fp) 464583f67cbSMichał Górny "4142434445464748" # x30 (lr) 465583f67cbSMichał Górny "5152535455565758" # x31 (sp) 466583f67cbSMichał Górny "6162636465666768" # pc 467583f67cbSMichał Górny "71727374" # cpsr 468583f67cbSMichał Górny "8182838485868788898a8b8c8d8e8f90" # v0 469583f67cbSMichał Górny "9192939495969798999a9b9c9d9e9fa0" # v1 470*2238dcc3SJonas Devlieghere ) 471*2238dcc3SJonas Devlieghere + 30 * ("a1a2a3a4a5a6a7a8a9aaabacadaeafb0") # v2..v31 472*2238dcc3SJonas Devlieghere + ("00000000" "00000000") # fpsr # fpcr 473583f67cbSMichał Górny ) 474583f67cbSMichał Górny 47566249323SMichał Górny def qXferRead(self, obj, annex, offset, length): 47666249323SMichał Górny if annex == "target.xml": 477*2238dcc3SJonas Devlieghere return ( 478*2238dcc3SJonas Devlieghere """<?xml version="1.0"?> 47966249323SMichał Górny <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 48066249323SMichał Górny <target> 48166249323SMichał Górny <architecture>aarch64</architecture> 48266249323SMichał Górny <feature name="org.gnu.gdb.aarch64.core"> 48366249323SMichał Górny <reg name="x0" bitsize="64" type="int" regnum="0"/> 48466249323SMichał Górny <reg name="x1" bitsize="64" type="int" regnum="1"/> 48566249323SMichał Górny <reg name="x2" bitsize="64" type="int" regnum="2"/> 48666249323SMichał Górny <reg name="x3" bitsize="64" type="int" regnum="3"/> 48766249323SMichał Górny <reg name="x4" bitsize="64" type="int" regnum="4"/> 48866249323SMichał Górny <reg name="x5" bitsize="64" type="int" regnum="5"/> 48966249323SMichał Górny <reg name="x6" bitsize="64" type="int" regnum="6"/> 49066249323SMichał Górny <reg name="x7" bitsize="64" type="int" regnum="7"/> 49166249323SMichał Górny <reg name="x8" bitsize="64" type="int" regnum="8"/> 49266249323SMichał Górny <reg name="x9" bitsize="64" type="int" regnum="9"/> 49366249323SMichał Górny <reg name="x10" bitsize="64" type="int" regnum="10"/> 49466249323SMichał Górny <reg name="x11" bitsize="64" type="int" regnum="11"/> 49566249323SMichał Górny <reg name="x12" bitsize="64" type="int" regnum="12"/> 49666249323SMichał Górny <reg name="x13" bitsize="64" type="int" regnum="13"/> 49766249323SMichał Górny <reg name="x14" bitsize="64" type="int" regnum="14"/> 49866249323SMichał Górny <reg name="x15" bitsize="64" type="int" regnum="15"/> 49966249323SMichał Górny <reg name="x16" bitsize="64" type="int" regnum="16"/> 50066249323SMichał Górny <reg name="x17" bitsize="64" type="int" regnum="17"/> 50166249323SMichał Górny <reg name="x18" bitsize="64" type="int" regnum="18"/> 50266249323SMichał Górny <reg name="x19" bitsize="64" type="int" regnum="19"/> 50366249323SMichał Górny <reg name="x20" bitsize="64" type="int" regnum="20"/> 50466249323SMichał Górny <reg name="x21" bitsize="64" type="int" regnum="21"/> 50566249323SMichał Górny <reg name="x22" bitsize="64" type="int" regnum="22"/> 50666249323SMichał Górny <reg name="x23" bitsize="64" type="int" regnum="23"/> 50766249323SMichał Górny <reg name="x24" bitsize="64" type="int" regnum="24"/> 50866249323SMichał Górny <reg name="x25" bitsize="64" type="int" regnum="25"/> 50966249323SMichał Górny <reg name="x26" bitsize="64" type="int" regnum="26"/> 51066249323SMichał Górny <reg name="x27" bitsize="64" type="int" regnum="27"/> 51166249323SMichał Górny <reg name="x28" bitsize="64" type="int" regnum="28"/> 51266249323SMichał Górny <reg name="x29" bitsize="64" type="int" regnum="29"/> 51366249323SMichał Górny <reg name="x30" bitsize="64" type="int" regnum="30"/> 51466249323SMichał Górny <reg name="sp" bitsize="64" type="data_ptr" regnum="31"/> 51566249323SMichał Górny <reg name="pc" bitsize="64" type="code_ptr" regnum="32"/> 51666249323SMichał Górny <reg name="cpsr" bitsize="32" type="cpsr_flags" regnum="33"/> 51766249323SMichał Górny </feature> 51866249323SMichał Górny <feature name="org.gnu.gdb.aarch64.fpu"> 51966249323SMichał Górny <reg name="v0" bitsize="128" type="aarch64v" regnum="34"/> 52066249323SMichał Górny <reg name="v1" bitsize="128" type="aarch64v" regnum="35"/> 52166249323SMichał Górny <reg name="v2" bitsize="128" type="aarch64v" regnum="36"/> 52266249323SMichał Górny <reg name="v3" bitsize="128" type="aarch64v" regnum="37"/> 52366249323SMichał Górny <reg name="v4" bitsize="128" type="aarch64v" regnum="38"/> 52466249323SMichał Górny <reg name="v5" bitsize="128" type="aarch64v" regnum="39"/> 52566249323SMichał Górny <reg name="v6" bitsize="128" type="aarch64v" regnum="40"/> 52666249323SMichał Górny <reg name="v7" bitsize="128" type="aarch64v" regnum="41"/> 52766249323SMichał Górny <reg name="v8" bitsize="128" type="aarch64v" regnum="42"/> 52866249323SMichał Górny <reg name="v9" bitsize="128" type="aarch64v" regnum="43"/> 52966249323SMichał Górny <reg name="v10" bitsize="128" type="aarch64v" regnum="44"/> 53066249323SMichał Górny <reg name="v11" bitsize="128" type="aarch64v" regnum="45"/> 53166249323SMichał Górny <reg name="v12" bitsize="128" type="aarch64v" regnum="46"/> 53266249323SMichał Górny <reg name="v13" bitsize="128" type="aarch64v" regnum="47"/> 53366249323SMichał Górny <reg name="v14" bitsize="128" type="aarch64v" regnum="48"/> 53466249323SMichał Górny <reg name="v15" bitsize="128" type="aarch64v" regnum="49"/> 53566249323SMichał Górny <reg name="v16" bitsize="128" type="aarch64v" regnum="50"/> 53666249323SMichał Górny <reg name="v17" bitsize="128" type="aarch64v" regnum="51"/> 53766249323SMichał Górny <reg name="v18" bitsize="128" type="aarch64v" regnum="52"/> 53866249323SMichał Górny <reg name="v19" bitsize="128" type="aarch64v" regnum="53"/> 53966249323SMichał Górny <reg name="v20" bitsize="128" type="aarch64v" regnum="54"/> 54066249323SMichał Górny <reg name="v21" bitsize="128" type="aarch64v" regnum="55"/> 54166249323SMichał Górny <reg name="v22" bitsize="128" type="aarch64v" regnum="56"/> 54266249323SMichał Górny <reg name="v23" bitsize="128" type="aarch64v" regnum="57"/> 54366249323SMichał Górny <reg name="v24" bitsize="128" type="aarch64v" regnum="58"/> 54466249323SMichał Górny <reg name="v25" bitsize="128" type="aarch64v" regnum="59"/> 54566249323SMichał Górny <reg name="v26" bitsize="128" type="aarch64v" regnum="60"/> 54666249323SMichał Górny <reg name="v27" bitsize="128" type="aarch64v" regnum="61"/> 54766249323SMichał Górny <reg name="v28" bitsize="128" type="aarch64v" regnum="62"/> 54866249323SMichał Górny <reg name="v29" bitsize="128" type="aarch64v" regnum="63"/> 54966249323SMichał Górny <reg name="v30" bitsize="128" type="aarch64v" regnum="64"/> 55066249323SMichał Górny <reg name="v31" bitsize="128" type="aarch64v" regnum="65"/> 55166249323SMichał Górny <reg name="fpsr" bitsize="32" type="int" regnum="66"/> 55266249323SMichał Górny <reg name="fpcr" bitsize="32" type="int" regnum="67"/> 55366249323SMichał Górny </feature> 554*2238dcc3SJonas Devlieghere </target>""", 555*2238dcc3SJonas Devlieghere False, 556*2238dcc3SJonas Devlieghere ) 55766249323SMichał Górny else: 55866249323SMichał Górny return None, False 55966249323SMichał Górny 56066249323SMichał Górny def readRegister(self, regnum): 56166249323SMichał Górny return "" 56266249323SMichał Górny 56366249323SMichał Górny def readRegisters(self): 564583f67cbSMichał Górny return self.reg_data 56566249323SMichał Górny 56666249323SMichał Górny def writeRegisters(self, reg_hex): 567583f67cbSMichał Górny self.reg_data = reg_hex 56866249323SMichał Górny return "OK" 56966249323SMichał Górny 57066249323SMichał Górny def haltReason(self): 57166249323SMichał Górny return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;" 57266249323SMichał Górny 57366249323SMichał Górny self.server.responder = MyResponder() 57466249323SMichał Górny 57566249323SMichał Górny target = self.createTarget("basic_eh_frame-aarch64.yaml") 57666249323SMichał Górny process = self.connect(target) 577*2238dcc3SJonas Devlieghere lldbutil.expect_state_changes( 578*2238dcc3SJonas Devlieghere self, self.dbg.GetListener(), process, [lldb.eStateStopped] 579*2238dcc3SJonas Devlieghere ) 58066249323SMichał Górny 58166249323SMichał Górny # test GPRs 582*2238dcc3SJonas Devlieghere self.match("register read x0", ["x0 = 0x0807060504030201"]) 583*2238dcc3SJonas Devlieghere self.match("register read x1", ["x1 = 0x1817161514131211"]) 584*2238dcc3SJonas Devlieghere self.match("register read x29", ["x29 = 0x3837363534333231"]) 585*2238dcc3SJonas Devlieghere self.match("register read x30", ["x30 = 0x4847464544434241"]) 586*2238dcc3SJonas Devlieghere self.match("register read x31", ["sp = 0x5857565554535251"]) 587*2238dcc3SJonas Devlieghere self.match("register read sp", ["sp = 0x5857565554535251"]) 588*2238dcc3SJonas Devlieghere self.match("register read pc", ["pc = 0x6867666564636261"]) 589*2238dcc3SJonas Devlieghere self.match("register read cpsr", ["cpsr = 0x74737271"]) 59066249323SMichał Górny 59166249323SMichał Górny # test generic aliases 592*2238dcc3SJonas Devlieghere self.match("register read arg1", ["x0 = 0x0807060504030201"]) 593*2238dcc3SJonas Devlieghere self.match("register read arg2", ["x1 = 0x1817161514131211"]) 594*2238dcc3SJonas Devlieghere self.match("register read fp", ["x29 = 0x3837363534333231"]) 595*2238dcc3SJonas Devlieghere self.match("register read lr", ["x30 = 0x4847464544434241"]) 596*2238dcc3SJonas Devlieghere self.match("register read ra", ["x30 = 0x4847464544434241"]) 597*2238dcc3SJonas Devlieghere self.match("register read flags", ["cpsr = 0x74737271"]) 598f6e0edc2SMichał Górny 599f6e0edc2SMichał Górny # test vector registers 600*2238dcc3SJonas Devlieghere self.match( 601*2238dcc3SJonas Devlieghere "register read v0", 602*2238dcc3SJonas Devlieghere [ 603*2238dcc3SJonas Devlieghere "v0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}" 604*2238dcc3SJonas Devlieghere ], 605*2238dcc3SJonas Devlieghere ) 606*2238dcc3SJonas Devlieghere self.match( 607*2238dcc3SJonas Devlieghere "register read v31", 608*2238dcc3SJonas Devlieghere [ 609*2238dcc3SJonas Devlieghere "v31 = {0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf 0xb0}" 610*2238dcc3SJonas Devlieghere ], 611*2238dcc3SJonas Devlieghere ) 612583f67cbSMichał Górny 613583f67cbSMichał Górny # test partial registers 614*2238dcc3SJonas Devlieghere self.match("register read w0", ["w0 = 0x04030201"]) 615583f67cbSMichał Górny self.runCmd("register write w0 0xfffefdfc") 616*2238dcc3SJonas Devlieghere self.match("register read x0", ["x0 = 0x08070605fffefdfc"]) 617583f67cbSMichał Górny 618*2238dcc3SJonas Devlieghere self.match("register read w1", ["w1 = 0x14131211"]) 619583f67cbSMichał Górny self.runCmd("register write w1 0xefeeedec") 620*2238dcc3SJonas Devlieghere self.match("register read x1", ["x1 = 0x18171615efeeedec"]) 621583f67cbSMichał Górny 622*2238dcc3SJonas Devlieghere self.match("register read w30", ["w30 = 0x44434241"]) 623583f67cbSMichał Górny self.runCmd("register write w30 0xdfdedddc") 624*2238dcc3SJonas Devlieghere self.match("register read x30", ["x30 = 0x48474645dfdedddc"]) 625583f67cbSMichał Górny 626*2238dcc3SJonas Devlieghere self.match("register read w31", ["w31 = 0x54535251"]) 627583f67cbSMichał Górny self.runCmd("register write w31 0xcfcecdcc") 628*2238dcc3SJonas Devlieghere self.match("register read x31", ["sp = 0x58575655cfcecdcc"]) 629583f67cbSMichał Górny 630583f67cbSMichał Górny # test FPU registers (overlapping with vector registers) 631583f67cbSMichał Górny self.runCmd("register write d0 16") 632*2238dcc3SJonas Devlieghere self.match( 633*2238dcc3SJonas Devlieghere "register read v0", 634*2238dcc3SJonas Devlieghere [ 635*2238dcc3SJonas Devlieghere "v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}" 636*2238dcc3SJonas Devlieghere ], 637*2238dcc3SJonas Devlieghere ) 638*2238dcc3SJonas Devlieghere self.runCmd( 639*2238dcc3SJonas Devlieghere "register write v31 '{0x00 0x00 0x00 0x00 0x00 0x00 0x50 0x40 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'" 640*2238dcc3SJonas Devlieghere ) 641*2238dcc3SJonas Devlieghere self.match("register read d31", ["d31 = 64"]) 642583f67cbSMichał Górny 643583f67cbSMichał Górny self.runCmd("register write s0 32") 644*2238dcc3SJonas Devlieghere self.match( 645*2238dcc3SJonas Devlieghere "register read v0", 646*2238dcc3SJonas Devlieghere [ 647*2238dcc3SJonas Devlieghere "v0 = {0x00 0x00 0x00 0x42 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}" 648*2238dcc3SJonas Devlieghere ], 649*2238dcc3SJonas Devlieghere ) 650*2238dcc3SJonas Devlieghere self.runCmd( 651*2238dcc3SJonas Devlieghere "register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'" 652*2238dcc3SJonas Devlieghere ) 653*2238dcc3SJonas Devlieghere self.match("register read s31", ["s31 = 128"]) 654f70f9620SMichał Górny 655f70f9620SMichał Górny @skipIfXmlSupportMissing 656f70f9620SMichał Górny @skipIfRemote 6571583c41dSMichał Górny @skipIfLLVMTargetMissing("X86") 6581583c41dSMichał Górny def test_x86_64_no_duplicate_subregs(self): 6591583c41dSMichał Górny """Test that duplicate subregisters are not added (on x86_64).""" 660*2238dcc3SJonas Devlieghere 6611583c41dSMichał Górny class MyResponder(MockGDBServerResponder): 6621583c41dSMichał Górny reg_data = ( 6631583c41dSMichał Górny "0102030405060708" # rcx 6641583c41dSMichał Górny "1112131415161718" # rdx 6651583c41dSMichał Górny "2122232425262728" # rsi 6661583c41dSMichał Górny "3132333435363738" # rdi 6671583c41dSMichał Górny "4142434445464748" # rbp 6681583c41dSMichał Górny "5152535455565758" # rsp 6691583c41dSMichał Górny "6162636465666768" # r8 6701583c41dSMichał Górny "7172737475767778" # r9 6711583c41dSMichał Górny "8182838485868788" # rip 6721583c41dSMichał Górny "91929394" # eflags 6731583c41dSMichał Górny ) 6741583c41dSMichał Górny 6751583c41dSMichał Górny def qXferRead(self, obj, annex, offset, length): 6761583c41dSMichał Górny if annex == "target.xml": 677*2238dcc3SJonas Devlieghere return ( 678*2238dcc3SJonas Devlieghere """<?xml version="1.0"?> 6791583c41dSMichał Górny <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 6801583c41dSMichał Górny <target> 6811583c41dSMichał Górny <architecture>i386:x86-64</architecture> 6821583c41dSMichał Górny <osabi>GNU/Linux</osabi> 6831583c41dSMichał Górny <feature name="org.gnu.gdb.i386.core"> 6841583c41dSMichał Górny <reg name="rcx" bitsize="64" type="int64" regnum="2"/> 6851583c41dSMichał Górny <reg name="rdx" bitsize="64" type="int64" regnum="3"/> 6861583c41dSMichał Górny <reg name="rsi" bitsize="64" type="int64" regnum="4"/> 6871583c41dSMichał Górny <reg name="rdi" bitsize="64" type="int64" regnum="5"/> 6881583c41dSMichał Górny <reg name="rbp" bitsize="64" type="data_ptr" regnum="6"/> 6891583c41dSMichał Górny <reg name="rsp" bitsize="64" type="data_ptr" regnum="7"/> 6901583c41dSMichał Górny <reg name="r8" bitsize="64" type="int64" regnum="8"/> 6911583c41dSMichał Górny <reg name="r9" bitsize="64" type="int64" regnum="9"/> 6921583c41dSMichał Górny <reg name="rip" bitsize="64" type="code_ptr" regnum="16"/> 6931583c41dSMichał Górny <reg name="eflags" bitsize="32" type="i386_eflags" regnum="17"/> 6941583c41dSMichał Górny <reg name="ecx" bitsize="32" type="int" regnum="18" value_regnums="2"/> 6951583c41dSMichał Górny </feature> 696*2238dcc3SJonas Devlieghere </target>""", 697*2238dcc3SJonas Devlieghere False, 698*2238dcc3SJonas Devlieghere ) 6991583c41dSMichał Górny else: 7001583c41dSMichał Górny return None, False 7011583c41dSMichał Górny 7021583c41dSMichał Górny def readRegister(self, regnum): 7031583c41dSMichał Górny return "" 7041583c41dSMichał Górny 7051583c41dSMichał Górny def readRegisters(self): 7061583c41dSMichał Górny return self.reg_data 7071583c41dSMichał Górny 7081583c41dSMichał Górny def haltReason(self): 7091583c41dSMichał Górny return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;" 7101583c41dSMichał Górny 7111583c41dSMichał Górny self.server.responder = MyResponder() 7121583c41dSMichał Górny 7131583c41dSMichał Górny target = self.createTarget("basic_eh_frame.yaml") 7141583c41dSMichał Górny process = self.connect(target) 715*2238dcc3SJonas Devlieghere lldbutil.expect_state_changes( 716*2238dcc3SJonas Devlieghere self, self.dbg.GetListener(), process, [lldb.eStateStopped] 717*2238dcc3SJonas Devlieghere ) 7181583c41dSMichał Górny 719*2238dcc3SJonas Devlieghere self.match("register read rcx", ["rcx = 0x0807060504030201"]) 7201583c41dSMichał Górny # ecx is supplied via target.xml 721*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0x04030201"]) 722*2238dcc3SJonas Devlieghere self.match("register read rdx", ["rdx = 0x1817161514131211"]) 7231583c41dSMichał Górny # edx should not be added 724*2238dcc3SJonas Devlieghere self.match( 725*2238dcc3SJonas Devlieghere "register read edx", ["error: Invalid register name 'edx'."], error=True 726*2238dcc3SJonas Devlieghere ) 7271583c41dSMichał Górny 7281583c41dSMichał Górny @skipIfXmlSupportMissing 7291583c41dSMichał Górny @skipIfRemote 7301583c41dSMichał Górny @skipIfLLVMTargetMissing("X86") 7311583c41dSMichał Górny def test_i386_no_duplicate_subregs(self): 7321583c41dSMichał Górny """Test that duplicate subregisters are not added (on i386).""" 733*2238dcc3SJonas Devlieghere 7341583c41dSMichał Górny class MyResponder(MockGDBServerResponder): 7351583c41dSMichał Górny reg_data = ( 7361583c41dSMichał Górny "01020304" # eax 7371583c41dSMichał Górny "11121314" # ecx 7381583c41dSMichał Górny "21222324" # edx 7391583c41dSMichał Górny "31323334" # ebx 7401583c41dSMichał Górny "41424344" # esp 7411583c41dSMichał Górny "51525354" # ebp 7421583c41dSMichał Górny "61626364" # esi 7431583c41dSMichał Górny "71727374" # edi 7441583c41dSMichał Górny "81828384" # eip 7451583c41dSMichał Górny "91929394" # eflags 7461583c41dSMichał Górny ) 7471583c41dSMichał Górny 7481583c41dSMichał Górny def qXferRead(self, obj, annex, offset, length): 7491583c41dSMichał Górny if annex == "target.xml": 750*2238dcc3SJonas Devlieghere return ( 751*2238dcc3SJonas Devlieghere """<?xml version="1.0"?> 7521583c41dSMichał Górny <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 7531583c41dSMichał Górny <target> 7541583c41dSMichał Górny <architecture>i386</architecture> 7551583c41dSMichał Górny <osabi>GNU/Linux</osabi> 7561583c41dSMichał Górny <feature name="org.gnu.gdb.i386.core"> 7571583c41dSMichał Górny <reg name="eax" bitsize="32" type="int32" regnum="0"/> 7581583c41dSMichał Górny <reg name="ecx" bitsize="32" type="int32" regnum="1"/> 7591583c41dSMichał Górny <reg name="edx" bitsize="32" type="int32" regnum="2"/> 7601583c41dSMichał Górny <reg name="ebx" bitsize="32" type="int32" regnum="3"/> 7611583c41dSMichał Górny <reg name="esp" bitsize="32" type="data_ptr" regnum="4"/> 7621583c41dSMichał Górny <reg name="ebp" bitsize="32" type="data_ptr" regnum="5"/> 7631583c41dSMichał Górny <reg name="esi" bitsize="32" type="int32" regnum="6"/> 7641583c41dSMichał Górny <reg name="edi" bitsize="32" type="int32" regnum="7"/> 7651583c41dSMichał Górny <reg name="eip" bitsize="32" type="code_ptr" regnum="8"/> 7661583c41dSMichał Górny <reg name="eflags" bitsize="32" type="i386_eflags" regnum="9"/> 7671583c41dSMichał Górny <reg name="ax" bitsize="16" type="int" regnum="10" value_regnums="0"/> 7681583c41dSMichał Górny </feature> 769*2238dcc3SJonas Devlieghere </target>""", 770*2238dcc3SJonas Devlieghere False, 771*2238dcc3SJonas Devlieghere ) 7721583c41dSMichał Górny else: 7731583c41dSMichał Górny return None, False 7741583c41dSMichał Górny 7751583c41dSMichał Górny def readRegister(self, regnum): 7761583c41dSMichał Górny return "" 7771583c41dSMichał Górny 7781583c41dSMichał Górny def readRegisters(self): 7791583c41dSMichał Górny return self.reg_data 7801583c41dSMichał Górny 7811583c41dSMichał Górny def haltReason(self): 7821583c41dSMichał Górny return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;" 7831583c41dSMichał Górny 7841583c41dSMichał Górny self.server.responder = MyResponder() 7851583c41dSMichał Górny 7861583c41dSMichał Górny target = self.createTarget("basic_eh_frame-i386.yaml") 7871583c41dSMichał Górny process = self.connect(target) 788*2238dcc3SJonas Devlieghere lldbutil.expect_state_changes( 789*2238dcc3SJonas Devlieghere self, self.dbg.GetListener(), process, [lldb.eStateStopped] 790*2238dcc3SJonas Devlieghere ) 7911583c41dSMichał Górny 792*2238dcc3SJonas Devlieghere self.match("register read eax", ["eax = 0x04030201"]) 7931583c41dSMichał Górny # cx is supplied via target.xml 794*2238dcc3SJonas Devlieghere self.match("register read ax", ["ax = 0x0201"]) 795*2238dcc3SJonas Devlieghere self.match("register read ecx", ["ecx = 0x14131211"]) 7961583c41dSMichał Górny # dx should not be added 797*2238dcc3SJonas Devlieghere self.match( 798*2238dcc3SJonas Devlieghere "register read cx", ["error: Invalid register name 'cx'."], error=True 799*2238dcc3SJonas Devlieghere ) 8001583c41dSMichał Górny 8011583c41dSMichał Górny @skipIfXmlSupportMissing 8021583c41dSMichał Górny @skipIfRemote 803f70f9620SMichał Górny @skipIfLLVMTargetMissing("AArch64") 804f70f9620SMichał Górny def test_aarch64_no_duplicate_subregs(self): 805f70f9620SMichał Górny """Test that duplicate subregisters are not added.""" 806*2238dcc3SJonas Devlieghere 807f70f9620SMichał Górny class MyResponder(MockGDBServerResponder): 808f70f9620SMichał Górny reg_data = ( 809*2238dcc3SJonas Devlieghere ("0102030405060708" "1112131415161718") # x0 # x1 810*2238dcc3SJonas Devlieghere + 27 * ("2122232425262728") # x2..x28 811*2238dcc3SJonas Devlieghere + ( 812f70f9620SMichał Górny "3132333435363738" # x29 (fp) 813f70f9620SMichał Górny "4142434445464748" # x30 (lr) 814f70f9620SMichał Górny "5152535455565758" # x31 (sp) 815f70f9620SMichał Górny "6162636465666768" # pc 816f70f9620SMichał Górny "71727374" # cpsr 817f70f9620SMichał Górny ) 818*2238dcc3SJonas Devlieghere ) 819f70f9620SMichał Górny 820f70f9620SMichał Górny def qXferRead(self, obj, annex, offset, length): 821f70f9620SMichał Górny if annex == "target.xml": 822*2238dcc3SJonas Devlieghere return ( 823*2238dcc3SJonas Devlieghere """<?xml version="1.0"?> 824f70f9620SMichał Górny <!DOCTYPE feature SYSTEM "gdb-target.dtd"> 825f70f9620SMichał Górny <target> 826f70f9620SMichał Górny <architecture>aarch64</architecture> 827f70f9620SMichał Górny <feature name="org.gnu.gdb.aarch64.core"> 828f70f9620SMichał Górny <reg name="x0" bitsize="64" type="int" regnum="0"/> 829f70f9620SMichał Górny <reg name="x1" bitsize="64" type="int" regnum="1"/> 830f70f9620SMichał Górny <reg name="x2" bitsize="64" type="int" regnum="2"/> 831f70f9620SMichał Górny <reg name="x3" bitsize="64" type="int" regnum="3"/> 832f70f9620SMichał Górny <reg name="x4" bitsize="64" type="int" regnum="4"/> 833f70f9620SMichał Górny <reg name="x5" bitsize="64" type="int" regnum="5"/> 834f70f9620SMichał Górny <reg name="x6" bitsize="64" type="int" regnum="6"/> 835f70f9620SMichał Górny <reg name="x7" bitsize="64" type="int" regnum="7"/> 836f70f9620SMichał Górny <reg name="x8" bitsize="64" type="int" regnum="8"/> 837f70f9620SMichał Górny <reg name="x9" bitsize="64" type="int" regnum="9"/> 838f70f9620SMichał Górny <reg name="x10" bitsize="64" type="int" regnum="10"/> 839f70f9620SMichał Górny <reg name="x11" bitsize="64" type="int" regnum="11"/> 840f70f9620SMichał Górny <reg name="x12" bitsize="64" type="int" regnum="12"/> 841f70f9620SMichał Górny <reg name="x13" bitsize="64" type="int" regnum="13"/> 842f70f9620SMichał Górny <reg name="x14" bitsize="64" type="int" regnum="14"/> 843f70f9620SMichał Górny <reg name="x15" bitsize="64" type="int" regnum="15"/> 844f70f9620SMichał Górny <reg name="x16" bitsize="64" type="int" regnum="16"/> 845f70f9620SMichał Górny <reg name="x17" bitsize="64" type="int" regnum="17"/> 846f70f9620SMichał Górny <reg name="x18" bitsize="64" type="int" regnum="18"/> 847f70f9620SMichał Górny <reg name="x19" bitsize="64" type="int" regnum="19"/> 848f70f9620SMichał Górny <reg name="x20" bitsize="64" type="int" regnum="20"/> 849f70f9620SMichał Górny <reg name="x21" bitsize="64" type="int" regnum="21"/> 850f70f9620SMichał Górny <reg name="x22" bitsize="64" type="int" regnum="22"/> 851f70f9620SMichał Górny <reg name="x23" bitsize="64" type="int" regnum="23"/> 852f70f9620SMichał Górny <reg name="x24" bitsize="64" type="int" regnum="24"/> 853f70f9620SMichał Górny <reg name="x25" bitsize="64" type="int" regnum="25"/> 854f70f9620SMichał Górny <reg name="x26" bitsize="64" type="int" regnum="26"/> 855f70f9620SMichał Górny <reg name="x27" bitsize="64" type="int" regnum="27"/> 856f70f9620SMichał Górny <reg name="x28" bitsize="64" type="int" regnum="28"/> 857f70f9620SMichał Górny <reg name="x29" bitsize="64" type="int" regnum="29"/> 858f70f9620SMichał Górny <reg name="x30" bitsize="64" type="int" regnum="30"/> 859f70f9620SMichał Górny <reg name="sp" bitsize="64" type="data_ptr" regnum="31"/> 860f70f9620SMichał Górny <reg name="pc" bitsize="64" type="code_ptr" regnum="32"/> 861f70f9620SMichał Górny <reg name="cpsr" bitsize="32" type="cpsr_flags" regnum="33"/> 862f70f9620SMichał Górny <reg name="w0" bitsize="32" type="int" regnum="34" value_regnums="0"/> 863f70f9620SMichał Górny </feature> 864*2238dcc3SJonas Devlieghere </target>""", 865*2238dcc3SJonas Devlieghere False, 866*2238dcc3SJonas Devlieghere ) 867f70f9620SMichał Górny else: 868f70f9620SMichał Górny return None, False 869f70f9620SMichał Górny 870f70f9620SMichał Górny def readRegister(self, regnum): 871f70f9620SMichał Górny return "" 872f70f9620SMichał Górny 873f70f9620SMichał Górny def readRegisters(self): 874f70f9620SMichał Górny return self.reg_data 875f70f9620SMichał Górny 876f70f9620SMichał Górny def haltReason(self): 877f70f9620SMichał Górny return "T02thread:1ff0d;threads:1ff0d;thread-pcs:000000010001bc00;07:0102030405060708;10:1112131415161718;" 878f70f9620SMichał Górny 879f70f9620SMichał Górny self.server.responder = MyResponder() 880f70f9620SMichał Górny 881f70f9620SMichał Górny target = self.createTarget("basic_eh_frame-aarch64.yaml") 882f70f9620SMichał Górny process = self.connect(target) 883*2238dcc3SJonas Devlieghere lldbutil.expect_state_changes( 884*2238dcc3SJonas Devlieghere self, self.dbg.GetListener(), process, [lldb.eStateStopped] 885*2238dcc3SJonas Devlieghere ) 886f70f9620SMichał Górny 887*2238dcc3SJonas Devlieghere self.match("register read x0", ["x0 = 0x0807060504030201"]) 888f70f9620SMichał Górny # w0 comes from target.xml 889*2238dcc3SJonas Devlieghere self.match("register read w0", ["w0 = 0x04030201"]) 890*2238dcc3SJonas Devlieghere self.match("register read x1", ["x1 = 0x1817161514131211"]) 891f70f9620SMichał Górny # w1 should not be added 892*2238dcc3SJonas Devlieghere self.match( 893*2238dcc3SJonas Devlieghere "register read w1", ["error: Invalid register name 'w1'."], error=True 894*2238dcc3SJonas Devlieghere ) 895