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  if (args.GetArgumentCount() == 0) {
30  Debugger &debugger = GetDebugger();
31 
32  File &input = debugger.GetInputFile();
33  File &output = debugger.GetOutputFile();
34  if (input.GetStream() && output.GetStream() && input.GetIsRealTerminal() &&
35  input.GetIsInteractive()) {
36  IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
37  if (io_handler_sp)
38  debugger.RunIOHandlerAsync(io_handler_sp);
40  } else {
41  result.AppendError("the gui command requires an interactive terminal.");
42  }
43  } else {
44  result.AppendError("the gui command takes no arguments.");
45  }
46  return true;
47 #else
48  result.AppendError("lldb was not built with gui support");
49  return false;
50 #endif
51 }
lldb_private::CommandObjectParsed
Definition: CommandObject.h:394
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:961
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:167
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:169
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:121
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::File
Definition: File.h:35
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
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_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb
Definition: SBAddress.h:15
lldb_private::CommandObject::GetDebugger
Debugger & GetDebugger()
Definition: CommandObject.cpp:51