aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/macosx/dsym_modules/has_dsym.py
blob: babaa9e64cdb82db730f7e7b94545be8742ac9c2 (plain)
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
import lldb


def report_command(debugger, command, exe_ctx, result, internal_dict):
    result.AppendMessage(
        f'{lldb.num_module_inits} {lldb.num_target_inits} "{lldb.target_name}"'
    )
    result.SetStatus(lldb.eReturnStatusSuccessFinishResult)


def __lldb_init_module(debugger, internal_dict):
    # We only want to make one copy of the report command so it will be shared
    if "has_dsym_1" in __name__:
        # lldb is a convenient place to store our counters.
        lldb.num_module_inits = 0
        lldb.num_target_inits = 0
        lldb.target_name = "<unknown>"

        debugger.HandleCommand(
            f"command script add -o -f '{__name__}.report_command' report_command"
        )

    lldb.num_module_inits += 1


def __lldb_module_added_to_target(target, internal_dict):
    lldb.num_target_inits += 1
    target_name = target.executable.fullpath