Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- CommandObjectTranslate.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 "CommandObjectTranslate.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Core/Args.h" |
| 17 | #include "lldb/Core/Options.h" |
| 18 | |
| 19 | #include "lldb/Interpreter/CommandInterpreter.h" |
| 20 | #include "lldb/Interpreter/CommandReturnObject.h" |
| 21 | |
| 22 | using namespace lldb; |
| 23 | using namespace lldb_private; |
| 24 | |
| 25 | //------------------------------------------------------------------------- |
| 26 | // CommandObjectTranslate |
| 27 | //------------------------------------------------------------------------- |
| 28 | |
| 29 | CommandObjectTranslate::CommandObjectTranslate () : |
| 30 | CommandObject ("translate", |
| 31 | "Shows the actual function called for a given debugger command.", |
| 32 | "translate <command>") |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | CommandObjectTranslate::~CommandObjectTranslate() |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | |
| 41 | bool |
| 42 | CommandObjectTranslate::Execute |
| 43 | ( |
| 44 | Args& command, |
| 45 | CommandContext *context, |
| 46 | CommandInterpreter *interpreter, |
| 47 | CommandReturnObject &result |
| 48 | ) |
| 49 | { |
| 50 | CommandObject *cmd_obj; |
| 51 | |
| 52 | if (command.GetArgumentCount() != 0) |
| 53 | { |
| 54 | cmd_obj = interpreter->GetCommandObject(command.GetArgumentAtIndex(0)); |
| 55 | if (cmd_obj) |
| 56 | { |
| 57 | result.SetStatus (eReturnStatusSuccessFinishNoResult); |
| 58 | result.AppendMessageWithFormat ("%s\n", cmd_obj->Translate()); |
| 59 | } |
| 60 | else |
| 61 | { |
Eli Friedman | b4a4728 | 2010-06-09 07:57:51 +0000 | [diff] [blame^] | 62 | result.AppendErrorWithFormat |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 63 | ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", |
| 64 | command.GetArgumentAtIndex(0)); |
| 65 | result.SetStatus (eReturnStatusFailed); |
| 66 | } |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | result.AppendError ("must call translate with a valid command"); |
| 71 | result.SetStatus (eReturnStatusFailed); |
| 72 | } |
| 73 | |
| 74 | return result.Succeeded(); |
| 75 | } |