[31510] | 1 | /* $Id: DBGCInternal.h 105536 2024-07-30 01:08:28Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * DBGC - Debugger Console, Internal Header File.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[31510] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[31510] | 26 | */
|
---|
| 27 |
|
---|
[76564] | 28 | #ifndef DEBUGGER_INCLUDED_SRC_DBGCInternal_h
|
---|
| 29 | #define DEBUGGER_INCLUDED_SRC_DBGCInternal_h
|
---|
[76518] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[31510] | 33 |
|
---|
| 34 |
|
---|
| 35 | /*******************************************************************************
|
---|
| 36 | * Header Files *
|
---|
| 37 | *******************************************************************************/
|
---|
| 38 | #include <VBox/dbg.h>
|
---|
[41553] | 39 | #include <VBox/err.h>
|
---|
[87788] | 40 | #include <VBox/vmm/dbgf.h>
|
---|
| 41 | #include <VBox/vmm/dbgfflowtrace.h>
|
---|
[31510] | 42 |
|
---|
[87788] | 43 | #include <iprt/list.h>
|
---|
[31510] | 44 |
|
---|
| 45 | /*******************************************************************************
|
---|
| 46 | * Structures and Typedefs *
|
---|
| 47 | *******************************************************************************/
|
---|
| 48 |
|
---|
| 49 | /**
|
---|
| 50 | * Debugger console per breakpoint data.
|
---|
| 51 | */
|
---|
| 52 | typedef struct DBGCBP
|
---|
| 53 | {
|
---|
| 54 | /** Pointer to the next breakpoint in the list. */
|
---|
| 55 | struct DBGCBP *pNext;
|
---|
| 56 | /** The breakpoint identifier. */
|
---|
[35694] | 57 | uint32_t iBp;
|
---|
[31510] | 58 | /** The size of the command. */
|
---|
| 59 | size_t cchCmd;
|
---|
| 60 | /** The command to execute when the breakpoint is hit. */
|
---|
| 61 | char szCmd[1];
|
---|
| 62 | } DBGCBP;
|
---|
| 63 | /** Pointer to a breakpoint. */
|
---|
| 64 | typedef DBGCBP *PDBGCBP;
|
---|
| 65 |
|
---|
| 66 |
|
---|
[59072] | 67 | typedef enum DBGCEVTSTATE
|
---|
| 68 | {
|
---|
| 69 | kDbgcEvtState_Invalid = 0,
|
---|
| 70 | kDbgcEvtState_Disabled,
|
---|
| 71 | kDbgcEvtState_Enabled,
|
---|
| 72 | kDbgcEvtState_Notify
|
---|
| 73 | } DBGCEVTSTATE;
|
---|
| 74 |
|
---|
[31510] | 75 | /**
|
---|
[59072] | 76 | * Debugger console per event configuration.
|
---|
| 77 | */
|
---|
| 78 | typedef struct DBGCEVTCFG
|
---|
| 79 | {
|
---|
| 80 | /** The event state. */
|
---|
| 81 | DBGCEVTSTATE enmState;
|
---|
| 82 | /** The size of the command. */
|
---|
| 83 | size_t cchCmd;
|
---|
| 84 | /** The command to execute when the event occurs. */
|
---|
| 85 | char szCmd[1];
|
---|
| 86 | } DBGCEVTCFG;
|
---|
| 87 | /** Pointer to a event configuration. */
|
---|
| 88 | typedef DBGCEVTCFG *PDBGCEVTCFG;
|
---|
| 89 | /** Pointer to a const event configuration. */
|
---|
| 90 | typedef DBGCEVTCFG const *PCDBGCEVTCFG;
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | /**
|
---|
[31510] | 94 | * Named variable.
|
---|
| 95 | *
|
---|
[33540] | 96 | * Always allocated from heap in one single block.
|
---|
[31510] | 97 | */
|
---|
| 98 | typedef struct DBGCNAMEDVAR
|
---|
| 99 | {
|
---|
| 100 | /** The variable. */
|
---|
| 101 | DBGCVAR Var;
|
---|
| 102 | /** Its name. */
|
---|
| 103 | char szName[1];
|
---|
| 104 | } DBGCNAMEDVAR;
|
---|
| 105 | /** Pointer to named variable. */
|
---|
| 106 | typedef DBGCNAMEDVAR *PDBGCNAMEDVAR;
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | /**
|
---|
[87788] | 110 | * Debugger console per trace flow data.
|
---|
| 111 | */
|
---|
| 112 | typedef struct DBGCTFLOW
|
---|
| 113 | {
|
---|
| 114 | /** Node for the trace flow module list. */
|
---|
| 115 | RTLISTNODE NdTraceFlow;
|
---|
| 116 | /** Handle of the DGF trace flow module. */
|
---|
| 117 | DBGFFLOWTRACEMOD hTraceFlowMod;
|
---|
| 118 | /** The control flow graph for the module. */
|
---|
| 119 | DBGFFLOW hFlow;
|
---|
| 120 | /** The trace flow module identifier. */
|
---|
| 121 | uint32_t iTraceFlowMod;
|
---|
| 122 | } DBGCTFLOW;
|
---|
| 123 | /** Pointer to the per trace flow data. */
|
---|
| 124 | typedef DBGCTFLOW *PDBGCTFLOW;
|
---|
| 125 |
|
---|
| 126 |
|
---|
| 127 | /**
|
---|
[31510] | 128 | * Debugger console status
|
---|
| 129 | */
|
---|
| 130 | typedef enum DBGCSTATUS
|
---|
| 131 | {
|
---|
| 132 | /** Normal status, .*/
|
---|
| 133 | DBGC_HALTED
|
---|
| 134 |
|
---|
| 135 | } DBGCSTATUS;
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | /**
|
---|
| 139 | * Debugger console instance data.
|
---|
| 140 | */
|
---|
| 141 | typedef struct DBGC
|
---|
| 142 | {
|
---|
| 143 | /** Command helpers. */
|
---|
| 144 | DBGCCMDHLP CmdHlp;
|
---|
[31966] | 145 | /** Wrappers for DBGF output. */
|
---|
| 146 | DBGFINFOHLP DbgfOutputHlp;
|
---|
[86327] | 147 | /** Pointer to I/O callback structure. */
|
---|
| 148 | PCDBGCIO pIo;
|
---|
[31510] | 149 |
|
---|
[84653] | 150 | /**
|
---|
| 151 | * Output a bunch of characters.
|
---|
| 152 | *
|
---|
| 153 | * @returns VBox status code.
|
---|
| 154 | * @param pvUser Opaque user data from DBGC::pvOutputUser.
|
---|
| 155 | * @param pachChars Pointer to an array of utf-8 characters.
|
---|
| 156 | * @param cbChars Number of bytes in the character array pointed to by pachChars.
|
---|
| 157 | */
|
---|
| 158 | DECLR3CALLBACKMEMBER(int, pfnOutput, (void *pvUser, const char *pachChars, size_t cbChars));
|
---|
| 159 | /** Opqaue user data passed to DBGC::pfnOutput. */
|
---|
| 160 | void *pvOutputUser;
|
---|
| 161 |
|
---|
[31510] | 162 | /** Pointer to the current VM. */
|
---|
| 163 | PVM pVM;
|
---|
[44399] | 164 | /** The user mode handle of the current VM. */
|
---|
| 165 | PUVM pUVM;
|
---|
[35629] | 166 | /** The ID of current virtual CPU. */
|
---|
[31510] | 167 | VMCPUID idCpu;
|
---|
| 168 | /** The current address space handle. */
|
---|
| 169 | RTDBGAS hDbgAs;
|
---|
| 170 | /** The current debugger emulation. */
|
---|
| 171 | const char *pszEmulation;
|
---|
[41561] | 172 | /** Pointer to the commands for the current debugger emulation. */
|
---|
[31510] | 173 | PCDBGCCMD paEmulationCmds;
|
---|
| 174 | /** The number of commands paEmulationCmds points to. */
|
---|
[59229] | 175 | uint32_t cEmulationCmds;
|
---|
[41561] | 176 | /** Pointer to the functions for the current debugger emulation. */
|
---|
| 177 | PCDBGCFUNC paEmulationFuncs;
|
---|
| 178 | /** The number of functions paEmulationFuncs points to. */
|
---|
| 179 | uint32_t cEmulationFuncs;
|
---|
[31510] | 180 | /** Log indicator. (If set we're writing the log to the console.) */
|
---|
| 181 | bool fLog;
|
---|
| 182 |
|
---|
[83088] | 183 | /** Counter use to suppress the printing of the headers. */
|
---|
| 184 | uint8_t cPagingHierarchyDumps;
|
---|
[31510] | 185 | /** Indicates whether the register are terse or sparse. */
|
---|
| 186 | bool fRegTerse;
|
---|
[83088] | 187 |
|
---|
| 188 | /** @name Stepping
|
---|
| 189 | * @{ */
|
---|
[64721] | 190 | /** Whether to display registers when tracing. */
|
---|
| 191 | bool fStepTraceRegs;
|
---|
[83088] | 192 | /** Number of multi-steps left, zero if not multi-stepping. */
|
---|
| 193 | uint32_t cMultiStepsLeft;
|
---|
| 194 | /** The multi-step stride length. */
|
---|
| 195 | uint32_t uMultiStepStrideLength;
|
---|
| 196 | /** The active multi-step command. */
|
---|
| 197 | PCDBGCCMD pMultiStepCmd;
|
---|
| 198 | /** @} */
|
---|
[31510] | 199 |
|
---|
[33540] | 200 | /** Current disassembler position. */
|
---|
[31510] | 201 | DBGCVAR DisasmPos;
|
---|
[47569] | 202 | /** The flags that goes with DisasmPos. */
|
---|
| 203 | uint32_t fDisasm;
|
---|
[31510] | 204 | /** Current source position. (flat GC) */
|
---|
| 205 | DBGCVAR SourcePos;
|
---|
| 206 | /** Current memory dump position. */
|
---|
| 207 | DBGCVAR DumpPos;
|
---|
| 208 | /** Size of the previous dump element. */
|
---|
| 209 | unsigned cbDumpElement;
|
---|
[31966] | 210 | /** Points to DisasmPos, SourcePos or DumpPos depending on which was
|
---|
| 211 | * used last. */
|
---|
| 212 | PCDBGCVAR pLastPos;
|
---|
[31510] | 213 |
|
---|
| 214 | /** Number of variables in papVars. */
|
---|
| 215 | unsigned cVars;
|
---|
| 216 | /** Array of global variables.
|
---|
| 217 | * Global variables can be referenced using the $ operator and set
|
---|
| 218 | * and unset using command with those names. */
|
---|
| 219 | PDBGCNAMEDVAR *papVars;
|
---|
| 220 |
|
---|
| 221 | /** The list of breakpoints. (singly linked) */
|
---|
| 222 | PDBGCBP pFirstBp;
|
---|
[87788] | 223 | /** The list of known trace flow modules. */
|
---|
| 224 | RTLISTANCHOR LstTraceFlowMods;
|
---|
[31510] | 225 |
|
---|
[59072] | 226 | /** Software interrupt events. */
|
---|
| 227 | PDBGCEVTCFG apSoftInts[256];
|
---|
| 228 | /** Hardware interrupt events. */
|
---|
| 229 | PDBGCEVTCFG apHardInts[256];
|
---|
| 230 | /** Selectable events (first few entries are unused). */
|
---|
| 231 | PDBGCEVTCFG apEventCfgs[DBGFEVENT_END];
|
---|
| 232 |
|
---|
[31510] | 233 | /** Save search pattern. */
|
---|
| 234 | uint8_t abSearch[256];
|
---|
| 235 | /** The length of the search pattern. */
|
---|
| 236 | uint32_t cbSearch;
|
---|
| 237 | /** The search unit */
|
---|
| 238 | uint32_t cbSearchUnit;
|
---|
| 239 | /** The max hits. */
|
---|
| 240 | uint64_t cMaxSearchHits;
|
---|
| 241 | /** The address to resume searching from. */
|
---|
| 242 | DBGFADDRESS SearchAddr;
|
---|
| 243 | /** What's left of the original search range. */
|
---|
| 244 | RTGCUINTPTR cbSearchRange;
|
---|
| 245 |
|
---|
| 246 | /** @name Parsing and Execution
|
---|
| 247 | * @{ */
|
---|
| 248 |
|
---|
| 249 | /** Input buffer. */
|
---|
| 250 | char achInput[2048];
|
---|
| 251 | /** To ease debugging. */
|
---|
| 252 | unsigned uInputZero;
|
---|
| 253 | /** Write index in the input buffer. */
|
---|
| 254 | unsigned iWrite;
|
---|
| 255 | /** Read index in the input buffer. */
|
---|
| 256 | unsigned iRead;
|
---|
| 257 | /** The number of lines in the buffer. */
|
---|
| 258 | unsigned cInputLines;
|
---|
| 259 | /** Indicates that we have a buffer overflow condition.
|
---|
| 260 | * This means that input is ignored up to the next newline. */
|
---|
| 261 | bool fInputOverflow;
|
---|
| 262 | /** Indicates whether or we're ready for input. */
|
---|
| 263 | bool fReady;
|
---|
| 264 | /** Scratch buffer position. */
|
---|
| 265 | char *pszScratch;
|
---|
| 266 | /** Scratch buffer. */
|
---|
| 267 | char achScratch[16384];
|
---|
| 268 | /** Argument array position. */
|
---|
| 269 | unsigned iArg;
|
---|
| 270 | /** Array of argument variables. */
|
---|
| 271 | DBGCVAR aArgs[100];
|
---|
| 272 |
|
---|
| 273 | /** rc from the last dbgcHlpPrintfV(). */
|
---|
| 274 | int rcOutput;
|
---|
[35694] | 275 | /** The last character we wrote. */
|
---|
| 276 | char chLastOutput;
|
---|
| 277 |
|
---|
[31510] | 278 | /** rc from the last command. */
|
---|
| 279 | int rcCmd;
|
---|
| 280 | /** @} */
|
---|
[59229] | 281 |
|
---|
| 282 | /** The command history file (not yet implemented). */
|
---|
| 283 | char *pszHistoryFile;
|
---|
| 284 | /** The global debugger init script. */
|
---|
| 285 | char *pszGlobalInitScript;
|
---|
| 286 | /** The per VM debugger init script. */
|
---|
| 287 | char *pszLocalInitScript;
|
---|
[31510] | 288 | } DBGC;
|
---|
| 289 | /** Pointer to debugger console instance data. */
|
---|
| 290 | typedef DBGC *PDBGC;
|
---|
| 291 |
|
---|
| 292 | /** Converts a Command Helper pointer to a pointer to DBGC instance data. */
|
---|
[73097] | 293 | #define DBGC_CMDHLP2DBGC(pCmdHlp) ( (PDBGC)((uintptr_t)(pCmdHlp) - RT_UOFFSETOF(DBGC, CmdHlp)) )
|
---|
[31510] | 294 |
|
---|
| 295 |
|
---|
| 296 | /**
|
---|
| 297 | * Chunk of external commands.
|
---|
| 298 | */
|
---|
| 299 | typedef struct DBGCEXTCMDS
|
---|
| 300 | {
|
---|
| 301 | /** Number of commands descriptors. */
|
---|
| 302 | unsigned cCmds;
|
---|
| 303 | /** Pointer to array of command descriptors. */
|
---|
| 304 | PCDBGCCMD paCmds;
|
---|
| 305 | /** Pointer to the next chunk. */
|
---|
| 306 | struct DBGCEXTCMDS *pNext;
|
---|
| 307 | } DBGCEXTCMDS;
|
---|
| 308 | /** Pointer to chunk of external commands. */
|
---|
| 309 | typedef DBGCEXTCMDS *PDBGCEXTCMDS;
|
---|
| 310 |
|
---|
| 311 |
|
---|
[41561] | 312 | /**
|
---|
| 313 | * Chunk of external functions.
|
---|
| 314 | */
|
---|
| 315 | typedef struct DBGCEXTFUNCS
|
---|
| 316 | {
|
---|
| 317 | /** Number of functions descriptors. */
|
---|
| 318 | uint32_t cFuncs;
|
---|
| 319 | /** Pointer to array of functions descriptors. */
|
---|
| 320 | PCDBGCFUNC paFuncs;
|
---|
| 321 | /** Pointer to the next chunk. */
|
---|
| 322 | struct DBGCEXTFUNCS *pNext;
|
---|
| 323 | } DBGCEXTFUNCS;
|
---|
| 324 | /** Pointer to chunk of external functions. */
|
---|
| 325 | typedef DBGCEXTFUNCS *PDBGCEXTFUNCS;
|
---|
[31510] | 326 |
|
---|
[41561] | 327 |
|
---|
| 328 |
|
---|
[31510] | 329 | /**
|
---|
| 330 | * Unary operator handler function.
|
---|
| 331 | *
|
---|
| 332 | * @returns 0 on success.
|
---|
| 333 | * @returns VBox evaluation / parsing error code on failure.
|
---|
| 334 | * The caller does the bitching.
|
---|
| 335 | * @param pDbgc Debugger console instance data.
|
---|
| 336 | * @param pArg The argument.
|
---|
[41546] | 337 | * @param enmCat The desired result category. Can be ignored.
|
---|
[31510] | 338 | * @param pResult Where to store the result.
|
---|
| 339 | */
|
---|
[85121] | 340 | typedef DECLCALLBACKTYPE(int, FNDBGCOPUNARY,(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult));
|
---|
[31510] | 341 | /** Pointer to a unary operator handler function. */
|
---|
| 342 | typedef FNDBGCOPUNARY *PFNDBGCOPUNARY;
|
---|
| 343 |
|
---|
| 344 |
|
---|
| 345 | /**
|
---|
| 346 | * Binary operator handler function.
|
---|
| 347 | *
|
---|
| 348 | * @returns 0 on success.
|
---|
| 349 | * @returns VBox evaluation / parsing error code on failure.
|
---|
| 350 | * The caller does the bitching.
|
---|
| 351 | * @param pDbgc Debugger console instance data.
|
---|
| 352 | * @param pArg1 The first argument.
|
---|
| 353 | * @param pArg2 The 2nd argument.
|
---|
| 354 | * @param pResult Where to store the result.
|
---|
| 355 | */
|
---|
[85121] | 356 | typedef DECLCALLBACKTYPE(int, FNDBGCOPBINARY,(PDBGC pDbgc, PCDBGCVAR pArg1, PCDBGCVAR pArg2, PDBGCVAR pResult));
|
---|
[31510] | 357 | /** Pointer to a binary operator handler function. */
|
---|
| 358 | typedef FNDBGCOPBINARY *PFNDBGCOPBINARY;
|
---|
| 359 |
|
---|
| 360 |
|
---|
| 361 | /**
|
---|
| 362 | * Operator descriptor.
|
---|
| 363 | */
|
---|
| 364 | typedef struct DBGCOP
|
---|
| 365 | {
|
---|
| 366 | /** Operator mnemonic. */
|
---|
| 367 | char szName[4];
|
---|
| 368 | /** Length of name. */
|
---|
| 369 | const unsigned cchName;
|
---|
| 370 | /** Whether or not this is a binary operator.
|
---|
| 371 | * Unary operators are evaluated right-to-left while binary are left-to-right. */
|
---|
| 372 | bool fBinary;
|
---|
| 373 | /** Precedence level. */
|
---|
| 374 | unsigned iPrecedence;
|
---|
| 375 | /** Unary operator handler. */
|
---|
| 376 | PFNDBGCOPUNARY pfnHandlerUnary;
|
---|
| 377 | /** Binary operator handler. */
|
---|
| 378 | PFNDBGCOPBINARY pfnHandlerBinary;
|
---|
[35637] | 379 | /** The category of the 1st argument.
|
---|
| 380 | * Set to DBGCVAR_CAT_ANY if anything goes. */
|
---|
| 381 | DBGCVARCAT enmCatArg1;
|
---|
| 382 | /** The category of the 2nd argument.
|
---|
| 383 | * Set to DBGCVAR_CAT_ANY if anything goes. */
|
---|
| 384 | DBGCVARCAT enmCatArg2;
|
---|
[31510] | 385 | /** Operator description. */
|
---|
| 386 | const char *pszDescription;
|
---|
| 387 | } DBGCOP;
|
---|
| 388 | /** Pointer to an operator descriptor. */
|
---|
| 389 | typedef DBGCOP *PDBGCOP;
|
---|
| 390 | /** Pointer to a const operator descriptor. */
|
---|
| 391 | typedef const DBGCOP *PCDBGCOP;
|
---|
| 392 |
|
---|
| 393 |
|
---|
| 394 |
|
---|
| 395 | /** Pointer to symbol descriptor. */
|
---|
| 396 | typedef struct DBGCSYM *PDBGCSYM;
|
---|
| 397 | /** Pointer to const symbol descriptor. */
|
---|
| 398 | typedef const struct DBGCSYM *PCDBGCSYM;
|
---|
| 399 |
|
---|
| 400 | /**
|
---|
| 401 | * Get builtin symbol.
|
---|
| 402 | *
|
---|
| 403 | * @returns 0 on success.
|
---|
| 404 | * @returns VBox evaluation / parsing error code on failure.
|
---|
| 405 | * The caller does the bitching.
|
---|
| 406 | * @param pSymDesc Pointer to the symbol descriptor.
|
---|
| 407 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
| 408 | * @param enmType The result type.
|
---|
| 409 | * @param pResult Where to store the result.
|
---|
| 410 | */
|
---|
[85121] | 411 | typedef DECLCALLBACKTYPE(int, FNDBGCSYMGET,(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, DBGCVARTYPE enmType, PDBGCVAR pResult));
|
---|
[31510] | 412 | /** Pointer to get function for a builtin symbol. */
|
---|
| 413 | typedef FNDBGCSYMGET *PFNDBGCSYMGET;
|
---|
| 414 |
|
---|
| 415 | /**
|
---|
| 416 | * Set builtin symbol.
|
---|
| 417 | *
|
---|
| 418 | * @returns 0 on success.
|
---|
| 419 | * @returns VBox evaluation / parsing error code on failure.
|
---|
| 420 | * The caller does the bitching.
|
---|
| 421 | * @param pSymDesc Pointer to the symbol descriptor.
|
---|
| 422 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
| 423 | * @param pValue The value to assign the symbol.
|
---|
| 424 | */
|
---|
[85121] | 425 | typedef DECLCALLBACKTYPE(int, FNDBGCSYMSET,(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, PCDBGCVAR pValue));
|
---|
[31510] | 426 | /** Pointer to set function for a builtin symbol. */
|
---|
| 427 | typedef FNDBGCSYMSET *PFNDBGCSYMSET;
|
---|
| 428 |
|
---|
| 429 |
|
---|
| 430 | /**
|
---|
| 431 | * Symbol description (for builtin symbols).
|
---|
| 432 | */
|
---|
| 433 | typedef struct DBGCSYM
|
---|
| 434 | {
|
---|
| 435 | /** Symbol name. */
|
---|
| 436 | const char *pszName;
|
---|
| 437 | /** Get function. */
|
---|
| 438 | PFNDBGCSYMGET pfnGet;
|
---|
| 439 | /** Set function. (NULL if readonly) */
|
---|
| 440 | PFNDBGCSYMSET pfnSet;
|
---|
| 441 | /** User data. */
|
---|
| 442 | unsigned uUser;
|
---|
| 443 | } DBGCSYM;
|
---|
| 444 |
|
---|
| 445 |
|
---|
[59072] | 446 | /** Selectable debug event kind. */
|
---|
| 447 | typedef enum
|
---|
| 448 | {
|
---|
| 449 | kDbgcSxEventKind_Plain,
|
---|
| 450 | kDbgcSxEventKind_Interrupt
|
---|
| 451 | } DBGCSXEVENTKIND;
|
---|
| 452 |
|
---|
| 453 | /**
|
---|
| 454 | * Selectable debug event name / type lookup table entry.
|
---|
| 455 | *
|
---|
| 456 | * This also contains the default setting and an alternative name.
|
---|
| 457 | */
|
---|
| 458 | typedef struct DBGCSXEVT
|
---|
| 459 | {
|
---|
[59246] | 460 | /** The event type. */
|
---|
[59072] | 461 | DBGFEVENTTYPE enmType;
|
---|
[59246] | 462 | /** The event name. */
|
---|
[59072] | 463 | const char *pszName;
|
---|
[59246] | 464 | /** Alternative event name (optional). */
|
---|
[59072] | 465 | const char *pszAltNm;
|
---|
[59246] | 466 | /** The kind of event. */
|
---|
[59072] | 467 | DBGCSXEVENTKIND enmKind;
|
---|
[59246] | 468 | /** The default state. */
|
---|
[59072] | 469 | DBGCEVTSTATE enmDefault;
|
---|
[59246] | 470 | /** Flags, DBGCSXEVT_F_XXX. */
|
---|
| 471 | uint32_t fFlags;
|
---|
| 472 | /** Description for use when reporting the event, optional. */
|
---|
| 473 | const char *pszDesc;
|
---|
[59072] | 474 | } DBGCSXEVT;
|
---|
| 475 | /** Pointer to a constant selectable debug event descriptor. */
|
---|
| 476 | typedef DBGCSXEVT const *PCDBGCSXEVT;
|
---|
| 477 |
|
---|
[59246] | 478 | /** @name DBGCSXEVT_F_XXX
|
---|
| 479 | * @{ */
|
---|
| 480 | #define DBGCSXEVT_F_TAKE_ARG RT_BIT_32(0)
|
---|
[73348] | 481 | /** Windows bugcheck, should take 5 arguments. */
|
---|
| 482 | #define DBGCSXEVT_F_BUGCHECK RT_BIT_32(1)
|
---|
[59246] | 483 | /** @} */
|
---|
[59072] | 484 |
|
---|
[59246] | 485 |
|
---|
[64554] | 486 | /**
|
---|
| 487 | * Control flow graph basic block dumper state
|
---|
| 488 | */
|
---|
[64559] | 489 | typedef struct DBGCFLOWBBDUMP
|
---|
[64554] | 490 | {
|
---|
| 491 | /** The basic block referenced. */
|
---|
[64559] | 492 | DBGFFLOWBB hFlowBb;
|
---|
[64554] | 493 | /** Cached start address. */
|
---|
| 494 | DBGFADDRESS AddrStart;
|
---|
| 495 | /** Target address. */
|
---|
| 496 | DBGFADDRESS AddrTarget;
|
---|
| 497 | /** Width of the basic block in chars. */
|
---|
| 498 | uint32_t cchWidth;
|
---|
| 499 | /** Height of the basic block in chars. */
|
---|
| 500 | uint32_t cchHeight;
|
---|
| 501 | /** X coordinate of the start. */
|
---|
| 502 | uint32_t uStartX;
|
---|
| 503 | /** Y coordinate of the start. */
|
---|
| 504 | uint32_t uStartY;
|
---|
[64559] | 505 | } DBGCFLOWBBDUMP;
|
---|
[64591] | 506 | /** Pointer to the control flow graph basic block dump state. */
|
---|
[64559] | 507 | typedef DBGCFLOWBBDUMP *PDBGCFLOWBBDUMP;
|
---|
[64554] | 508 |
|
---|
[64591] | 509 |
|
---|
| 510 | /**
|
---|
| 511 | * Control flow graph branch table dumper state.
|
---|
| 512 | */
|
---|
| 513 | typedef struct DBGCFLOWBRANCHTBLDUMP
|
---|
| 514 | {
|
---|
| 515 | /** The branch table referenced. */
|
---|
| 516 | DBGFFLOWBRANCHTBL hFlowBranchTbl;
|
---|
| 517 | /** Cached start address. */
|
---|
| 518 | DBGFADDRESS AddrStart;
|
---|
| 519 | /** Width of the branch table in chars. */
|
---|
| 520 | uint32_t cchWidth;
|
---|
| 521 | /** Height of the branch table in chars. */
|
---|
| 522 | uint32_t cchHeight;
|
---|
| 523 | /** X coordinate of the start. */
|
---|
| 524 | uint32_t uStartX;
|
---|
| 525 | /** Y coordinate of the start. */
|
---|
| 526 | uint32_t uStartY;
|
---|
| 527 | } DBGCFLOWBRANCHTBLDUMP;
|
---|
| 528 | /** Pointer to control flow graph branch table state. */
|
---|
| 529 | typedef DBGCFLOWBRANCHTBLDUMP *PDBGCFLOWBRANCHTBLDUMP;
|
---|
| 530 |
|
---|
[105536] | 531 |
|
---|
[31510] | 532 | /*******************************************************************************
|
---|
| 533 | * Internal Functions *
|
---|
| 534 | *******************************************************************************/
|
---|
| 535 | int dbgcBpAdd(PDBGC pDbgc, RTUINT iBp, const char *pszCmd);
|
---|
| 536 | int dbgcBpUpdate(PDBGC pDbgc, RTUINT iBp, const char *pszCmd);
|
---|
| 537 | int dbgcBpDelete(PDBGC pDbgc, RTUINT iBp);
|
---|
| 538 | PDBGCBP dbgcBpGet(PDBGC pDbgc, RTUINT iBp);
|
---|
| 539 | int dbgcBpExec(PDBGC pDbgc, RTUINT iBp);
|
---|
| 540 |
|
---|
[87788] | 541 | DECLHIDDEN(PDBGCTFLOW) dbgcFlowTraceModGet(PDBGC pDbgc, uint32_t iTraceFlowMod);
|
---|
| 542 | DECLHIDDEN(int) dbgcFlowTraceModAdd(PDBGC pDbgc, DBGFFLOWTRACEMOD hFlowTraceMod, DBGFFLOW hFlow, uint32_t *piId);
|
---|
| 543 | DECLHIDDEN(int) dbgcFlowTraceModDelete(PDBGC pDbgc, uint32_t iFlowTraceMod);
|
---|
| 544 |
|
---|
[35628] | 545 | void dbgcEvalInit(void);
|
---|
[35637] | 546 | int dbgcEvalSub(PDBGC pDbgc, char *pszExpr, size_t cchExpr, DBGCVARCAT enmCategory, PDBGCVAR pResult);
|
---|
[35628] | 547 | int dbgcEvalCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd, bool fNoExecute);
|
---|
[97728] | 548 | int dbgcEvalCommands(PDBGC pDbgc, char *pszCmds, size_t cchCmds, bool fNoExecute);
|
---|
[59229] | 549 | int dbgcEvalScript(PDBGC pDbgc, const char *pszFilename, bool fAnnounce);
|
---|
[31510] | 550 |
|
---|
| 551 | int dbgcSymbolGet(PDBGC pDbgc, const char *pszSymbol, DBGCVARTYPE enmType, PDBGCVAR pResult);
|
---|
| 552 | PCDBGCSYM dbgcLookupRegisterSymbol(PDBGC pDbgc, const char *pszSymbol);
|
---|
| 553 | PCDBGCOP dbgcOperatorLookup(PDBGC pDbgc, const char *pszExpr, bool fPreferBinary, char chPrev);
|
---|
[41561] | 554 | PCDBGCCMD dbgcCommandLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal);
|
---|
| 555 | PCDBGCFUNC dbgcFunctionLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal);
|
---|
[31510] | 556 |
|
---|
[41546] | 557 | DECLCALLBACK(int) dbgcOpRegister(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
|
---|
| 558 | DECLCALLBACK(int) dbgcOpAddrFlat(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
|
---|
| 559 | DECLCALLBACK(int) dbgcOpAddrHost(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
|
---|
| 560 | DECLCALLBACK(int) dbgcOpAddrPhys(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
|
---|
| 561 | DECLCALLBACK(int) dbgcOpAddrHostPhys(PDBGC pDbgc, PCDBGCVAR pArg, DBGCVARCAT enmCat, PDBGCVAR pResult);
|
---|
[31510] | 562 |
|
---|
| 563 | void dbgcInitCmdHlp(PDBGC pDbgc);
|
---|
| 564 |
|
---|
[59072] | 565 | void dbgcEventInit(PDBGC pDbgc);
|
---|
| 566 | void dbgcEventTerm(PDBGC pDbgc);
|
---|
| 567 |
|
---|
[64554] | 568 | /** Console ASCII screen handle. */
|
---|
| 569 | typedef struct DBGCSCREENINT *DBGCSCREEN;
|
---|
| 570 | /** Pointer to ASCII screen handle. */
|
---|
| 571 | typedef DBGCSCREEN *PDBGCSCREEN;
|
---|
[59072] | 572 |
|
---|
[64554] | 573 | /**
|
---|
| 574 | * ASCII screen blit callback.
|
---|
| 575 | *
|
---|
| 576 | * @returns VBox status code. Any non VINF_SUCCESS status code will abort the dumping.
|
---|
| 577 | *
|
---|
| 578 | * @param psz The string to dump
|
---|
| 579 | * @param pvUser Opaque user data.
|
---|
| 580 | */
|
---|
[85121] | 581 | typedef DECLCALLBACKTYPE(int, FNDGCSCREENBLIT,(const char *psz, void *pvUser));
|
---|
[64554] | 582 | /** Pointer to a FNDGCSCREENBLIT. */
|
---|
| 583 | typedef FNDGCSCREENBLIT *PFNDGCSCREENBLIT;
|
---|
| 584 |
|
---|
| 585 | /**
|
---|
| 586 | * ASCII screen supported colors.
|
---|
| 587 | */
|
---|
| 588 | typedef enum DBGCSCREENCOLOR
|
---|
| 589 | {
|
---|
| 590 | /** Invalid color. */
|
---|
| 591 | DBGCSCREENCOLOR_INVALID = 0,
|
---|
| 592 | /** Default color of the terminal. */
|
---|
| 593 | DBGCSCREENCOLOR_DEFAULT,
|
---|
| 594 | /** Black. */
|
---|
| 595 | DBGCSCREENCOLOR_BLACK,
|
---|
| 596 | DBGCSCREENCOLOR_BLACK_BRIGHT,
|
---|
| 597 | /** Red. */
|
---|
| 598 | DBGCSCREENCOLOR_RED,
|
---|
| 599 | DBGCSCREENCOLOR_RED_BRIGHT,
|
---|
| 600 | /** Green. */
|
---|
| 601 | DBGCSCREENCOLOR_GREEN,
|
---|
| 602 | DBGCSCREENCOLOR_GREEN_BRIGHT,
|
---|
| 603 | /** Yellow. */
|
---|
| 604 | DBGCSCREENCOLOR_YELLOW,
|
---|
| 605 | DBGCSCREENCOLOR_YELLOW_BRIGHT,
|
---|
| 606 | /** Blue. */
|
---|
| 607 | DBGCSCREENCOLOR_BLUE,
|
---|
| 608 | DBGCSCREENCOLOR_BLUE_BRIGHT,
|
---|
| 609 | /** Magenta. */
|
---|
| 610 | DBGCSCREENCOLOR_MAGENTA,
|
---|
| 611 | DBGCSCREENCOLOR_MAGENTA_BRIGHT,
|
---|
| 612 | /** Cyan. */
|
---|
| 613 | DBGCSCREENCOLOR_CYAN,
|
---|
| 614 | DBGCSCREENCOLOR_CYAN_BRIGHT,
|
---|
| 615 | /** White. */
|
---|
| 616 | DBGCSCREENCOLOR_WHITE,
|
---|
| 617 | DBGCSCREENCOLOR_WHITE_BRIGHT
|
---|
| 618 | } DBGCSCREENCOLOR;
|
---|
| 619 | /** Pointer to a screen color. */
|
---|
| 620 | typedef DBGCSCREENCOLOR *PDBGCSCREENCOLOR;
|
---|
| 621 |
|
---|
| 622 | DECLHIDDEN(int) dbgcScreenAsciiCreate(PDBGCSCREEN phScreen, uint32_t cchWidth, uint32_t cchHeight);
|
---|
| 623 | DECLHIDDEN(void) dbgcScreenAsciiDestroy(DBGCSCREEN hScreen);
|
---|
| 624 | DECLHIDDEN(int) dbgcScreenAsciiBlit(DBGCSCREEN hScreen, PFNDGCSCREENBLIT pfnBlit, void *pvUser, bool fAddColors);
|
---|
| 625 | DECLHIDDEN(int) dbgcScreenAsciiDrawLineVertical(DBGCSCREEN hScreen, uint32_t uX, uint32_t uStartY,
|
---|
| 626 | uint32_t uEndY, char ch, DBGCSCREENCOLOR enmColor);
|
---|
| 627 | DECLHIDDEN(int) dbgcScreenAsciiDrawLineHorizontal(DBGCSCREEN hScreen, uint32_t uStartX, uint32_t uEndX,
|
---|
| 628 | uint32_t uY, char ch, DBGCSCREENCOLOR enmColor);
|
---|
| 629 | DECLHIDDEN(int) dbgcScreenAsciiDrawCharacter(DBGCSCREEN hScreen, uint32_t uX, uint32_t uY, char ch,
|
---|
| 630 | DBGCSCREENCOLOR enmColor);
|
---|
| 631 | DECLHIDDEN(int) dbgcScreenAsciiDrawString(DBGCSCREEN hScreen, uint32_t uX, uint32_t uY, const char *pszText,
|
---|
| 632 | DBGCSCREENCOLOR enmColor);
|
---|
| 633 |
|
---|
[31510] | 634 | /* For tstDBGCParser: */
|
---|
[86327] | 635 | int dbgcCreate(PDBGC *ppDbgc, PCDBGCIO pIo, unsigned fFlags);
|
---|
[31510] | 636 | int dbgcRun(PDBGC pDbgc);
|
---|
| 637 | int dbgcProcessInput(PDBGC pDbgc, bool fNoExecute);
|
---|
| 638 | void dbgcDestroy(PDBGC pDbgc);
|
---|
| 639 |
|
---|
[84708] | 640 | DECLHIDDEN(const char *) dbgcGetEventCtx(DBGFEVENTCTX enmCtx);
|
---|
| 641 | DECLHIDDEN(PCDBGCSXEVT) dbgcEventLookup(DBGFEVENTTYPE enmType);
|
---|
[31510] | 642 |
|
---|
[86327] | 643 | DECL_HIDDEN_CALLBACK(int) dbgcGdbStubRunloop(PUVM pUVM, PCDBGCIO pIo, unsigned fFlags);
|
---|
| 644 | DECL_HIDDEN_CALLBACK(int) dbgcKdStubRunloop(PUVM pUVM, PCDBGCIO pIo, unsigned fFlags);
|
---|
[84627] | 645 |
|
---|
| 646 |
|
---|
[105536] | 647 | extern FNDBGCCMD dbgcCmdDumpImage;
|
---|
| 648 | extern FNDBGCCMD dbgcCmdNtRbTree;
|
---|
| 649 |
|
---|
| 650 |
|
---|
[31510] | 651 | /*******************************************************************************
|
---|
| 652 | * Global Variables *
|
---|
| 653 | *******************************************************************************/
|
---|
[41561] | 654 | extern const DBGCCMD g_aDbgcCmds[];
|
---|
| 655 | extern const uint32_t g_cDbgcCmds;
|
---|
| 656 | extern const DBGCFUNC g_aDbgcFuncs[];
|
---|
| 657 | extern const uint32_t g_cDbgcFuncs;
|
---|
[31510] | 658 | extern const DBGCCMD g_aCmdsCodeView[];
|
---|
[41561] | 659 | extern const uint32_t g_cCmdsCodeView;
|
---|
| 660 | extern const DBGCFUNC g_aFuncsCodeView[];
|
---|
| 661 | extern const uint32_t g_cFuncsCodeView;
|
---|
| 662 | extern const DBGCOP g_aDbgcOps[];
|
---|
| 663 | extern const uint32_t g_cDbgcOps;
|
---|
[59072] | 664 | extern const DBGCSXEVT g_aDbgcSxEvents[];
|
---|
| 665 | extern const uint32_t g_cDbgcSxEvents;
|
---|
[31510] | 666 |
|
---|
| 667 |
|
---|
[41561] | 668 | /*******************************************************************************
|
---|
| 669 | * Defined Constants And Macros *
|
---|
| 670 | *******************************************************************************/
|
---|
| 671 | /** Locks the g_pExtCmdsHead and g_pExtFuncsHead lists for reading. */
|
---|
| 672 | #define DBGCEXTLISTS_LOCK_RD() do { } while (0)
|
---|
| 673 | /** Locks the g_pExtCmdsHead and g_pExtFuncsHead lists for writing. */
|
---|
| 674 | #define DBGCEXTLISTS_LOCK_WR() do { } while (0)
|
---|
| 675 | /** UnLocks the g_pExtCmdsHead and g_pExtFuncsHead lists after reading. */
|
---|
| 676 | #define DBGCEXTLISTS_UNLOCK_RD() do { } while (0)
|
---|
| 677 | /** UnLocks the g_pExtCmdsHead and g_pExtFuncsHead lists after writing. */
|
---|
| 678 | #define DBGCEXTLISTS_UNLOCK_WR() do { } while (0)
|
---|
| 679 |
|
---|
| 680 |
|
---|
| 681 |
|
---|
[76564] | 682 | #endif /* !DEBUGGER_INCLUDED_SRC_DBGCInternal_h */
|
---|
[35628] | 683 |
|
---|