blob: 4acbf66d548f9b2d9f75694120c452441639d4bc [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- CommandObjectShow.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
10#include "CommandObjectShow.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/Interpreter/CommandInterpreter.h"
17#include "lldb/Interpreter/CommandReturnObject.h"
18
19using namespace lldb;
20using namespace lldb_private;
21
22//-------------------------------------------------------------------------
23// CommandObjectShow
24//-------------------------------------------------------------------------
25
26CommandObjectShow::CommandObjectShow () :
27 CommandObject ("show",
28 "Allows the user to see a single debugger setting variable and its value, or lists them all.",
29 "show [<setting-variable-name>]")
30{
31}
32
33CommandObjectShow::~CommandObjectShow()
34{
35}
36
37
38bool
39CommandObjectShow::Execute
40(
Greg Clayton63094e02010-06-23 01:19:29 +000041 CommandInterpreter &interpreter,
Chris Lattner24943d22010-06-08 16:52:24 +000042 Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +000043 CommandReturnObject &result
44)
45{
46 CommandInterpreter::VariableMap::iterator pos;
47
48 if (command.GetArgumentCount())
49 {
50 // The user requested to see the value of a particular variable.
51
52 const char *var_name = command.GetArgumentAtIndex(0);
Greg Clayton63094e02010-06-23 01:19:29 +000053 StateVariable *var = interpreter.GetStateVariable(var_name);
Chris Lattner24943d22010-06-08 16:52:24 +000054 if (var)
55 {
56 var->AppendVariableInformation (result);
57 result.SetStatus (eReturnStatusSuccessFinishNoResult);
58 }
59 else
60 {
61 result.AppendErrorWithFormat ("Unrecognized variable '%s'; cannot do 'show' command.\n", var_name);
62 result.SetStatus (eReturnStatusFailed);
63 }
64 }
65 else
66 {
67 // The user didn't specify a particular variable, so show the values of all of them.
Greg Clayton63094e02010-06-23 01:19:29 +000068 interpreter.ShowVariableValues(result);
Chris Lattner24943d22010-06-08 16:52:24 +000069 result.SetStatus (eReturnStatusSuccessFinishNoResult);
70 }
71
72 return result.Succeeded();
73}