57 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 TestStopPCs(GDBRemoteTestBase):9 @skipIfXmlSupportMissing10 def test(self):11 class MyResponder(MockGDBServerResponder):12 def haltReason(self):13 # lldb should treat the default halt reason, hwbreak and swbreak in the same way. Which is that it14 # expects the stub to have corrected the PC already, so lldb should not modify it further.15 return "T02thread:1ff0d;threads:1ff0d,2ff0d,3ff0d;thread-pcs:10001bc00,10002bc00,10003bc00;"16 17 def threadStopInfo(self, threadnum):18 if threadnum == 0x1FF0D:19 return "T02thread:1ff0d;threads:1ff0d,2ff0d,3ff0d;thread-pcs:10001bc00,10002bc00,10003bc00;"20 if threadnum == 0x2FF0D:21 return "T00swbreak:;thread:2ff0d;threads:1ff0d,2ff0d,3ff0d;thread-pcs:10001bc00,10002bc00,10003bc00;"22 if threadnum == 0x3FF0D:23 return "T00hwbreak:;thread:3ff0d;threads:1ff0d,2ff0d,3ff0d;thread-pcs:10001bc00,10002bc00,10003bc00;"24 25 def qXferRead(self, obj, annex, offset, length):26 if annex == "target.xml":27 return (28 """<?xml version="1.0"?>29 <target version="1.0">30 <architecture>i386:x86-64</architecture>31 <feature name="org.gnu.gdb.i386.core">32 <reg name="rip" bitsize="64" regnum="0" type="code_ptr" group="general"/>33 </feature>34 </target>""",35 False,36 )37 else:38 return None, False39 40 self.server.responder = MyResponder()41 target = self.dbg.CreateTarget("")42 if self.TraceOn():43 self.runCmd("log enable gdb-remote packets")44 self.addTearDownHook(lambda: self.runCmd("log disable gdb-remote packets"))45 process = self.connect(target)46 47 self.assertEqual(process.GetNumThreads(), 3)48 th0 = process.GetThreadAtIndex(0)49 th1 = process.GetThreadAtIndex(1)50 th2 = process.GetThreadAtIndex(2)51 self.assertEqual(th0.GetThreadID(), 0x1FF0D)52 self.assertEqual(th1.GetThreadID(), 0x2FF0D)53 self.assertEqual(th2.GetThreadID(), 0x3FF0D)54 self.assertEqual(th0.GetFrameAtIndex(0).GetPC(), 0x10001BC00)55 self.assertEqual(th1.GetFrameAtIndex(0).GetPC(), 0x10002BC00)56 self.assertEqual(th2.GetFrameAtIndex(0).GetPC(), 0x10003BC00)57