1 //===-- MICmdCmdSupportListInfo.cpp -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 // File: MICmdCmdSupportListInfo.cpp
13 // Overview: CMICmdCmdSupportInfoMiCmdQuery implementation.
15 // Environment: Compilers: Visual C++ 12.
16 // gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 // Libraries: See MIReadmetxt.
23 #include "MICmdCmdSupportInfo.h"
24 #include "MICmnMIResultRecord.h"
25 #include "MICmnMIValueConst.h"
26 #include "MICmnMIValueTuple.h"
27 #include "MICmdArgValString.h"
28 #include "MICmdFactory.h"
30 //++ ------------------------------------------------------------------------------------
31 // Details: CMICmdCmdSupportInfoMiCmdQuery constructor.
37 CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery(void)
39 , m_constStrArgCmdName("cmd_name")
41 // Command factory matches this name with that received from the stdin stream
42 m_strMiCmd = "info-gdb-mi-command";
44 // Required by the CMICmdFactory when registering *this command
45 m_pSelfCreatorFn = &CMICmdCmdSupportInfoMiCmdQuery::CreateSelf;
48 //++ ------------------------------------------------------------------------------------
49 // Details: CMICmdCmdSupportInfoMiCmdQuery destructor.
50 // Type: Overrideable.
55 CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery(void)
59 //++ ------------------------------------------------------------------------------------
60 // Details: The invoker requires this function. The parses the command line options
61 // arguments to extract values for each of those arguments.
64 // Return: MIstatus::success - Functional succeeded.
65 // MIstatus::failure - Functional failed.
69 CMICmdCmdSupportInfoMiCmdQuery::ParseArgs(void)
71 bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgCmdName, true, true)));
72 return (bOk && ParseValidateCmdOptions());
75 //++ ------------------------------------------------------------------------------------
76 // Details: The invoker requires this function. The command does work in this function.
77 // The command is likely to communicate with the LLDB SBDebugger in here.
80 // Return: MIstatus::success - Functional succeeded.
81 // MIstatus::failure - Functional failed.
85 CMICmdCmdSupportInfoMiCmdQuery::Execute(void)
87 CMICMDBASE_GETOPTION(pArgNamedCmdName, String, m_constStrArgCmdName);
88 const CMIUtilString &rCmdToQuery(pArgNamedCmdName->GetValue());
89 const MIuint nLen = rCmdToQuery.length();
90 const CMICmdFactory &rCmdFactory = CMICmdFactory::Instance();
91 if ((nLen > 1) && (rCmdToQuery[0] == '-'))
92 m_bCmdFound = rCmdFactory.CmdExist(rCmdToQuery.substr(1, nLen - 1).c_str());
94 m_bCmdFound = rCmdFactory.CmdExist(rCmdToQuery);
96 return MIstatus::success;
99 //++ ------------------------------------------------------------------------------------
100 // Details: The invoker requires this function. The command prepares a MI Record Result
101 // for the work carried out in the Execute().
104 // Return: MIstatus::success - Functional succeeded.
105 // MIstatus::failure - Functional failed.
109 CMICmdCmdSupportInfoMiCmdQuery::Acknowledge(void)
111 const CMICmnMIValueConst miValueConst(m_bCmdFound ? "true" : "false");
112 const CMICmnMIValueResult miValueResult("exists", miValueConst);
113 const CMICmnMIValueTuple miValueTuple(miValueResult);
114 const CMICmnMIValueResult miValueResult2("command", miValueTuple);
115 const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult2);
116 m_miResultRecord = miRecordResult;
118 return MIstatus::success;
121 //++ ------------------------------------------------------------------------------------
122 // Details: Required by the CMICmdFactory when registering *this command. The factory
123 // calls this function to create an instance of *this command.
124 // Type: Static method.
126 // Return: CMICmdBase * - Pointer to a new command.
130 CMICmdCmdSupportInfoMiCmdQuery::CreateSelf(void)
132 return new CMICmdCmdSupportInfoMiCmdQuery();