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