1from __future__ import print_function 2import lldb 3from lldbsuite.test.lldbtest import * 4from lldbsuite.test.decorators import * 5from lldbsuite.test.gdbclientutils import * 6from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase 7 8class TestNoWatchpointSupportInfo(GDBRemoteTestBase): 9 10 @skipIfXmlSupportMissing 11 @skipIfRemote 12 def test(self): 13 """ 14 Test lldb's parsing of the <architecture> tag in the target.xml register 15 description packet. 16 """ 17 class MyResponder(MockGDBServerResponder): 18 19 def haltReason(self): 20 return "T02thread:1ff0d;thread-pcs:10001bc00;" 21 22 def threadStopInfo(self, threadnum): 23 if threadnum == 0x1ff0d: 24 return "T02thread:1ff0d;thread-pcs:10001bc00;" 25 return "" 26 27 def setBreakpoint(self, packet): 28 if packet.startswith("Z2,"): 29 return "OK" 30 31 def qXferRead(self, obj, annex, offset, length): 32 if annex == "target.xml": 33 return """<?xml version="1.0"?> 34 <target version="1.0"> 35 <architecture>i386:x86-64</architecture> 36 <feature name="org.gnu.gdb.i386.core"> 37 <reg name="rip" bitsize="64" regnum="0" type="code_ptr" group="general"/> 38 </feature> 39 </target>""", False 40 else: 41 return None, False 42 43 self.server.responder = MyResponder() 44 if self.TraceOn(): 45 self.runCmd("log enable gdb-remote packets") 46 self.addTearDownHook( 47 lambda: self.runCmd("log disable gdb-remote packets")) 48 self.dbg.SetDefaultArchitecture("x86_64") 49 target = self.dbg.CreateTargetWithFileAndArch(None, None) 50 51 process = self.connect(target) 52 53 if self.TraceOn(): 54 interp = self.dbg.GetCommandInterpreter() 55 result = lldb.SBCommandReturnObject() 56 interp.HandleCommand("target list", result) 57 print(result.GetOutput()) 58 59 60 err = lldb.SBError() 61 wp = target.WatchAddress(0x100, 8, False, True, err) 62 if self.TraceOn() and (err.Fail() or wp.IsValid == False): 63 strm = lldb.SBStream() 64 err.GetDescription(strm) 65 print("watchpoint failed: %s" % strm.GetData()) 66 self.assertTrue(wp.IsValid()) 67 68