LLDB  mainline
CommandObjectGUI.cpp
Go to the documentation of this file.
1 //===-- CommandObjectGUI.cpp ----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "CommandObjectGUI.h"
10 
12 #include "lldb/Host/Config.h"
15 
16 using namespace lldb;
17 using namespace lldb_private;
18 
19 // CommandObjectGUI
20 
21 CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
22  : CommandObjectParsed(interpreter, "gui",
23  "Switch into the curses based GUI mode.", "gui") {}
24 
26 
28 #if LLDB_ENABLE_CURSES
29  Debugger &debugger = GetDebugger();
30 
31  File &input = debugger.GetInputFile();
32  File &output = debugger.GetOutputFile();
33  if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
34  input.GetIsInteractive()) {
35  IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
36  if (io_handler_sp)
37  debugger.RunIOHandlerAsync(io_handler_sp);
39  } else {
40  result.AppendError("the gui command requires an interactive terminal.");
41  }
42  return true;
43 #else
44  result.AppendError("lldb was not built with gui support");
45  return false;
46 #endif
47 }
lldb_private::CommandObjectParsed
Definition: CommandObject.h:389
lldb_private::File::GetIsInteractive
bool GetIsInteractive()
Return true if this file is interactive.
Definition: File.cpp:191
lldb_private::Debugger::RunIOHandlerAsync
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
Definition: Debugger.cpp:1103
lldb_private::File::GetIsRealTerminal
bool GetIsRealTerminal()
Return true if this file from a real terminal.
Definition: File.cpp:197
lldb_private::Args
Definition: Args.h:33
CommandReturnObject.h
IOHandlerCursesGUI.h
lldb_private::Debugger::GetInputFile
File & GetInputFile()
Definition: Debugger.h:140
CommandObjectGUI.h
lldb_private::CommandObjectGUI::DoExecute
bool DoExecute(Args &args, CommandReturnObject &result) override
Definition: CommandObjectGUI.cpp:27
lldb_private::Debugger::GetOutputFile
File & GetOutputFile()
Definition: Debugger.h:142
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:127
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::File
Definition: File.h:35
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
lldb_private::CommandObjectGUI::~CommandObjectGUI
~CommandObjectGUI() override
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
CommandInterpreter.h
lldb_private::File::GetStream
virtual FILE * GetStream()
Get the underlying libc stream for this file, or NULL.
Definition: File.cpp:126
lldb_private::IOHandlerCursesGUI
Definition: IOHandlerCursesGUI.h:16
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
lldb
Definition: SBAddress.h:15
lldb_private::CommandObject::GetDebugger
Debugger & GetDebugger()
Definition: CommandObject.cpp:53