2014-01-28 07:43:24 +08:00
|
|
|
//===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08: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-28 07:43:24 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "CommandObjectGUI.h"
|
|
|
|
|
|
|
|
#include "lldb/Interpreter/CommandInterpreter.h"
|
|
|
|
#include "lldb/Interpreter/CommandReturnObject.h"
|
2016-09-07 04:57:50 +08:00
|
|
|
#include "lldb/lldb-private.h"
|
2014-01-28 07:43:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
// CommandObjectGUI
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
|
|
|
|
: CommandObjectParsed(interpreter, "gui",
|
|
|
|
"Switch into the curses based GUI mode.", "gui") {}
|
2014-01-28 07:43:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
CommandObjectGUI::~CommandObjectGUI() {}
|
2014-01-28 07:43:24 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
|
2014-02-01 02:48:46 +08:00
|
|
|
#ifndef LLDB_DISABLE_CURSES
|
2016-09-07 04:57:50 +08:00
|
|
|
if (args.GetArgumentCount() == 0) {
|
2019-04-27 14:19:42 +08:00
|
|
|
Debugger &debugger = GetDebugger();
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
lldb::StreamFileSP input_sp = debugger.GetInputFile();
|
|
|
|
if (input_sp && input_sp->GetFile().GetIsRealTerminal() &&
|
|
|
|
input_sp->GetFile().GetIsInteractive()) {
|
|
|
|
IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
|
|
|
|
if (io_handler_sp)
|
|
|
|
debugger.PushIOHandler(io_handler_sp);
|
|
|
|
result.SetStatus(eReturnStatusSuccessFinishResult);
|
|
|
|
} else {
|
|
|
|
result.AppendError("the gui command requires an interactive terminal.");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
2014-01-28 07:43:24 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
|
|
|
result.AppendError("the gui command takes no arguments.");
|
|
|
|
result.SetStatus(eReturnStatusFailed);
|
|
|
|
}
|
|
|
|
return true;
|
2014-02-01 02:48:46 +08:00
|
|
|
#else
|
2016-09-07 04:57:50 +08:00
|
|
|
result.AppendError("lldb was not build with gui support");
|
|
|
|
return false;
|
2014-02-01 02:48:46 +08:00
|
|
|
#endif
|
2014-01-28 07:43:24 +08:00
|
|
|
}
|