blob: 88f5327e84b14bb11d76e1e41f8ed466a3087a0c [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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
22using namespace lldb;
23using namespace lldb_private;
24
25//-------------------------------------------------------------------------
26// CommandObjectTranslate
27//-------------------------------------------------------------------------
28
29CommandObjectTranslate::CommandObjectTranslate () :
30 CommandObject ("translate",
31 "Shows the actual function called for a given debugger command.",
32 "translate <command>")
33{
34}
35
36CommandObjectTranslate::~CommandObjectTranslate()
37{
38}
39
40
41bool
42CommandObjectTranslate::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 Friedmanb4a47282010-06-09 07:57:51 +000062 result.AppendErrorWithFormat
Chris Lattner24943d22010-06-08 16:52:24 +000063 ("'%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}