LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 44352 - LLDB driver invoked LLDB gets upset if SBDebugger.HandleCommand invoked commands set Python variables (KeyError)
Summary: LLDB driver invoked LLDB gets upset if SBDebugger.HandleCommand invoked comma...
Status: CONFIRMED
Alias: None
Product: lldb
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: 9.0
Hardware: PC MacOS X
: P normal
Assignee: Jonas Devlieghere
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-19 16:29 PST by Jonathan Watt [:jwatt]
Modified: 2020-01-13 19:25 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Watt [:jwatt] 2019-12-19 16:29:46 PST
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
Comment 1 Jonathan Watt [:jwatt] 2019-12-19 16:36:55 PST
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.
Comment 2 Jonas Devlieghere 2020-01-13 18:55:17 PST
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'
Comment 3 Jonas Devlieghere 2020-01-13 19:22:33 PST
Although unrelated, the repro is also hitting an assert in the editline implementation: lldbassert(m_editor_status != EditorStatus::Editing) in Editline::GetLine().