brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 7d6b1af Raw
69 lines · python
1import lldb2from lldbsuite.test.lldbtest import *3from lldbsuite.test.decorators import *4from lldbsuite.test.gdbclientutils import *5from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase6 7 8class TestNoWatchpointSupportInfo(GDBRemoteTestBase):9    @skipIfXmlSupportMissing10    @skipIfRemote11    def test(self):12        """13        Test lldb's parsing of the <architecture> tag in the target.xml register14        description packet.15        """16 17        class MyResponder(MockGDBServerResponder):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 (33                        """<?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>""",40                        False,41                    )42                else:43                    return None, False44 45        self.server.responder = MyResponder()46        if self.TraceOn():47            self.runCmd("log enable gdb-remote packets")48            self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets"))49        self.dbg.SetDefaultArchitecture("x86_64")50        target = self.dbg.CreateTargetWithFileAndArch(None, None)51 52        process = self.connect(target)53 54        if self.TraceOn():55            interp = self.dbg.GetCommandInterpreter()56            result = lldb.SBCommandReturnObject()57            interp.HandleCommand("target list", result)58            print(result.GetOutput())59 60        err = lldb.SBError()61        wp_opts = lldb.SBWatchpointOptions()62        wp_opts.SetWatchpointTypeWrite(lldb.eWatchpointWriteTypeOnModify)63        wp = target.WatchpointCreateByAddress(0x100, 8, wp_opts, err)64        if self.TraceOn() and (err.Fail() or not wp.IsValid):65            strm = lldb.SBStream()66            err.GetDescription(strm)67            print("watchpoint failed: %s" % strm.GetData())68        self.assertTrue(wp.IsValid())69