Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 10 | #include "CommandObjectGUI.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 16 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 17 | #include "lldb/Interpreter/CommandReturnObject.h" |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 18 | #include "lldb/lldb-private.h" |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 19 | |
| 20 | using namespace lldb; |
| 21 | using namespace lldb_private; |
| 22 | |
| 23 | //------------------------------------------------------------------------- |
| 24 | // CommandObjectGUI |
| 25 | //------------------------------------------------------------------------- |
| 26 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 27 | CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter) |
| 28 | : CommandObjectParsed(interpreter, "gui", |
| 29 | "Switch into the curses based GUI mode.", "gui") {} |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 30 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 31 | CommandObjectGUI::~CommandObjectGUI() {} |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) { |
Deepak Panickal | 914b8d9 | 2014-01-31 18:48:46 +0000 | [diff] [blame] | 34 | #ifndef LLDB_DISABLE_CURSES |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 35 | if (args.GetArgumentCount() == 0) { |
| 36 | Debugger &debugger = m_interpreter.GetDebugger(); |
Greg Clayton | 456f271 | 2015-01-14 19:45:21 +0000 | [diff] [blame] | 37 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 38 | lldb::StreamFileSP input_sp = debugger.GetInputFile(); |
| 39 | if (input_sp && input_sp->GetFile().GetIsRealTerminal() && |
| 40 | input_sp->GetFile().GetIsInteractive()) { |
| 41 | IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger)); |
| 42 | if (io_handler_sp) |
| 43 | debugger.PushIOHandler(io_handler_sp); |
| 44 | result.SetStatus(eReturnStatusSuccessFinishResult); |
| 45 | } else { |
| 46 | result.AppendError("the gui command requires an interactive terminal."); |
| 47 | result.SetStatus(eReturnStatusFailed); |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 48 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 49 | } else { |
| 50 | result.AppendError("the gui command takes no arguments."); |
| 51 | result.SetStatus(eReturnStatusFailed); |
| 52 | } |
| 53 | return true; |
Deepak Panickal | 914b8d9 | 2014-01-31 18:48:46 +0000 | [diff] [blame] | 54 | #else |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 55 | result.AppendError("lldb was not build with gui support"); |
| 56 | return false; |
Deepak Panickal | 914b8d9 | 2014-01-31 18:48:46 +0000 | [diff] [blame] | 57 | #endif |
Greg Clayton | 44d9378 | 2014-01-27 23:43:24 +0000 | [diff] [blame] | 58 | } |