1 //===-- MICmdCmdData.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: CMICmdCmdDataEvaluateExpression interface. 11 // CMICmdCmdDataDisassemble interface. 12 // CMICmdCmdDataReadMemoryBytes interface. 13 // CMICmdCmdDataReadMemory interface. 14 // CMICmdCmdDataListRegisterNames interface. 15 // CMICmdCmdDataListRegisterValues interface. 16 // CMICmdCmdDataListRegisterChanged interface. 17 // CMICmdCmdDataWriteMemoryBytes interface. 18 // CMICmdCmdDataWriteMemory interface. 19 // CMICmdCmdDataInfoLine interface. 20 // 21 // To implement new MI commands derive a new command class from the 22 // command base 23 // class. To enable the new command for interpretation add the new 24 // command class 25 // to the command factory. The files of relevance are: 26 // MICmdCommands.cpp 27 // MICmdBase.h / .cpp 28 // MICmdCmd.h / .cpp 29 // For an introduction to adding a new command see 30 // CMICmdCmdSupportInfoMiCmdQuery 31 // command class as an example. 32 // 33 34 #pragma once 35 36 // Third party headers: 37 #include "lldb/API/SBError.h" 38 39 // In-house headers: 40 #include "MICmdBase.h" 41 #include "MICmnLLDBDebugSessionInfoVarObj.h" 42 #include "MICmnMIValueList.h" 43 #include "MICmnMIValueTuple.h" 44 #include "MICmnMIResultRecord.h" 45 46 //++ 47 //============================================================================ 48 // Details: MI command class. MI commands derived from the command base class. 49 // *this class implements MI command "data-evaluate-expression". 50 //-- 51 class CMICmdCmdDataEvaluateExpression : public CMICmdBase { 52 // Statics: 53 public: 54 // Required by the CMICmdFactory when registering *this command 55 static CMICmdBase *CreateSelf(); 56 57 // Methods: 58 public: 59 /* ctor */ CMICmdCmdDataEvaluateExpression(); 60 61 // Overridden: 62 public: 63 // From CMICmdInvoker::ICmd 64 bool Execute() override; 65 bool Acknowledge() override; 66 bool ParseArgs() override; 67 // From CMICmnBase 68 /* dtor */ ~CMICmdCmdDataEvaluateExpression() override; 69 70 // Methods: 71 private: 72 bool HaveInvalidCharacterInExpression(const CMIUtilString &vrExpr, 73 char &vrwInvalidChar); 74 75 // Attributes: 76 private: 77 bool m_bExpressionValid; // True = yes is valid, false = not valid 78 bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = 79 // failed 80 lldb::SBError m_Error; // Status object, which is examined when 81 // m_bEvaluatedExpression is false 82 CMIUtilString m_strValue; 83 CMICmnMIValueTuple m_miValueTuple; 84 bool m_bFoundInvalidChar; // True = yes found unexpected character in the 85 // expression, false = all ok 86 char m_cExpressionInvalidChar; 87 const CMIUtilString m_constStrArgExpr; 88 }; 89 90 //++ 91 //============================================================================ 92 // Details: MI command class. MI commands derived from the command base class. 93 // *this class implements MI command "data-disassemble". 94 //-- 95 class CMICmdCmdDataDisassemble : public CMICmdBase { 96 // Statics: 97 public: 98 // Required by the CMICmdFactory when registering *this command 99 static CMICmdBase *CreateSelf(); 100 101 // Methods: 102 public: 103 /* ctor */ CMICmdCmdDataDisassemble(); 104 105 // Overridden: 106 public: 107 // From CMICmdInvoker::ICmd 108 bool Execute() override; 109 bool Acknowledge() override; 110 bool ParseArgs() override; 111 // From CMICmnBase 112 /* dtor */ ~CMICmdCmdDataDisassemble() override; 113 114 // Attributes: 115 private: 116 const CMIUtilString 117 m_constStrArgAddrStart; // MI spec non mandatory, *this command mandatory 118 const CMIUtilString 119 m_constStrArgAddrEnd; // MI spec non mandatory, *this command mandatory 120 const CMIUtilString m_constStrArgMode; 121 CMICmnMIValueList m_miValueList; 122 }; 123 124 //++ 125 //============================================================================ 126 // Details: MI command class. MI commands derived from the command base class. 127 // *this class implements MI command "data-read-memory-bytes". 128 //-- 129 class CMICmdCmdDataReadMemoryBytes : public CMICmdBase { 130 // Statics: 131 public: 132 // Required by the CMICmdFactory when registering *this command 133 static CMICmdBase *CreateSelf(); 134 135 // Methods: 136 public: 137 /* ctor */ CMICmdCmdDataReadMemoryBytes(); 138 139 // Overridden: 140 public: 141 // From CMICmdInvoker::ICmd 142 bool Execute() override; 143 bool Acknowledge() override; 144 bool ParseArgs() override; 145 // From CMICmnBase 146 /* dtor */ ~CMICmdCmdDataReadMemoryBytes() override; 147 148 // Attributes: 149 private: 150 const CMIUtilString m_constStrArgByteOffset; 151 const CMIUtilString m_constStrArgAddrExpr; 152 const CMIUtilString m_constStrArgNumBytes; 153 unsigned char *m_pBufferMemory; 154 MIuint64 m_nAddrStart; 155 MIuint64 m_nAddrNumBytesToRead; 156 }; 157 158 //++ 159 //============================================================================ 160 // Details: MI command class. MI commands derived from the command base class. 161 // *this class implements MI command "data-read-memory". 162 //-- 163 class CMICmdCmdDataReadMemory : public CMICmdBase { 164 // Statics: 165 public: 166 // Required by the CMICmdFactory when registering *this command 167 static CMICmdBase *CreateSelf(); 168 169 // Methods: 170 public: 171 /* ctor */ CMICmdCmdDataReadMemory(); 172 173 // Overridden: 174 public: 175 // From CMICmdInvoker::ICmd 176 bool Execute() override; 177 bool Acknowledge() override; 178 // From CMICmnBase 179 /* dtor */ ~CMICmdCmdDataReadMemory() override; 180 }; 181 182 //++ 183 //============================================================================ 184 // Details: MI command class. MI commands derived from the command base class. 185 // *this class implements MI command "data-list-register-names". 186 //-- 187 class CMICmdCmdDataListRegisterNames : public CMICmdBase { 188 // Statics: 189 public: 190 // Required by the CMICmdFactory when registering *this command 191 static CMICmdBase *CreateSelf(); 192 193 // Methods: 194 public: 195 /* ctor */ CMICmdCmdDataListRegisterNames(); 196 197 // Overridden: 198 public: 199 // From CMICmdInvoker::ICmd 200 bool Execute() override; 201 bool Acknowledge() override; 202 bool ParseArgs() override; 203 // From CMICmnBase 204 /* dtor */ ~CMICmdCmdDataListRegisterNames() override; 205 206 // Methods: 207 private: 208 lldb::SBValue GetRegister(const MIuint vRegisterIndex) const; 209 210 // Attributes: 211 private: 212 const CMIUtilString m_constStrArgRegNo; // Not handled by *this command 213 CMICmnMIValueList m_miValueList; 214 }; 215 216 //++ 217 //============================================================================ 218 // Details: MI command class. MI commands derived from the command base class. 219 // *this class implements MI command "data-list-register-values". 220 //-- 221 class CMICmdCmdDataListRegisterValues : public CMICmdBase { 222 // Statics: 223 public: 224 // Required by the CMICmdFactory when registering *this command 225 static CMICmdBase *CreateSelf(); 226 227 // Methods: 228 public: 229 /* ctor */ CMICmdCmdDataListRegisterValues(); 230 231 // Overridden: 232 public: 233 // From CMICmdInvoker::ICmd 234 bool Execute() override; 235 bool Acknowledge() override; 236 bool ParseArgs() override; 237 // From CMICmnBase 238 /* dtor */ ~CMICmdCmdDataListRegisterValues() override; 239 240 // Methods: 241 private: 242 lldb::SBValue GetRegister(const MIuint vRegisterIndex) const; 243 void AddToOutput(const MIuint vnIndex, const lldb::SBValue &vrValue, 244 CMICmnLLDBDebugSessionInfoVarObj::varFormat_e veVarFormat); 245 246 // Attributes: 247 private: 248 const CMIUtilString m_constStrArgSkip; // Not handled by *this command 249 const CMIUtilString m_constStrArgFormat; 250 const CMIUtilString m_constStrArgRegNo; 251 CMICmnMIValueList m_miValueList; 252 }; 253 254 //++ 255 //============================================================================ 256 // Details: MI command class. MI commands derived from the command base class. 257 // *this class implements MI command "data-list-changed-registers". 258 //-- 259 class CMICmdCmdDataListRegisterChanged : public CMICmdBase { 260 // Statics: 261 public: 262 // Required by the CMICmdFactory when registering *this command 263 static CMICmdBase *CreateSelf(); 264 265 // Methods: 266 public: 267 /* ctor */ CMICmdCmdDataListRegisterChanged(); 268 269 // Overridden: 270 public: 271 // From CMICmdInvoker::ICmd 272 bool Execute() override; 273 bool Acknowledge() override; 274 // From CMICmnBase 275 /* dtor */ ~CMICmdCmdDataListRegisterChanged() override; 276 }; 277 278 //++ 279 //============================================================================ 280 // Details: MI command class. MI commands derived from the command base class. 281 // *this class implements MI command "data-read-memory-bytes". 282 //-- 283 class CMICmdCmdDataWriteMemoryBytes : public CMICmdBase { 284 // Statics: 285 public: 286 // Required by the CMICmdFactory when registering *this command 287 static CMICmdBase *CreateSelf(); 288 289 // Methods: 290 public: 291 /* ctor */ CMICmdCmdDataWriteMemoryBytes(); 292 293 // Overridden: 294 public: 295 // From CMICmdInvoker::ICmd 296 bool Execute() override; 297 bool Acknowledge() override; 298 bool ParseArgs() override; 299 // From CMICmnBase 300 /* dtor */ ~CMICmdCmdDataWriteMemoryBytes() override; 301 302 // Attributes: 303 private: 304 const CMIUtilString m_constStrArgAddr; 305 const CMIUtilString m_constStrArgContents; 306 const CMIUtilString m_constStrArgCount; 307 CMIUtilString m_strContents; 308 }; 309 310 //++ 311 //============================================================================ 312 // Details: MI command class. MI commands derived from the command base class. 313 // *this class implements MI command "data-read-memory". 314 // Not specified in MI spec but Eclipse gives *this command. 315 //-- 316 class CMICmdCmdDataWriteMemory : public CMICmdBase { 317 // Statics: 318 public: 319 // Required by the CMICmdFactory when registering *this command 320 static CMICmdBase *CreateSelf(); 321 322 // Methods: 323 public: 324 /* ctor */ CMICmdCmdDataWriteMemory(); 325 326 // Overridden: 327 public: 328 // From CMICmdInvoker::ICmd 329 bool Execute() override; 330 bool Acknowledge() override; 331 bool ParseArgs() override; 332 // From CMICmnBase 333 /* dtor */ ~CMICmdCmdDataWriteMemory() override; 334 335 // Attributes: 336 private: 337 const CMIUtilString m_constStrArgOffset; // Not specified in MI spec but 338 // Eclipse gives this option. 339 const CMIUtilString m_constStrArgAddr; // Not specified in MI spec but Eclipse 340 // gives this option. 341 const CMIUtilString 342 m_constStrArgD; // Not specified in MI spec but Eclipse gives this option. 343 const CMIUtilString m_constStrArgNumber; // Not specified in MI spec but 344 // Eclipse gives this option. 345 const CMIUtilString m_constStrArgContents; // Not specified in MI spec but 346 // Eclipse gives this option. 347 MIuint64 m_nAddr; 348 CMIUtilString m_strContents; 349 MIuint64 m_nCount; 350 unsigned char *m_pBufferMemory; 351 }; 352 353 //++ 354 //============================================================================ 355 // Details: MI command class. MI commands derived from the command base class. 356 // *this class implements MI command "data-info-line". 357 // See MIExtensions.txt for details. 358 //-- 359 class CMICmdCmdDataInfoLine : public CMICmdBase { 360 // Statics: 361 public: 362 // Required by the CMICmdFactory when registering *this command 363 static CMICmdBase *CreateSelf(); 364 365 // Methods: 366 public: 367 /* ctor */ CMICmdCmdDataInfoLine(); 368 369 // Overridden: 370 public: 371 // From CMICmdInvoker::ICmd 372 bool Execute() override; 373 bool Acknowledge() override; 374 bool ParseArgs() override; 375 // From CMICmnBase 376 /* dtor */ ~CMICmdCmdDataInfoLine() override; 377 378 // Attributes: 379 private: 380 const CMIUtilString m_constStrArgLocation; 381 CMICmnMIResultRecord m_resultRecord; 382 }; 383