File: TestAArch64LinuxNonAddressBitCodeBreak.py

package info (click to toggle)
llvm-toolchain-18 1%3A18.1.8-18
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,908,340 kB
  • sloc: cpp: 6,667,937; ansic: 1,440,452; asm: 883,619; python: 230,549; objc: 76,880; f90: 74,238; lisp: 35,989; pascal: 16,571; sh: 10,229; perl: 7,459; ml: 5,047; awk: 3,523; makefile: 2,987; javascript: 2,149; xml: 892; fortran: 649; cs: 573
file content (64 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Test that "breakpoint set -a" uses the ABI plugin to remove non-address bits
before attempting to set a breakpoint.
"""

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class AArch64LinuxNonAddressBitCodeBreak(TestBase):
    NO_DEBUG_INFO_TESTCASE = True

    def do_tagged_break(self, hardware):
        if not self.isAArch64PAuth():
            self.skipTest("Target must support pointer authentication.")

        self.build()
        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)

        lldbutil.run_break_set_by_file_and_line(
            self,
            "main.c",
            line_number("main.c", "// Set break point at this line."),
            num_expected_locations=1,
        )

        self.runCmd("run", RUN_SUCCEEDED)

        if self.process().GetState() == lldb.eStateExited:
            self.fail("Test program failed to run.")

        self.expect(
            "thread list",
            STOPPED_DUE_TO_BREAKPOINT,
            substrs=["stopped", "stop reason = breakpoint"],
        )

        cmd = "breakpoint set -a fnptr"
        # LLDB only has the option to force hardware break, not software.
        # It prefers sofware break when it can and this will be one of those cases.
        if hardware:
            cmd += " --hardware"
        self.expect(cmd)

        self.runCmd("continue")
        self.assertEqual(self.process().GetState(), lldb.eStateStopped)
        self.expect(
            "thread list",
            STOPPED_DUE_TO_BREAKPOINT,
            substrs=["stopped", "`foo at main.c", "stop reason = breakpoint"],
        )

    # AArch64 Linux always enables the top byte ignore feature
    @skipUnlessArch("aarch64")
    @skipUnlessPlatform(["linux"])
    def test_software_break(self):
        self.do_tagged_break(False)

    @skipUnlessArch("aarch64")
    @skipUnlessPlatform(["linux"])
    def test_hardware_break(self):
        self.do_tagged_break(True)