brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · a82141a Raw
39 lines · python
1"""2Test changing setting for expression memory allocation.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class TestMemoryAllocSettings(TestBase):12    def test(self):13        """Test changing settings for expression memory allocation."""14        self.build()15        target = self.createTestTarget()16 17        self.log_file = self.getBuildArtifact("log-expr.txt")18 19        self.runCmd("settings set target.expr-alloc-address 0xdead0000")20        self.runCmd("settings set target.expr-alloc-size 10000")21        self.runCmd("settings set target.expr-alloc-align 0x1000")22 23        self.runCmd("log enable lldb expr -f " + self.log_file)24        self.runCmd("expression -- int foo; &foo")25 26        self.assertTrue(os.path.isfile(self.log_file))27        with open(self.log_file, "r") as f:28            log = f.read()29 30        alloc0 = re.search("^.*IRMemoryMap::Malloc.+?0xdead0000.*$", log, re.MULTILINE)31        # Malloc adds additional bytes to allocation size, hence 1000732        alloc1 = re.search(33            r"^.*IRMemoryMap::Malloc\s*?\(10007.+?0xdead1000.*$", log, re.MULTILINE34        )35        self.assertTrue(alloc0, "Couldn't find an allocation at a given address.")36        self.assertTrue(37            alloc1, "Couldn't find an allocation of a given size at a given address."38        )39