]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/tools/lldb-mi/MICmdCmdSupportInfo.cpp
Add ELF Tool Chain's brandelf(1) to contrib
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / tools / lldb-mi / MICmdCmdSupportInfo.cpp
1 //===-- MICmdCmdSupportListInfo.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 //++
11 // File:        MICmdCmdSupportListInfo.cpp
12 //
13 // Overview:    CMICmdCmdSupportInfoMiCmdQuery          implementation.
14 //
15 // Environment: Compilers:  Visual C++ 12.
16 //                          gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
17 //              Libraries:  See MIReadmetxt.
18 //
19 // Copyright:   None.
20 //--
21
22 // In-house headers:
23 #include "MICmdCmdSupportInfo.h"
24 #include "MICmnMIResultRecord.h"
25 #include "MICmnMIValueConst.h"
26 #include "MICmnMIValueTuple.h"
27 #include "MICmdArgValString.h"
28 #include "MICmdFactory.h"
29
30 //++ ------------------------------------------------------------------------------------
31 // Details: CMICmdCmdSupportInfoMiCmdQuery constructor.
32 // Type:    Method.
33 // Args:    None.
34 // Return:  None.
35 // Throws:  None.
36 //--
37 CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery(void)
38     : m_bCmdFound(false)
39     , m_constStrArgCmdName("cmd_name")
40 {
41     // Command factory matches this name with that received from the stdin stream
42     m_strMiCmd = "info-gdb-mi-command";
43
44     // Required by the CMICmdFactory when registering *this command
45     m_pSelfCreatorFn = &CMICmdCmdSupportInfoMiCmdQuery::CreateSelf;
46 }
47
48 //++ ------------------------------------------------------------------------------------
49 // Details: CMICmdCmdSupportInfoMiCmdQuery destructor.
50 // Type:    Overrideable.
51 // Args:    None.
52 // Return:  None.
53 // Throws:  None.
54 //--
55 CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery(void)
56 {
57 }
58
59 //++ ------------------------------------------------------------------------------------
60 // Details: The invoker requires this function. The parses the command line options
61 //          arguments to extract values for each of those arguments.
62 // Type:    Overridden.
63 // Args:    None.
64 // Return:  MIstatus::success - Functional succeeded.
65 //          MIstatus::failure - Functional failed.
66 // Throws:  None.
67 //--
68 bool
69 CMICmdCmdSupportInfoMiCmdQuery::ParseArgs(void)
70 {
71     bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgCmdName, true, true)));
72     return (bOk && ParseValidateCmdOptions());
73 }
74
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.
78 // Type:    Overridden.
79 // Args:    None.
80 // Return:  MIstatus::success - Functional succeeded.
81 //          MIstatus::failure - Functional failed.
82 // Throws:  None.
83 //--
84 bool
85 CMICmdCmdSupportInfoMiCmdQuery::Execute(void)
86 {
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());
93     else
94         m_bCmdFound = rCmdFactory.CmdExist(rCmdToQuery);
95
96     return MIstatus::success;
97 }
98
99 //++ ------------------------------------------------------------------------------------
100 // Details: The invoker requires this function. The command prepares a MI Record Result
101 //          for the work carried out in the Execute().
102 // Type:    Overridden.
103 // Args:    None.
104 // Return:  MIstatus::success - Functional succeeded.
105 //          MIstatus::failure - Functional failed.
106 // Throws:  None.
107 //--
108 bool
109 CMICmdCmdSupportInfoMiCmdQuery::Acknowledge(void)
110 {
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;
117
118     return MIstatus::success;
119 }
120
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.
125 // Args:    None.
126 // Return:  CMICmdBase * - Pointer to a new command.
127 // Throws:  None.
128 //--
129 CMICmdBase *
130 CMICmdCmdSupportInfoMiCmdQuery::CreateSelf(void)
131 {
132     return new CMICmdCmdSupportInfoMiCmdQuery();
133 }