xref: /llvm-project/lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py (revision 01450dd1c69d1edb0d01159352a56c99988839f4)
1f9f33165SAdrian Prantlimport lldb
2f9f33165SAdrian Prantlfrom lldbsuite.test.decorators import *
3f9f33165SAdrian Prantlfrom lldbsuite.test.lldbtest import *
4f9f33165SAdrian Prantlfrom lldbsuite.test import lldbutil
5f9f33165SAdrian Prantl
6f9f33165SAdrian Prantl
7f9f33165SAdrian Prantlclass TestArm64eAttach(TestBase):
8f9f33165SAdrian Prantl    NO_DEBUG_INFO_TESTCASE = True
9f9f33165SAdrian Prantl
10f9f33165SAdrian Prantl    # On Darwin systems, arch arm64e means ARMv8.3 with ptrauth ABI used.
11f9f33165SAdrian Prantl    @skipIf(archs=no_match(["arm64e"]))
12f9f33165SAdrian Prantl    def test(self):
13f9f33165SAdrian Prantl        # Skip this test if not running on AArch64 target that supports PAC
14f9f33165SAdrian Prantl        if not self.isAArch64PAuth():
15f9f33165SAdrian Prantl            self.skipTest("Target must support pointer authentication.")
16*01450dd1SAdrian Prantl
17f9f33165SAdrian Prantl        self.build()
18f9f33165SAdrian Prantl        popen = self.spawnSubprocess(self.getBuildArtifact(), [])
19*01450dd1SAdrian Prantl
20f9f33165SAdrian Prantl        # This simulates how Xcode attaches to a process by pid/name.
21*01450dd1SAdrian Prantl        error = lldb.SBError()
22f9f33165SAdrian Prantl        target = self.dbg.CreateTarget("", "arm64", "", True, error)
23f9f33165SAdrian Prantl        listener = lldb.SBListener("my.attach.listener")
24f9f33165SAdrian Prantl        process = target.AttachToProcessWithID(listener, popen.pid, error)
25f9f33165SAdrian Prantl        self.assertSuccess(error)
26f9f33165SAdrian Prantl        self.assertTrue(process, PROCESS_IS_VALID)
27f9f33165SAdrian Prantl        self.assertEqual(target.GetTriple().split('-')[0], "arm64e",
28f9f33165SAdrian Prantl                         "target triple is updated correctly")
29*01450dd1SAdrian Prantl
30*01450dd1SAdrian Prantl        self.expect('process plugin packet send qProcessInfo',
31*01450dd1SAdrian Prantl                    "debugserver returns correct triple",
32*01450dd1SAdrian Prantl                    substrs=['cputype:100000c', 'cpusubtype:2', 'ptrsize:8'])
33*01450dd1SAdrian Prantl
34f9f33165SAdrian Prantl        error = process.Kill()
35f9f33165SAdrian Prantl        self.assertSuccess(error)
36