This is an archive of the discontinued LLVM Phabricator instance.

[ScriptInterpreter] Make sure LLDB's global variables are only available in interactive mode.
ClosedPublic

Authored by JDevlieghere on Sep 17 2019, 4:54 PM.

Details

Summary

Jim pointed out that the LLDB global variables should only be available
in interactive mode. When used from a command for example, their values
might be stale or not at all what the user expects. Therefore we want to
explicitly make these variables unavailable.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Sep 17 2019, 4:54 PM
jingham accepted this revision.Sep 17 2019, 5:10 PM

This looks right.

EnterSession always initializes lldb.debugger, even when it isn't going to set the other globals. That's because one debugger owns one ScriptInterpreter and lldb.debugger always has a unique, valid value. So it isn't strictly necessary to None out lldb.debugger. But since EnterSession always sets it, I don't think it matters one way or the other.

This revision is now accepted and ready to land.Sep 17 2019, 5:10 PM
JDevlieghere edited the summary of this revision. (Show Details)Sep 17 2019, 5:26 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2019, 5:32 PM
labath added a subscriber: labath.Sep 18 2019, 6:02 AM

Unfortunately, there was a bug here which caused the test to fail on linux and windows. r372222 ought to fix that. From the patch description:

The test was expecting the value of "lldb.frame" to be None, because it
is cleared after each python interpreter session. However, this is not
true in the very first session, because lldb.py sets these values to
invalid objects (lldb.SBFrame(), etc.).

I have not investigated why is it that this test passes on darwin, but
my guess is that this is because we do extra work on darwin (loading the
objc runtime, etc), which causes us to enter the python interpreter
sooner.

This patch changes lldb.py to also initialize these values to None, as
that seems to make more sense.

I am pretty sure this will fix the issue on linux, but I am not sure about windows, because it may fail later due to the use of nested quotes, which mostly doesn't work there. Overall, it's usually better to avoid nested quotes in lit tests.