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