2020-01-24 08:23:27 +01:00
|
|
|
//===-- CommandObjectGUI.cpp ----------------------------------------------===//
|
2014-01-27 23:43:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-01-27 23:43:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "CommandObjectGUI.h"
|
|
|
|
|
|
2019-12-03 12:18:17 +01:00
|
|
|
#include "lldb/Core/IOHandlerCursesGUI.h"
|
2019-12-10 08:54:30 -08:00
|
|
|
#include "lldb/Host/Config.h"
|
2014-01-27 23:43:24 +00:00
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
|
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
// CommandObjectGUI
|
|
|
|
|
|
|
|
|
|
CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
|
|
|
|
|
: CommandObjectParsed(interpreter, "gui",
|
|
|
|
|
"Switch into the curses based GUI mode.", "gui") {}
|
|
|
|
|
|
|
|
|
|
CommandObjectGUI::~CommandObjectGUI() {}
|
|
|
|
|
|
|
|
|
|
bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
|
2019-12-12 09:13:04 -08:00
|
|
|
#if LLDB_ENABLE_CURSES
|
2014-01-27 23:43:24 +00:00
|
|
|
if (args.GetArgumentCount() == 0) {
|
2019-04-27 06:19:42 +00:00
|
|
|
Debugger &debugger = GetDebugger();
|
2015-01-14 19:45:21 +00:00
|
|
|
|
2019-09-27 14:33:35 +00:00
|
|
|
File &input = debugger.GetInputFile();
|
2019-10-09 18:43:03 +00:00
|
|
|
File &output = debugger.GetOutputFile();
|
|
|
|
|
if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
|
|
|
|
|
input.GetIsInteractive()) {
|
2015-01-14 19:45:21 +00:00
|
|
|
IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
|
|
|
|
|
if (io_handler_sp)
|
2020-01-15 14:56:28 -08:00
|
|
|
debugger.RunIOHandlerAsync(io_handler_sp);
|
2015-01-14 19:45:21 +00:00
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
|
} else {
|
|
|
|
|
result.AppendError("the gui command requires an interactive terminal.");
|
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
2014-01-27 23:43:24 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result.AppendError("the gui command takes no arguments.");
|
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2014-01-31 18:48:46 +00:00
|
|
|
#else
|
2020-05-13 19:03:22 +02:00
|
|
|
result.AppendError("lldb was not built with gui support");
|
2014-01-31 18:48:46 +00:00
|
|
|
return false;
|
|
|
|
|
#endif
|
2014-01-27 23:43:24 +00:00
|
|
|
}
|