brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 0611907 Raw
92 lines · python
1"""Test that the expedited thread pc values are not re-fetched by lldb."""2 3import subprocess4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9file_index = 010 11 12class TestExpeditedThreadPCs(TestBase):13    NO_DEBUG_INFO_TESTCASE = True14 15    @skipUnlessDarwin16    def test_expedited_thread_pcs(self):17        TestBase.setUp(self)18 19        global file_index20        ++file_index21        logfile = os.path.join(22            self.getBuildDir(),23            "packet-log-" + self.getArchitecture() + "-" + str(file_index) + ".txt",24        )25        self.runCmd("log enable -f %s gdb-remote packets" % (logfile))26 27        def cleanup():28            self.runCmd("log disable gdb-remote packets")29            if os.path.exists(logfile):30                os.unlink(logfile)31 32        self.addTearDownHook(cleanup)33 34        self.source = "main.cpp"35        self.build()36        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(37            self, "break here", lldb.SBFileSpec(self.source, False)38        )39 40        # verify that libfoo.dylib hasn't loaded yet41        for m in target.modules:42            self.assertNotEqual(m.GetFileSpec().GetFilename(), "libfoo.dylib")43 44        thread.StepInto()45        thread.StepInto()46 47        thread.StepInto()48        thread.StepInto()49        thread.StepInto()50 51        # verify that libfoo.dylib has loaded52        for m in target.modules:53            if m.GetFileSpec().GetFilename() == "libfoo.dylib":54                found_libfoo = True55        self.assertTrue(found_libfoo)56 57        thread.StepInto()58        thread.StepInto()59        thread.StepOver()60        thread.StepOver()61        thread.StepOver()62        thread.StepOver()63        thread.StepOver()64        thread.StepOver()65        thread.StepOver()66        thread.StepOver()67        thread.StepOver()68        thread.StepOver()69 70        process.Kill()71 72        # Confirm that we never fetched the pc for any threads during73        # this debug session.74        if os.path.exists(logfile):75            f = open(logfile)76            lines = f.readlines()77            num_errors = 078            for line in lines:79                arch = self.getArchitecture()80                if arch == "arm64" or arch == "arm64_32":81                    #   <reg name="pc" regnum="32" offset="256" bitsize="64" group="general" group_id="1" ehframe_regnum="32" dwarf_regnum="32" generic="pc"/>82                    # A fetch of $pc on arm64 looks like83                    #  <  22> send packet: $p20;thread:91698e;#7084                    self.assertNotIn("$p20;thread", line)85                else:86                    #   <reg name="rip" regnum="16" offset="128" bitsize="64" group="general" altname="pc" group_id="1" ehframe_regnum="16" dwarf_regnum="16" generic="pc"/>87                    # A fetch of $pc on x86_64 looks like88                    #  <  22> send packet: $p10;thread:91889c;#6f89                    self.assertNotIn("$p10;thread", line)90 91            f.close()92