1 //===-- MICmdCmdVar.h -------------------------------------------*- 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 // Overview:    CMICmdCmdVarCreate              interface.
11 //              CMICmdCmdVarUpdate              interface.
12 //              CMICmdCmdVarDelete              interface.
13 //              CMICmdCmdVarAssign              interface.
14 //              CMICmdCmdVarSetFormat           interface.
15 //              CMICmdCmdVarListChildren        interface.
16 //              CMICmdCmdVarEvaluateExpression  interface.
17 //              CMICmdCmdVarInfoPathExpression  interface.
18 //              CMICmdCmdVarShowAttributes      interface.
19 //
20 //              To implement new MI commands derive a new command class from the
21 //              command base
22 //              class. To enable the new command for interpretation add the new
23 //              command class
24 //              to the command factory. The files of relevance are:
25 //                  MICmdCommands.cpp
26 //                  MICmdBase.h / .cpp
27 //                  MICmdCmd.h / .cpp
28 //              For an introduction to adding a new command see
29 //              CMICmdCmdSupportInfoMiCmdQuery
30 //              command class as an example.
31 
32 #pragma once
33 
34 // In-house headers:
35 #include "MICmdBase.h"
36 #include "MICmnLLDBDebugSessionInfo.h"
37 #include "MICmnLLDBDebugSessionInfoVarObj.h"
38 #include "MICmnMIValueList.h"
39 #include "MICmnMIValueTuple.h"
40 
41 // Declarations:
42 class CMICmnLLDBDebugSessionInfoVarObj;
43 
44 //++
45 //============================================================================
46 // Details: MI command class. MI commands derived from the command base class.
47 //          *this class implements MI command "var-create".
48 //--
49 class CMICmdCmdVarCreate : public CMICmdBase {
50   // Statics:
51 public:
52   // Required by the CMICmdFactory when registering *this command
53   static CMICmdBase *CreateSelf();
54 
55   // Methods:
56 public:
57   /* ctor */ CMICmdCmdVarCreate();
58 
59   // Overridden:
60 public:
61   // From CMICmdInvoker::ICmd
62   bool Execute() override;
63   bool Acknowledge() override;
64   bool ParseArgs() override;
65 
66   // Overridden:
67 public:
68   // From CMICmnBase
69   /* dtor */ ~CMICmdCmdVarCreate() override;
70 
71   // Methods:
72 private:
73   void CompleteSBValue(lldb::SBValue &vrwValue);
74 
75   // Attribute:
76 private:
77   CMIUtilString m_strVarName;
78   MIuint m_nChildren;
79   MIuint64 m_nThreadId;
80   CMIUtilString m_strType;
81   bool m_bValid; // True = Variable is valid, false = not valid
82   CMIUtilString m_strExpression;
83   CMIUtilString m_strValue;
84   const CMIUtilString m_constStrArgName;
85   const CMIUtilString m_constStrArgFrameAddr;
86   const CMIUtilString m_constStrArgExpression;
87 };
88 
89 //++
90 //============================================================================
91 // Details: MI command class. MI commands derived from the command base class.
92 //          *this class implements MI command "var-update".
93 //--
94 class CMICmdCmdVarUpdate : public CMICmdBase {
95   // Statics:
96 public:
97   // Required by the CMICmdFactory when registering *this command
98   static CMICmdBase *CreateSelf();
99 
100   // Methods:
101 public:
102   /* ctor */ CMICmdCmdVarUpdate();
103 
104   // Overridden:
105 public:
106   // From CMICmdInvoker::ICmd
107   bool Execute() override;
108   bool Acknowledge() override;
109   bool ParseArgs() override;
110 
111   // Overridden:
112 public:
113   // From CMICmnBase
114   /* dtor */ ~CMICmdCmdVarUpdate() override;
115 
116   // Methods:
117 private:
118   bool ExamineSBValueForChange(lldb::SBValue &vrwValue, bool &vrwbChanged);
119   void MIFormResponse(const CMIUtilString &vrStrVarName,
120                       const char *const vpValue,
121                       const CMIUtilString &vrStrScope);
122 
123   // Attribute:
124 private:
125   const CMIUtilString m_constStrArgPrintValues;
126   const CMIUtilString m_constStrArgName;
127   bool m_bValueChanged; // True = yes value changed, false = no change
128   CMICmnMIValueList m_miValueList;
129 };
130 
131 //++
132 //============================================================================
133 // Details: MI command class. MI commands derived from the command base class.
134 //          *this class implements MI command "var-delete".
135 //--
136 class CMICmdCmdVarDelete : public CMICmdBase {
137   // Statics:
138 public:
139   // Required by the CMICmdFactory when registering *this command
140   static CMICmdBase *CreateSelf();
141 
142   // Methods:
143 public:
144   /* ctor */ CMICmdCmdVarDelete();
145 
146   // Overridden:
147 public:
148   // From CMICmdInvoker::ICmd
149   bool Execute() override;
150   bool Acknowledge() override;
151   bool ParseArgs() override;
152   // From CMICmnBase
153   /* dtor */ ~CMICmdCmdVarDelete() override;
154 
155   // Attribute:
156 private:
157   const CMIUtilString m_constStrArgName;
158 };
159 
160 //++
161 //============================================================================
162 // Details: MI command class. MI commands derived from the command base class.
163 //          *this class implements MI command "var-assign".
164 //--
165 class CMICmdCmdVarAssign : public CMICmdBase {
166   // Statics:
167 public:
168   // Required by the CMICmdFactory when registering *this command
169   static CMICmdBase *CreateSelf();
170 
171   // Methods:
172 public:
173   /* ctor */ CMICmdCmdVarAssign();
174 
175   // Overridden:
176 public:
177   // From CMICmdInvoker::ICmd
178   bool Execute() override;
179   bool Acknowledge() override;
180   bool ParseArgs() override;
181   // From CMICmnBase
182   /* dtor */ ~CMICmdCmdVarAssign() override;
183 
184   // Attributes:
185 private:
186   bool m_bOk; // True = success, false = failure
187   CMIUtilString m_varObjName;
188   const CMIUtilString m_constStrArgName;
189   const CMIUtilString m_constStrArgExpression;
190 };
191 
192 //++
193 //============================================================================
194 // Details: MI command class. MI commands derived from the command base class.
195 //          *this class implements MI command "var-set-format".
196 //--
197 class CMICmdCmdVarSetFormat : public CMICmdBase {
198   // Statics:
199 public:
200   // Required by the CMICmdFactory when registering *this command
201   static CMICmdBase *CreateSelf();
202 
203   // Methods:
204 public:
205   /* ctor */ CMICmdCmdVarSetFormat();
206 
207   // Overridden:
208 public:
209   // From CMICmdInvoker::ICmd
210   bool Execute() override;
211   bool Acknowledge() override;
212   bool ParseArgs() override;
213   // From CMICmnBase
214   /* dtor */ ~CMICmdCmdVarSetFormat() override;
215 
216   // Attributes:
217 private:
218   CMIUtilString m_varObjName;
219   const CMIUtilString m_constStrArgName;
220   const CMIUtilString m_constStrArgFormatSpec;
221 };
222 
223 //++
224 //============================================================================
225 // Details: MI command class. MI commands derived from the command base class.
226 //          *this class implements MI command "var-list-children".
227 //--
228 class CMICmdCmdVarListChildren : public CMICmdBase {
229   // Statics:
230 public:
231   // Required by the CMICmdFactory when registering *this command
232   static CMICmdBase *CreateSelf();
233 
234   // Methods:
235 public:
236   /* ctor */ CMICmdCmdVarListChildren();
237 
238   // Overridden:
239 public:
240   // From CMICmdInvoker::ICmd
241   bool Execute() override;
242   bool Acknowledge() override;
243   bool ParseArgs() override;
244   // From CMICmnBase
245   /* dtor */ ~CMICmdCmdVarListChildren() override;
246 
247   // Attributes:
248 private:
249   const CMIUtilString m_constStrArgPrintValues;
250   const CMIUtilString m_constStrArgName;
251   const CMIUtilString m_constStrArgFrom;
252   const CMIUtilString m_constStrArgTo;
253   bool m_bValueValid; // True = yes SBValue object is valid, false = not valid
254   MIuint m_nChildren;
255   CMICmnMIValueList m_miValueList;
256   bool m_bHasMore;
257 };
258 
259 //++
260 //============================================================================
261 // Details: MI command class. MI commands derived from the command base class.
262 //          *this class implements MI command "var-evaluate-expression".
263 //--
264 class CMICmdCmdVarEvaluateExpression : public CMICmdBase {
265   // Statics:
266 public:
267   // Required by the CMICmdFactory when registering *this command
268   static CMICmdBase *CreateSelf();
269 
270   // Methods:
271 public:
272   /* ctor */ CMICmdCmdVarEvaluateExpression();
273 
274   // Overridden:
275 public:
276   // From CMICmdInvoker::ICmd
277   bool Execute() override;
278   bool Acknowledge() override;
279   bool ParseArgs() override;
280   // From CMICmnBase
281   /* dtor */ ~CMICmdCmdVarEvaluateExpression() override;
282 
283   // Attributes:
284 private:
285   bool m_bValueValid; // True = yes SBValue object is valid, false = not valid
286   CMIUtilString m_varObjName;
287   const CMIUtilString m_constStrArgFormatSpec; // Not handled by *this command
288   const CMIUtilString m_constStrArgName;
289 };
290 
291 //++
292 //============================================================================
293 // Details: MI command class. MI commands derived from the command base class.
294 //          *this class implements MI command "var-info-path-expression".
295 //--
296 class CMICmdCmdVarInfoPathExpression : public CMICmdBase {
297   // Statics:
298 public:
299   // Required by the CMICmdFactory when registering *this command
300   static CMICmdBase *CreateSelf();
301 
302   // Methods:
303 public:
304   /* ctor */ CMICmdCmdVarInfoPathExpression();
305 
306   // Overridden:
307 public:
308   // From CMICmdInvoker::ICmd
309   bool Execute() override;
310   bool Acknowledge() override;
311   bool ParseArgs() override;
312   // From CMICmnBase
313   /* dtor */ ~CMICmdCmdVarInfoPathExpression() override;
314 
315   // Attributes:
316 private:
317   bool m_bValueValid; // True = yes SBValue object is valid, false = not valid
318   CMIUtilString m_strPathExpression;
319   const CMIUtilString m_constStrArgName;
320 };
321 
322 //++
323 //============================================================================
324 // Details: MI command class. MI commands derived from the command base class.
325 //          *this class implements MI command "var-show-attributes".
326 //--
327 class CMICmdCmdVarShowAttributes : public CMICmdBase {
328   // Statics:
329 public:
330   // Required by the CMICmdFactory when registering *this command
331   static CMICmdBase *CreateSelf();
332 
333   // Methods:
334 public:
335   /* ctor */ CMICmdCmdVarShowAttributes();
336 
337   // Overridden:
338 public:
339   // From CMICmdInvoker::ICmd
340   bool Execute() override;
341   bool Acknowledge() override;
342   bool ParseArgs() override;
343   // From CMICmnBase
344   /* dtor */ ~CMICmdCmdVarShowAttributes() override;
345 
346   // Attributes:
347 private:
348   const CMIUtilString m_constStrArgName;
349 };
350