VirtualBox

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

Last change on this file since 12831 was 12644, checked in by vboxsync, 16 years ago

Debugger: misc file headers.

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