brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 4c1bbe7 Raw
65 lines · python
1"""Test that we don't read objc class tables early in process startup."""2 3import time4import lldb5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7from lldbsuite.test import lldbutil8 9 10class TestEarlyProcessLaunch(TestBase):11    NO_DEBUG_INFO_TESTCASE = True12 13    @skipUnlessDarwin14    @skipIfAsan  # rdar://10335935415    # until this feature is included in the system16    # debugserver.17    @add_test_categories(["pyapi"])18    def test_early_process_launch(self):19        """Test that we don't read objc class tables early in proc startup"""20        self.build()21 22        ###23        ### Hit a breakpoint on the first malloc() call, which24        ### is before libSystem has finished initializing.  At25        ### this point, we should not read the objc class tables.26        ### Then continue to main(), which is past libSystem27        ### initializing.  Try again, and they should be read.28        ###29        ### Use the types logging to detect the difference.30 31        exe = self.getBuildArtifact("a.out")32        target = self.dbg.CreateTarget(exe)33        self.assertTrue(target.IsValid())34        bkpt = target.BreakpointCreateByRegex("alloc", None)35        self.assertTrue(bkpt.IsValid())36        (target, process, thread, bkpt) = lldbutil.run_to_breakpoint_do_run(37            self, target, bkpt38        )39 40        target.DisableAllBreakpoints()41        target.BreakpointCreateByName("main")42 43        logfile_early = os.path.join(self.getBuildDir(), "types-log-early.txt")44        self.addTearDownHook(lambda: self.runCmd("log disable lldb types"))45        self.runCmd("log enable -f %s lldb types" % logfile_early)46        self.runCmd("expression --language objc -- global = 15")47 48        err = process.Continue()49        self.assertTrue(err.Success())50 51        logfile_later = os.path.join(self.getBuildDir(), "types-log-later.txt")52        self.runCmd("log enable -f %s lldb types" % logfile_later)53        self.runCmd("expression --language objc -- global = 25")54 55        self.assertTrue(os.path.exists(logfile_early))56        self.assertTrue(os.path.exists(logfile_later))57        early_text = open(logfile_early).read()58        later_text = open(logfile_later).read()59 60        self.assertIn("ran: no, retry: yes", early_text)61        self.assertNotIn("ran: no, retry: yes", later_text)62 63        self.assertNotIn("ran: yes, retry: no", early_text)64        self.assertIn("ran: yes, retry: no", later_text)65