blob: be6f6888a99d50c922ea1e1526a93be533ccb5cd [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(
41 Args& command,
42 CommandContext *context,
43 CommandInterpreter *interpreter,
44 CommandReturnObject &result
45)
46{
47 CommandInterpreter::VariableMap::iterator pos;
48
49 if (command.GetArgumentCount())
50 {
51 // The user requested to see the value of a particular variable.
52
53 const char *var_name = command.GetArgumentAtIndex(0);
54 StateVariable *var = interpreter->GetStateVariable(var_name);
55 if (var)
56 {
57 var->AppendVariableInformation (result);
58 result.SetStatus (eReturnStatusSuccessFinishNoResult);
59 }
60 else
61 {
62 result.AppendErrorWithFormat ("Unrecognized variable '%s'; cannot do 'show' command.\n", var_name);
63 result.SetStatus (eReturnStatusFailed);
64 }
65 }
66 else
67 {
68 // The user didn't specify a particular variable, so show the values of all of them.
69 interpreter->ShowVariableValues(result);
70 result.SetStatus (eReturnStatusSuccessFinishNoResult);
71 }
72
73 return result.Succeeded();
74}