Changeset 5668 in vbox for trunk/src/VBox/Debugger/DBGConsole.cpp
- Timestamp:
- Nov 11, 2007 4:36:28 AM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 26012
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGConsole.cpp
r5666 r5668 125 125 #include <stdio.h> 126 126 127 /* to err.h! */ 128 #define VERR_DBGC_QUIT (-11999) 129 #define VERR_PARSE_FIRST (-11000) 130 #define VERR_PARSE_TOO_FEW_ARGUMENTS (VERR_PARSE_FIRST - 0) 131 #define VERR_PARSE_TOO_MANY_ARGUMENTS (VERR_PARSE_FIRST - 1) 132 #define VERR_PARSE_ARGUMENT_OVERFLOW (VERR_PARSE_FIRST - 2) 133 #define VERR_PARSE_ARGUMENT_TYPE_MISMATCH (VERR_PARSE_FIRST - 3) 134 #define VERR_PARSE_NO_RANGE_ALLOWED (VERR_PARSE_FIRST - 4) 135 #define VERR_PARSE_UNBALANCED_QUOTE (VERR_PARSE_FIRST - 5) 136 #define VERR_PARSE_UNBALANCED_PARENTHESIS (VERR_PARSE_FIRST - 6) 137 #define VERR_PARSE_EMPTY_ARGUMENT (VERR_PARSE_FIRST - 7) 138 #define VERR_PARSE_UNEXPECTED_OPERATOR (VERR_PARSE_FIRST - 8) 139 #define VERR_PARSE_INVALID_NUMBER (VERR_PARSE_FIRST - 9) 140 #define VERR_PARSE_NUMBER_TOO_BIG (VERR_PARSE_FIRST - 10) 141 #define VERR_PARSE_INVALID_OPERATION (VERR_PARSE_FIRST - 11) 142 #define VERR_PARSE_FUNCTION_NOT_FOUND (VERR_PARSE_FIRST - 12) 143 #define VERR_PARSE_NOT_A_FUNCTION (VERR_PARSE_FIRST - 13) 144 #define VERR_PARSE_NO_MEMORY (VERR_PARSE_FIRST - 14) 145 #define VERR_PARSE_INCORRECT_ARG_TYPE (VERR_PARSE_FIRST - 15) 146 #define VERR_PARSE_VARIABLE_NOT_FOUND (VERR_PARSE_FIRST - 16) 147 #define VERR_PARSE_CONVERSION_FAILED (VERR_PARSE_FIRST - 17) 148 #define VERR_PARSE_NOT_IMPLEMENTED (VERR_PARSE_FIRST - 18) 149 #define VERR_PARSE_BAD_RESULT_TYPE (VERR_PARSE_FIRST - 19) 150 #define VERR_PARSE_WRITEONLY_SYMBOL (VERR_PARSE_FIRST - 20) 151 #define VERR_PARSE_NO_ARGUMENT_MATCH (VERR_PARSE_FIRST - 21) 152 #define VERR_PARSE_LAST (VERR_PARSE_FIRST - 30) 153 154 #define VWRN_DBGC_CMD_PENDING 12000 155 #define VWRN_DBGC_ALREADY_REGISTERED 12001 156 #define VERR_DBGC_COMMANDS_NOT_REGISTERED (-12002) 157 #define VERR_DBGC_BP_NOT_FOUND (-12003) 158 #define VERR_DBGC_BP_EXISTS (-12004) 159 #define VINF_DBGC_BP_NO_COMMAND 12005 160 161 162 163 /******************************************************************************* 164 * Defined Constants And Macros * 165 *******************************************************************************/ 166 /** Makes a DBGC variable type pair. 167 * Typically used by binary operators. */ 168 #define BINARY_TYPE_PAIR(type1, type2) (type1 | (type2 << 16)) 169 170 171 /******************************************************************************* 172 * Structures and Typedefs * 173 *******************************************************************************/ 174 175 /** 176 * Debugger console per breakpoint data. 177 */ 178 typedef struct DBGCBP 179 { 180 /** Pointer to the next breakpoint in the list. */ 181 struct DBGCBP *pNext; 182 /** The breakpoint identifier. */ 183 RTUINT iBp; 184 /** The size of the command. */ 185 size_t cchCmd; 186 /** The command to execute when the breakpoint is hit. */ 187 char szCmd[1]; 188 } DBGCBP; 189 /** Pointer to a breakpoint. */ 190 typedef DBGCBP *PDBGCBP; 191 192 193 /** 194 * Named variable. 195 * 196 * Always allocated from heap in one signle block. 197 */ 198 typedef struct DBGCNAMEDVAR 199 { 200 /** The variable. */ 201 DBGCVAR Var; 202 /** It's name. */ 203 char szName[1]; 204 } DBGCNAMEDVAR; 205 /** Pointer to named variable. */ 206 typedef DBGCNAMEDVAR *PDBGCNAMEDVAR; 207 208 209 /** 210 * Debugger console status 211 */ 212 typedef enum DBGCSTATUS 213 { 214 /** Normal status, .*/ 215 DBGC_HALTED 216 217 } DBGCSTATUS; 218 219 220 /** 221 * Debugger console instance data. 222 */ 223 typedef struct DBGC 224 { 225 /** Command helpers. */ 226 DBGCCMDHLP CmdHlp; 227 /** Pointer to backend callback structure. */ 228 PDBGCBACK pBack; 229 230 /** Pointer to the current VM. */ 231 PVM pVM; 232 /** The current debugger emulation. */ 233 const char *pszEmulation; 234 /** Pointer to the command and functions for the current debugger emulation. */ 235 PCDBGCCMD paEmulationCmds; 236 /** The number of commands paEmulationCmds points to. */ 237 unsigned cEmulationCmds; 238 /** Log indicator. (If set we're writing the log to the console.) */ 239 bool fLog; 240 241 /** Indicates whether we're in guest (true) or hypervisor (false) register context. */ 242 bool fRegCtxGuest; 243 /** Indicates whether the register are terse or sparse. */ 244 bool fRegTerse; 245 246 /** Current dissassembler position. */ 247 DBGCVAR DisasmPos; 248 /** Current source position. (flat GC) */ 249 DBGCVAR SourcePos; 250 /** Current memory dump position. */ 251 DBGCVAR DumpPos; 252 /** Size of the previous dump element. */ 253 unsigned cbDumpElement; 254 255 /** Number of variables in papVars. */ 256 unsigned cVars; 257 /** Array of global variables. 258 * Global variables can be referenced using the $ operator and set 259 * and unset using command with those names. */ 260 PDBGCNAMEDVAR *papVars; 261 262 /** The list of breakpoints. (singly linked) */ 263 PDBGCBP pFirstBp; 264 265 /** @name Parsing and Execution 266 * @{ */ 267 268 /** Input buffer. */ 269 char achInput[2048]; 270 /** To ease debugging. */ 271 unsigned uInputZero; 272 /** Write index in the input buffer. */ 273 unsigned iWrite; 274 /** Read index in the input buffer. */ 275 unsigned iRead; 276 /** The number of lines in the buffer. */ 277 unsigned cInputLines; 278 /** Indicates that we have a buffer overflow condition. 279 * This means that input is ignored up to the next newline. */ 280 bool fInputOverflow; 281 /** Indicates whether or we're ready for input. */ 282 bool fReady; 283 284 /** Scratch buffer position. */ 285 char *pszScratch; 286 /** Scratch buffer. */ 287 char achScratch[16384]; 288 /** Argument array position. */ 289 unsigned iArg; 290 /** Array of argument variables. */ 291 DBGCVAR aArgs[100]; 292 293 /** rc from last dbgcHlpPrintfV(). */ 294 int rcOutput; 295 296 /** @} */ 297 } DBGC; 298 /** Pointer to debugger console instance data. */ 299 typedef DBGC *PDBGC; 300 301 /** Converts a Command Helper pointer to a pointer to DBGC instance data. */ 302 #define DBGC_CMDHLP2DBGC(pCmdHlp) ( (PDBGC)((uintptr_t)(pCmdHlp) - RT_OFFSETOF(DBGC, CmdHlp)) ) 303 304 305 /** 306 * Chunk of external commands. 307 */ 308 typedef struct DBGCEXTCMDS 309 { 310 /** Number of commands descriptors. */ 311 unsigned cCmds; 312 /** Pointer to array of command descriptors. */ 313 PCDBGCCMD paCmds; 314 /** Pointer to the next chunk. */ 315 struct DBGCEXTCMDS *pNext; 316 } DBGCEXTCMDS; 317 /** Pointer to chunk of external commands. */ 318 typedef DBGCEXTCMDS *PDBGCEXTCMDS; 319 320 321 322 /** 323 * Unary operator handler function. 324 * 325 * @returns 0 on success. 326 * @returns VBox evaluation / parsing error code on failure. 327 * The caller does the bitching. 328 * @param pDbgc Debugger console instance data. 329 * @param pArg The argument. 330 * @param pResult Where to store the result. 331 */ 332 typedef DECLCALLBACK(int) FNDBGCOPUNARY(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult); 333 /** Pointer to a unary operator handler function. */ 334 typedef FNDBGCOPUNARY *PFNDBGCOPUNARY; 335 336 337 /** 338 * Binary operator handler function. 339 * 340 * @returns 0 on success. 341 * @returns VBox evaluation / parsing error code on failure. 342 * The caller does the bitching. 343 * @param pDbgc Debugger console instance data. 344 * @param pArg1 The first argument. 345 * @param pArg2 The 2nd argument. 346 * @param pResult Where to store the result. 347 */ 348 typedef DECLCALLBACK(int) FNDBGCOPBINARY(PDBGC pDbgc, PCDBGCVAR pArg1, PCDBGCVAR pArg2, PDBGCVAR pResult); 349 /** Pointer to a binary operator handler function. */ 350 typedef FNDBGCOPBINARY *PFNDBGCOPBINARY; 351 352 353 /** 354 * Operator descriptor. 355 */ 356 typedef struct DBGCOP 357 { 358 /** Operator mnemonic. */ 359 char szName[4]; 360 /** Length of name. */ 361 const unsigned cchName; 362 /** Whether or not this is a binary operator. 363 * Unary operators are evaluated right-to-left while binary are left-to-right. */ 364 bool fBinary; 365 /** Precedence level. */ 366 unsigned iPrecedence; 367 /** Unary operator handler. */ 368 PFNDBGCOPUNARY pfnHandlerUnary; 369 /** Binary operator handler. */ 370 PFNDBGCOPBINARY pfnHandlerBinary; 371 /** Operator description. */ 372 const char *pszDescription; 373 } DBGCOP; 374 /** Pointer to an operator descriptor. */ 375 typedef DBGCOP *PDBGCOP; 376 /** Pointer to a const operator descriptor. */ 377 typedef const DBGCOP *PCDBGCOP; 378 379 380 381 /** Pointer to symbol descriptor. */ 382 typedef struct DBGCSYM *PDBGCSYM; 383 /** Pointer to const symbol descriptor. */ 384 typedef const struct DBGCSYM *PCDBGCSYM; 385 386 /** 387 * Get builtin symbol. 388 * 389 * @returns 0 on success. 390 * @returns VBox evaluation / parsing error code on failure. 391 * The caller does the bitching. 392 * @param pSymDesc Pointer to the symbol descriptor. 393 * @param pCmdHlp Pointer to the command callback structure. 394 * @param enmType The result type. 395 * @param pResult Where to store the result. 396 */ 397 typedef DECLCALLBACK(int) FNDBGCSYMGET(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, DBGCVARTYPE enmType, PDBGCVAR pResult); 398 /** Pointer to get function for a builtin symbol. */ 399 typedef FNDBGCSYMGET *PFNDBGCSYMGET; 400 401 /** 402 * Set builtin symbol. 403 * 404 * @returns 0 on success. 405 * @returns VBox evaluation / parsing error code on failure. 406 * The caller does the bitching. 407 * @param pSymDesc Pointer to the symbol descriptor. 408 * @param pCmdHlp Pointer to the command callback structure. 409 * @param pValue The value to assign the symbol. 410 */ 411 typedef DECLCALLBACK(int) FNDBGCSYMSET(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, PCDBGCVAR pValue); 412 /** Pointer to set function for a builtin symbol. */ 413 typedef FNDBGCSYMSET *PFNDBGCSYMSET; 414 415 416 /** 417 * Symbol description (for builtin symbols). 418 */ 419 typedef struct DBGCSYM 420 { 421 /** Symbol name. */ 422 const char *pszName; 423 /** Get function. */ 424 PFNDBGCSYMGET pfnGet; 425 /** Set function. (NULL if readonly) */ 426 PFNDBGCSYMSET pfnSet; 427 /** User data. */ 428 unsigned uUser; 429 } DBGCSYM; 127 #include "DBGCInternal.h" 430 128 431 129
Note:
See TracChangeset
for help on using the changeset viewer.