Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- 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 | |
| 19 | using namespace lldb; |
| 20 | using namespace lldb_private; |
| 21 | |
| 22 | //------------------------------------------------------------------------- |
| 23 | // CommandObjectShow |
| 24 | //------------------------------------------------------------------------- |
| 25 | |
| 26 | CommandObjectShow::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 | |
| 33 | CommandObjectShow::~CommandObjectShow() |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | |
| 38 | bool |
| 39 | CommandObjectShow::Execute |
| 40 | ( |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 41 | CommandInterpreter &interpreter, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 42 | Args& command, |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | 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 Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 53 | StateVariable *var = interpreter.GetStateVariable(var_name); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 54 | 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 Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 68 | interpreter.ShowVariableValues(result); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 69 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 70 | } |
| 71 | |
| 72 | return result.Succeeded(); |
| 73 | } |