This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Use current execution context in SBDebugger
ClosedPublic

Authored by werat on Jan 31 2021, 7:52 AM.

Details

Summary

Use GetSelectedExecutionContext() instead of GetCommandInterpreter().GetExecutionContext() in SBDebugger::GetInternalVariableValue/SBDebugger::SetInternalVariable. The execution context in the command interpreter might be empty, if no commands has been executed yet (it is updated only when handling commands or completions -- e.g. https://github.com/llvm/llvm-project/blob/main/lldb/source/Interpreter/CommandInterpreter.cpp#L1855).

Diff Detail

Event Timeline

werat requested review of this revision.Jan 31 2021, 7:52 AM
werat created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2021, 7:52 AM
teemperor accepted this revision.Feb 1 2021, 3:13 AM
teemperor added a subscriber: teemperor.

LGTM, thanks!

This revision is now accepted and ready to land.Feb 1 2021, 3:13 AM
werat added a comment.Feb 1 2021, 3:24 AM

Thanks for the review! Can you submit it for me, since I don't have commit access?

This revision was landed with ongoing or failed builds.Feb 1 2021, 4:13 AM
This revision was automatically updated to reflect the committed changes.
jingham added a subscriber: jingham.Feb 1 2021, 9:48 AM

I think it's fine to fall back to the "currently selected target" if the command interpreter doesn't have a current execution context, that should not be your first choice.

For instance, if you are running this command in a Python breakpoint callback, then the current Interpreter context will be set to the target/process/thread that the interpreter is running that command for, whereas the selected context will be whatever the user last selected, and may be for a totally different target/process/thread.