1""" 2Test that "memory region" command can show memory tagged regions 3on AArch64 Linux. 4""" 5 6 7 8import lldb 9from lldbsuite.test.decorators import * 10from lldbsuite.test.lldbtest import * 11from lldbsuite.test import lldbutil 12 13 14class AArch64LinuxMTEMemoryRegionTestCase(TestBase): 15 16 NO_DEBUG_INFO_TESTCASE = True 17 18 @skipUnlessArch("aarch64") 19 @skipUnlessPlatform(["linux"]) 20 @skipUnlessAArch64MTELinuxCompiler 21 def test_mte_regions(self): 22 if not self.isAArch64MTE(): 23 self.skipTest('Target must support MTE.') 24 25 # This test assumes that we have /proc/<PID>/smaps files 26 # that include "VmFlags:" lines. 27 # AArch64 kernel config defaults to enabling smaps with 28 # PROC_PAGE_MONITOR and "VmFlags" was added in kernel 3.8, 29 # before MTE was supported at all. 30 31 self.build() 32 self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) 33 34 lldbutil.run_break_set_by_file_and_line(self, "main.c", 35 line_number('main.c', '// Set break point at this line.'), 36 num_expected_locations=1) 37 38 self.runCmd("run", RUN_SUCCEEDED) 39 40 if self.process().GetState() == lldb.eStateExited: 41 self.fail("Test program failed to run.") 42 43 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 44 substrs=['stopped', 45 'stop reason = breakpoint']) 46 47 substrs = ["memory tagging: enabled"] 48 # The new page will be tagged 49 self.expect("memory region the_page", substrs=substrs) 50 # Code page will not be 51 self.expect("memory region main", substrs=substrs, matching=False) 52