1"""
2Test python scripted process which returns an empty SBMemoryRegionInfo
3"""
4
5import os, shutil
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11from lldbsuite.test import lldbtest
12
13
14class ScriptedProcessEmptyMemoryRegion(TestBase):
15    NO_DEBUG_INFO_TESTCASE = True
16
17    # imports examples/python/templates/scripted_process.py
18    # which only has register definitions for x86_64 and arm64.
19    @skipIf(archs=no_match(["arm64", "x86_64"]))
20    def test_scripted_process_empty_memory_region(self):
21        """Test that lldb handles an empty SBMemoryRegionInfo object from
22        a scripted process plugin."""
23        self.build()
24
25        target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
26        self.assertTrue(target, VALID_TARGET)
27
28        scripted_process_example_relpath = "dummy_scripted_process.py"
29        self.runCmd(
30            "command script import "
31            + os.path.join(self.getSourceDir(), scripted_process_example_relpath)
32        )
33
34        self.expect("memory region 0", error=True, substrs=["Invalid memory region"])
35
36        self.expect("expr -- 5", substrs=["5"])
37