forked from OSchip/llvm-project
[lldb] Make Target* a Target& in CommandObjectExpression::DoExecute REPL logic
Subscribers: JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70002
This commit is contained in:
parent
79b3cce7f1
commit
5a1bac4d1d
|
@ -589,61 +589,59 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_repl_option.GetOptionValue().GetCurrentValue()) {
|
if (m_repl_option.GetOptionValue().GetCurrentValue()) {
|
||||||
Target *target = m_interpreter.GetExecutionContext().GetTargetPtr();
|
Target &target = GetSelectedOrDummyTarget();
|
||||||
if (target) {
|
// Drop into REPL
|
||||||
// Drop into REPL
|
m_expr_lines.clear();
|
||||||
m_expr_lines.clear();
|
m_expr_line_count = 0;
|
||||||
m_expr_line_count = 0;
|
|
||||||
|
|
||||||
Debugger &debugger = target->GetDebugger();
|
Debugger &debugger = target.GetDebugger();
|
||||||
|
|
||||||
// Check if the LLDB command interpreter is sitting on top of a REPL
|
// Check if the LLDB command interpreter is sitting on top of a REPL
|
||||||
// that launched it...
|
// that launched it...
|
||||||
if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter,
|
if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter,
|
||||||
IOHandler::Type::REPL)) {
|
IOHandler::Type::REPL)) {
|
||||||
// the LLDB command interpreter is sitting on top of a REPL that
|
// the LLDB command interpreter is sitting on top of a REPL that
|
||||||
// launched it, so just say the command interpreter is done and
|
// launched it, so just say the command interpreter is done and
|
||||||
// fall back to the existing REPL
|
// fall back to the existing REPL
|
||||||
m_interpreter.GetIOHandler(false)->SetIsDone(true);
|
m_interpreter.GetIOHandler(false)->SetIsDone(true);
|
||||||
} else {
|
} else {
|
||||||
// We are launching the REPL on top of the current LLDB command
|
// We are launching the REPL on top of the current LLDB command
|
||||||
// interpreter, so just push one
|
// interpreter, so just push one
|
||||||
bool initialize = false;
|
bool initialize = false;
|
||||||
Status repl_error;
|
Status repl_error;
|
||||||
REPLSP repl_sp(target->GetREPL(repl_error, m_command_options.language,
|
REPLSP repl_sp(target.GetREPL(repl_error, m_command_options.language,
|
||||||
nullptr, false));
|
nullptr, false));
|
||||||
|
|
||||||
if (!repl_sp) {
|
if (!repl_sp) {
|
||||||
initialize = true;
|
initialize = true;
|
||||||
repl_sp = target->GetREPL(repl_error, m_command_options.language,
|
repl_sp = target.GetREPL(repl_error, m_command_options.language,
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
if (!repl_error.Success()) {
|
if (!repl_error.Success()) {
|
||||||
result.SetError(repl_error);
|
|
||||||
return result.Succeeded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repl_sp) {
|
|
||||||
if (initialize) {
|
|
||||||
repl_sp->SetEvaluateOptions(
|
|
||||||
GetExprOptions(exe_ctx, m_command_options));
|
|
||||||
repl_sp->SetFormatOptions(m_format_options);
|
|
||||||
repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
|
|
||||||
}
|
|
||||||
|
|
||||||
IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
|
|
||||||
|
|
||||||
io_handler_sp->SetIsDone(false);
|
|
||||||
|
|
||||||
debugger.PushIOHandler(io_handler_sp);
|
|
||||||
} else {
|
|
||||||
repl_error.SetErrorStringWithFormat(
|
|
||||||
"Couldn't create a REPL for %s",
|
|
||||||
Language::GetNameForLanguageType(m_command_options.language));
|
|
||||||
result.SetError(repl_error);
|
result.SetError(repl_error);
|
||||||
return result.Succeeded();
|
return result.Succeeded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (repl_sp) {
|
||||||
|
if (initialize) {
|
||||||
|
repl_sp->SetEvaluateOptions(
|
||||||
|
GetExprOptions(exe_ctx, m_command_options));
|
||||||
|
repl_sp->SetFormatOptions(m_format_options);
|
||||||
|
repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
|
||||||
|
}
|
||||||
|
|
||||||
|
IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
|
||||||
|
|
||||||
|
io_handler_sp->SetIsDone(false);
|
||||||
|
|
||||||
|
debugger.PushIOHandler(io_handler_sp);
|
||||||
|
} else {
|
||||||
|
repl_error.SetErrorStringWithFormat(
|
||||||
|
"Couldn't create a REPL for %s",
|
||||||
|
Language::GetNameForLanguageType(m_command_options.language));
|
||||||
|
result.SetError(repl_error);
|
||||||
|
return result.Succeeded();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No expression following options
|
// No expression following options
|
||||||
|
|
Loading…
Reference in New Issue