I have some simple gdb defines that I would like to implement in lldb. I use a small wrapper script that actually generates the gdb defines and then loads them when I launch gdb. The simplest is
define rm
run $LIBLIST $KEXTRAS $EXTRAS
end
Which just defines a custom rm command that runs the binary with command line arguments determined in the wrapper script.
I'd like to emulate that in lldb. I've tried writing python scripts, and I can get them to load and run, but it seems like the command is run under the python interpreter so that the debugger is not catching events (like a CTRL-C to break to the debugger).
This is what I've currently got:
import os
import lldb
def __lldb_init_module(debugger, dict):
debugger.HandleCommand('command script add -f $PYPKG.rm_command rm')
def rm_command( debugger, command, result, internal_dict):
debugger.HandleCommand( 'run $LIBLIST $KEXTRAS $EXTRAS' )
I've also tried using debugger.GetSelectedTarget().Launch, but I get pretty much the same thing. The closest I've gotten is specifying the lldb.eLaunchFlagStopAtEntry LaunchFlag and then having to continue in llvm after the script returns. That's close, but it is kind of annoying to need to enter two commands.
How do I launch a process from a lldb script so that it can debugged as if the run command was used in lldb itself?
(For this example I know I could just pass the command line arguments on lldb's command line, but more complex examples combine arguments from the script with values I'd like to specify when I am debugging)
(Also I know you can create an alias for a one liner like this one, but I have some more complex scripts that would not be possible as an alias)