VirtualBox

source: vbox/trunk/src/VBox/Debugger/DBGCInternal.h@ 5668

Last change on this file since 5668 was 5668, checked in by vboxsync, 17 years ago

Split out the core structures, defines and stuff into DBGCInternal.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.8 KB
Line 
1/** $Id: DBGCInternal.h 5668 2007-11-11 04:36:28Z vboxsync $ */
2/** @file
3 * DBGC - Debugger Console, Internal Header File.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___DBGCInternal_h
19#define ___DBGCInternal_h
20
21
22/*******************************************************************************
23* Header Files *
24*******************************************************************************/
25#include <VBox/dbg.h>
26#include <VBox/dbgf.h>
27#include <VBox/vm.h>
28#include <VBox/vmm.h>
29#include <VBox/mm.h>
30#include <VBox/pgm.h>
31#include <VBox/selm.h>
32#include <VBox/dis.h>
33#include <VBox/param.h>
34#include <VBox/err.h>
35
36
37/*******************************************************************************
38* Defined Constants And Macros *
39*******************************************************************************/
40/* to err.h! */
41#define VERR_DBGC_QUIT (-11999)
42#define VERR_PARSE_FIRST (-11000)
43#define VERR_PARSE_TOO_FEW_ARGUMENTS (VERR_PARSE_FIRST - 0)
44#define VERR_PARSE_TOO_MANY_ARGUMENTS (VERR_PARSE_FIRST - 1)
45#define VERR_PARSE_ARGUMENT_OVERFLOW (VERR_PARSE_FIRST - 2)
46#define VERR_PARSE_ARGUMENT_TYPE_MISMATCH (VERR_PARSE_FIRST - 3)
47#define VERR_PARSE_NO_RANGE_ALLOWED (VERR_PARSE_FIRST - 4)
48#define VERR_PARSE_UNBALANCED_QUOTE (VERR_PARSE_FIRST - 5)
49#define VERR_PARSE_UNBALANCED_PARENTHESIS (VERR_PARSE_FIRST - 6)
50#define VERR_PARSE_EMPTY_ARGUMENT (VERR_PARSE_FIRST - 7)
51#define VERR_PARSE_UNEXPECTED_OPERATOR (VERR_PARSE_FIRST - 8)
52#define VERR_PARSE_INVALID_NUMBER (VERR_PARSE_FIRST - 9)
53#define VERR_PARSE_NUMBER_TOO_BIG (VERR_PARSE_FIRST - 10)
54#define VERR_PARSE_INVALID_OPERATION (VERR_PARSE_FIRST - 11)
55#define VERR_PARSE_FUNCTION_NOT_FOUND (VERR_PARSE_FIRST - 12)
56#define VERR_PARSE_NOT_A_FUNCTION (VERR_PARSE_FIRST - 13)
57#define VERR_PARSE_NO_MEMORY (VERR_PARSE_FIRST - 14)
58#define VERR_PARSE_INCORRECT_ARG_TYPE (VERR_PARSE_FIRST - 15)
59#define VERR_PARSE_VARIABLE_NOT_FOUND (VERR_PARSE_FIRST - 16)
60#define VERR_PARSE_CONVERSION_FAILED (VERR_PARSE_FIRST - 17)
61#define VERR_PARSE_NOT_IMPLEMENTED (VERR_PARSE_FIRST - 18)
62#define VERR_PARSE_BAD_RESULT_TYPE (VERR_PARSE_FIRST - 19)
63#define VERR_PARSE_WRITEONLY_SYMBOL (VERR_PARSE_FIRST - 20)
64#define VERR_PARSE_NO_ARGUMENT_MATCH (VERR_PARSE_FIRST - 21)
65#define VERR_PARSE_LAST (VERR_PARSE_FIRST - 30)
66
67#define VWRN_DBGC_CMD_PENDING 12000
68#define VWRN_DBGC_ALREADY_REGISTERED 12001
69#define VERR_DBGC_COMMANDS_NOT_REGISTERED (-12002)
70#define VERR_DBGC_BP_NOT_FOUND (-12003)
71#define VERR_DBGC_BP_EXISTS (-12004)
72#define VINF_DBGC_BP_NO_COMMAND 12005
73
74
75/*******************************************************************************
76* Structures and Typedefs *
77*******************************************************************************/
78
79/**
80 * Debugger console per breakpoint data.
81 */
82typedef struct DBGCBP
83{
84 /** Pointer to the next breakpoint in the list. */
85 struct DBGCBP *pNext;
86 /** The breakpoint identifier. */
87 RTUINT iBp;
88 /** The size of the command. */
89 size_t cchCmd;
90 /** The command to execute when the breakpoint is hit. */
91 char szCmd[1];
92} DBGCBP;
93/** Pointer to a breakpoint. */
94typedef DBGCBP *PDBGCBP;
95
96
97/**
98 * Named variable.
99 *
100 * Always allocated from heap in one signle block.
101 */
102typedef struct DBGCNAMEDVAR
103{
104 /** The variable. */
105 DBGCVAR Var;
106 /** It's name. */
107 char szName[1];
108} DBGCNAMEDVAR;
109/** Pointer to named variable. */
110typedef DBGCNAMEDVAR *PDBGCNAMEDVAR;
111
112
113/**
114 * Debugger console status
115 */
116typedef enum DBGCSTATUS
117{
118 /** Normal status, .*/
119 DBGC_HALTED
120
121} DBGCSTATUS;
122
123
124/**
125 * Debugger console instance data.
126 */
127typedef struct DBGC
128{
129 /** Command helpers. */
130 DBGCCMDHLP CmdHlp;
131 /** Pointer to backend callback structure. */
132 PDBGCBACK pBack;
133
134 /** Pointer to the current VM. */
135 PVM pVM;
136 /** The current debugger emulation. */
137 const char *pszEmulation;
138 /** Pointer to the command and functions for the current debugger emulation. */
139 PCDBGCCMD paEmulationCmds;
140 /** The number of commands paEmulationCmds points to. */
141 unsigned cEmulationCmds;
142 /** Log indicator. (If set we're writing the log to the console.) */
143 bool fLog;
144
145 /** Indicates whether we're in guest (true) or hypervisor (false) register context. */
146 bool fRegCtxGuest;
147 /** Indicates whether the register are terse or sparse. */
148 bool fRegTerse;
149
150 /** Current dissassembler position. */
151 DBGCVAR DisasmPos;
152 /** Current source position. (flat GC) */
153 DBGCVAR SourcePos;
154 /** Current memory dump position. */
155 DBGCVAR DumpPos;
156 /** Size of the previous dump element. */
157 unsigned cbDumpElement;
158
159 /** Number of variables in papVars. */
160 unsigned cVars;
161 /** Array of global variables.
162 * Global variables can be referenced using the $ operator and set
163 * and unset using command with those names. */
164 PDBGCNAMEDVAR *papVars;
165
166 /** The list of breakpoints. (singly linked) */
167 PDBGCBP pFirstBp;
168
169 /** @name Parsing and Execution
170 * @{ */
171
172 /** Input buffer. */
173 char achInput[2048];
174 /** To ease debugging. */
175 unsigned uInputZero;
176 /** Write index in the input buffer. */
177 unsigned iWrite;
178 /** Read index in the input buffer. */
179 unsigned iRead;
180 /** The number of lines in the buffer. */
181 unsigned cInputLines;
182 /** Indicates that we have a buffer overflow condition.
183 * This means that input is ignored up to the next newline. */
184 bool fInputOverflow;
185 /** Indicates whether or we're ready for input. */
186 bool fReady;
187
188 /** Scratch buffer position. */
189 char *pszScratch;
190 /** Scratch buffer. */
191 char achScratch[16384];
192 /** Argument array position. */
193 unsigned iArg;
194 /** Array of argument variables. */
195 DBGCVAR aArgs[100];
196
197 /** rc from last dbgcHlpPrintfV(). */
198 int rcOutput;
199
200 /** @} */
201} DBGC;
202/** Pointer to debugger console instance data. */
203typedef DBGC *PDBGC;
204
205/** Converts a Command Helper pointer to a pointer to DBGC instance data. */
206#define DBGC_CMDHLP2DBGC(pCmdHlp) ( (PDBGC)((uintptr_t)(pCmdHlp) - RT_OFFSETOF(DBGC, CmdHlp)) )
207
208
209/**
210 * Chunk of external commands.
211 */
212typedef struct DBGCEXTCMDS
213{
214 /** Number of commands descriptors. */
215 unsigned cCmds;
216 /** Pointer to array of command descriptors. */
217 PCDBGCCMD paCmds;
218 /** Pointer to the next chunk. */
219 struct DBGCEXTCMDS *pNext;
220} DBGCEXTCMDS;
221/** Pointer to chunk of external commands. */
222typedef DBGCEXTCMDS *PDBGCEXTCMDS;
223
224
225
226/**
227 * Unary operator handler function.
228 *
229 * @returns 0 on success.
230 * @returns VBox evaluation / parsing error code on failure.
231 * The caller does the bitching.
232 * @param pDbgc Debugger console instance data.
233 * @param pArg The argument.
234 * @param pResult Where to store the result.
235 */
236typedef DECLCALLBACK(int) FNDBGCOPUNARY(PDBGC pDbgc, PCDBGCVAR pArg, PDBGCVAR pResult);
237/** Pointer to a unary operator handler function. */
238typedef FNDBGCOPUNARY *PFNDBGCOPUNARY;
239
240
241/**
242 * Binary operator handler function.
243 *
244 * @returns 0 on success.
245 * @returns VBox evaluation / parsing error code on failure.
246 * The caller does the bitching.
247 * @param pDbgc Debugger console instance data.
248 * @param pArg1 The first argument.
249 * @param pArg2 The 2nd argument.
250 * @param pResult Where to store the result.
251 */
252typedef DECLCALLBACK(int) FNDBGCOPBINARY(PDBGC pDbgc, PCDBGCVAR pArg1, PCDBGCVAR pArg2, PDBGCVAR pResult);
253/** Pointer to a binary operator handler function. */
254typedef FNDBGCOPBINARY *PFNDBGCOPBINARY;
255
256
257/**
258 * Operator descriptor.
259 */
260typedef struct DBGCOP
261{
262 /** Operator mnemonic. */
263 char szName[4];
264 /** Length of name. */
265 const unsigned cchName;
266 /** Whether or not this is a binary operator.
267 * Unary operators are evaluated right-to-left while binary are left-to-right. */
268 bool fBinary;
269 /** Precedence level. */
270 unsigned iPrecedence;
271 /** Unary operator handler. */
272 PFNDBGCOPUNARY pfnHandlerUnary;
273 /** Binary operator handler. */
274 PFNDBGCOPBINARY pfnHandlerBinary;
275 /** Operator description. */
276 const char *pszDescription;
277} DBGCOP;
278/** Pointer to an operator descriptor. */
279typedef DBGCOP *PDBGCOP;
280/** Pointer to a const operator descriptor. */
281typedef const DBGCOP *PCDBGCOP;
282
283
284
285/** Pointer to symbol descriptor. */
286typedef struct DBGCSYM *PDBGCSYM;
287/** Pointer to const symbol descriptor. */
288typedef const struct DBGCSYM *PCDBGCSYM;
289
290/**
291 * Get builtin symbol.
292 *
293 * @returns 0 on success.
294 * @returns VBox evaluation / parsing error code on failure.
295 * The caller does the bitching.
296 * @param pSymDesc Pointer to the symbol descriptor.
297 * @param pCmdHlp Pointer to the command callback structure.
298 * @param enmType The result type.
299 * @param pResult Where to store the result.
300 */
301typedef DECLCALLBACK(int) FNDBGCSYMGET(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, DBGCVARTYPE enmType, PDBGCVAR pResult);
302/** Pointer to get function for a builtin symbol. */
303typedef FNDBGCSYMGET *PFNDBGCSYMGET;
304
305/**
306 * Set builtin symbol.
307 *
308 * @returns 0 on success.
309 * @returns VBox evaluation / parsing error code on failure.
310 * The caller does the bitching.
311 * @param pSymDesc Pointer to the symbol descriptor.
312 * @param pCmdHlp Pointer to the command callback structure.
313 * @param pValue The value to assign the symbol.
314 */
315typedef DECLCALLBACK(int) FNDBGCSYMSET(PCDBGCSYM pSymDesc, PDBGCCMDHLP pCmdHlp, PCDBGCVAR pValue);
316/** Pointer to set function for a builtin symbol. */
317typedef FNDBGCSYMSET *PFNDBGCSYMSET;
318
319
320/**
321 * Symbol description (for builtin symbols).
322 */
323typedef struct DBGCSYM
324{
325 /** Symbol name. */
326 const char *pszName;
327 /** Get function. */
328 PFNDBGCSYMGET pfnGet;
329 /** Set function. (NULL if readonly) */
330 PFNDBGCSYMSET pfnSet;
331 /** User data. */
332 unsigned uUser;
333} DBGCSYM;
334
335
336/*******************************************************************************
337* Internal Functions *
338*******************************************************************************/
339#if 0
340static void dbgcVarSetGCFlat(PDBGCVAR pVar, RTGCPTR GCFlat);
341static void dbgcVarSetGCFlatByteRange(PDBGCVAR pVar, RTGCPTR GCFlat, uint64_t cb);
342static void dbgcVarSetVar(PDBGCVAR pVar, PCDBGCVAR pVar2);
343static void dbgcVarSetNoRange(PDBGCVAR pVar);
344static void dbgcVarSetByteRange(PDBGCVAR pVar, uint64_t cb);
345static int dbgcVarToDbgfAddr(PDBGC pDbgc, PCDBGCVAR pVar, PDBGFADDRESS pAddress);
346
347static int dbgcBpAdd(PDBGC pDbgc, RTUINT iBp, const char *pszCmd);
348static int dbgcBpUpdate(PDBGC pDbgc, RTUINT iBp, const char *pszCmd);
349static int dbgcBpDelete(PDBGC pDbgc, RTUINT iBp);
350static PDBGCBP dbgcBpGet(PDBGC pDbgc, RTUINT iBp);
351static int dbgcBpExec(PDBGC pDbgc, RTUINT iBp);
352
353static PCDBGCSYM dbgcLookupRegisterSymbol(PDBGC pDbgc, const char *pszSymbol);
354static int dbgcSymbolGet(PDBGC pDbgc, const char *pszSymbol, DBGCVARTYPE enmType, PDBGCVAR pResult);
355static int dbgcEvalSub(PDBGC pDbgc, char *pszExpr, size_t cchExpr, PDBGCVAR pResult);
356static int dbgcProcessCommand(PDBGC pDbgc, char *pszCmd, size_t cchCmd);
357#endif
358
359
360/*******************************************************************************
361* Global Variables *
362*******************************************************************************/
363/** Command descriptors for the basic commands. */
364extern const DBGCCMD g_aCmds[];
365/** Command descriptors for the CodeView / WinDbg emulation.
366 * The emulation isn't attempting to be identical, only somewhat similar.
367 */
368extern const DBGCCMD g_aCmdsCodeView[];
369
370#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette