blob: 0991c7e848742a943bb35508780af4a896a41ce4 [file] [log] [blame]
Greg Clayton44d93782014-01-27 23:43:24 +00001//===-- 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 Clayton44d93782014-01-27 23:43:24 +000010#include "CommandObjectGUI.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/lldb-private.h"
17#include "lldb/Interpreter/CommandInterpreter.h"
18#include "lldb/Interpreter/CommandReturnObject.h"
19
20using namespace lldb;
21using namespace lldb_private;
22
23//-------------------------------------------------------------------------
24// CommandObjectGUI
25//-------------------------------------------------------------------------
26
27CommandObjectGUI::CommandObjectGUI (CommandInterpreter &interpreter) :
28 CommandObjectParsed (interpreter, "gui", "Switch into the curses based GUI mode.", "gui")
29{
30}
31
32CommandObjectGUI::~CommandObjectGUI ()
33{
34}
35
36bool
37CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
38{
Deepak Panickal914b8d92014-01-31 18:48:46 +000039#ifndef LLDB_DISABLE_CURSES
Greg Clayton44d93782014-01-27 23:43:24 +000040 if (args.GetArgumentCount() == 0)
41 {
42 Debugger &debugger = m_interpreter.GetDebugger();
Greg Clayton456f2712015-01-14 19:45:21 +000043
44 lldb::StreamFileSP input_sp = debugger.GetInputFile();
45 if (input_sp &&
46 input_sp->GetFile().GetIsRealTerminal() &&
47 input_sp->GetFile().GetIsInteractive())
48 {
49 IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
50 if (io_handler_sp)
51 debugger.PushIOHandler(io_handler_sp);
52 result.SetStatus (eReturnStatusSuccessFinishResult);
53 }
54 else
55 {
56 result.AppendError("the gui command requires an interactive terminal.");
57 result.SetStatus (eReturnStatusFailed);
58 }
Greg Clayton44d93782014-01-27 23:43:24 +000059 }
60 else
61 {
62 result.AppendError("the gui command takes no arguments.");
63 result.SetStatus (eReturnStatusFailed);
64 }
65 return true;
Deepak Panickal914b8d92014-01-31 18:48:46 +000066#else
67 result.AppendError("lldb was not build with gui support");
68 return false;
69#endif
Greg Clayton44d93782014-01-27 23:43:24 +000070}
71