File: TestExecutableFirst.py

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (56 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (13)
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
# This test checks that we make the executable the first
# element in the image list.

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


class TestExecutableIsFirst(TestBase):
    NO_DEBUG_INFO_TESTCASE = True

    # ELF does not have a hard distinction between shared libraries and
    # (position-independent) executables
    @skipIf(oslist=no_match(lldbplatformutil.getDarwinOSTriples() + ["windows"]))
    def test_executable_is_first_before_run(self):
        self.build()

        ctx = self.platformContext
        lib_name = ctx.shlib_prefix + "bar." + ctx.shlib_extension

        exe = self.getBuildArtifact("a.out")
        lib = self.getBuildArtifact(lib_name)

        target = self.dbg.CreateTarget(None)
        module = target.AddModule(lib, None, None)
        self.assertTrue(module.IsValid(), "Added the module for the library")

        module = target.AddModule(exe, None, None)
        self.assertTrue(module.IsValid(), "Added the executable module")

        # This is the executable module so it should be the first in the list:
        first_module = target.GetModuleAtIndex(0)
        print("This is the first test, this one succeeds")
        self.assertEqual(module, first_module, "This executable is the first module")

        # The executable property is an SBFileSpec to the executable.  Make sure
        # that is also right:
        executable_module = target.executable
        self.assertEqual(
            first_module.file, executable_module, "Python property is also our module"
        )

    def test_executable_is_first_during_run(self):
        self.build()
        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
            self,
            "break after function call",
            lldb.SBFileSpec("main.cpp"),
            extra_images=["bar"],
        )

        first_module = target.GetModuleAtIndex(0)
        self.assertTrue(first_module.IsValid(), "We have at least one module")
        executable_module = target.executable
        self.assertEqual(first_module.file, executable_module, "They are the same")