Xcode invoked lldb gets upset if SBDebugger.HandleCommand() invoked commands set Python variables, but not (apparently) until the temporary global created in order to run the HandleCommand() commands is destroyed. Specifically it throws a KeyError complaining that those variables are not present *after* all the commands run under HandleCommand have completed. This is an upstreaming of the following report in Mozilla's Bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1605268
In case it's relevant, I should note that this all occurs under a breakpoint script. The script can be found at: https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/Debugging_on_Mac_OS_X#Setting_up_lldb I should also note that when lldb is invoked directly from a terminal (i.e. not invoked by Xcode linking to liblldb to invoke the driver) and this breakpoint is set and runs, this problem does not occur.
I can reproduce this: $ echo "script foo = 1" > test.lldb $ lldb ./a.out (lldb) b main (lldb) breakpoint command add -s python Enter your Python command(s). Type 'DONE' to end. def function (frame, bp_loc, internal_dict): """frame: the lldb.SBFrame for the location at which you stopped bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information internal_dict: an LLDB support object not to be used""" target = frame.GetThread().GetProcess().GetTarget() debugger = target.GetDebugger() debugger.HandleCommand("command source -s true ./test.lldb") DONE (lldb) run Traceback (most recent call last): File "temp.py", line 11, in lldb_autogen_python_bp_callback_func__0 KeyError: 'foo'
Although unrelated, the repro is also hitting an assert in the editline implementation: lldbassert(m_editor_status != EditorStatus::Editing) in Editline::GetLine().