So the dSYM can be told what target it has been loaded into. When lldb is loading modules, while creating a target, it will run "command script import" on any Python modules in Resources/Python in the dSYM. However, this happens WHILE the target is being created, so it is not yet in the target list. That means that these scripts can't act on the target that they a part of when they get loaded. This patch adds a new python API that lldb will call: __lldb_module_added_to_target if it is defined in the module, passing in the Target the module was being added to, so that code in these dSYM's don't have to guess.
29 lines
881 B
Python
29 lines
881 B
Python
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
|