I would like to be able to declare global helper functions and types for use in assisting debugging and keep these in their own framework.
I have found that it is possible to load the framework using LLDB by executing the following.
#!/usr/bin/python
import lldb
def __lldb_init_module(debugger, internal_dict):
debugger.HandleCommand("command script add -f {0}.HandleCommand custom".format(__name__))
debugger.HandleCommand("command alias swift expression -l Swift -O --")
debugger.HandleCommand("command alias objc expression -l objc -O --")
def HandleCommand(debugger, command, result, internal_dict):
target = debugger.GetSelectedTarget()
process = target.GetProcess()
error = lldb.SBError()
process.LoadImage(lldb.SBFileSpec("/path/to/CustomCommandHelper.framework/CustomCommandHelper"), error)
if error.fail:
result.SetError(error)
else:
result.AppendMessage("custom command loaded")
referenced from .lldbinit
command script import /path/to/CustomCommands.py
From the debugger typing the following will now load the framework into the debugger
(lldb) custom
However I am not able to access any of the types with in it except by [ab]using objc
@objc public class TestClass2: NSObject {
public override init() {}
@objc public let text = "Test"
}
(lldb) objc id testClass2 = [[NSClassFromString(@"CustomCommandHelper.TestClass2") alloc] init]; [testClass2 text];
Test
(lldb) swift let testClass2 = CustomCommandHelper.TestClass2(); testClass2.text
error: <EXPR>:8:18: error: module 'CustomCommandHelper' has no member named 'TestClass2'
let testClass2 = CustomCommandHelper.TestClass2(); testClass2.text