1 | /** @file
|
---|
2 | * Debugger Interfaces.
|
---|
3 | *
|
---|
4 | * This header covers all external interfaces of the Debugger module.
|
---|
5 | * However, it does not cover the DBGF interface since that part of the
|
---|
6 | * VMM. Use dbgf.h for that.
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
11 | *
|
---|
12 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | * available from http://www.virtualbox.org. This file is free software;
|
---|
14 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | * General Public License as published by the Free Software Foundation,
|
---|
16 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
17 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
18 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 | *
|
---|
20 | * If you received this file as part of a commercial VirtualBox
|
---|
21 | * distribution, then only the terms of your commercial VirtualBox
|
---|
22 | * license agreement apply instead of the previous paragraph.
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef __VBox_dbg_h__
|
---|
26 | #define __VBox_dbg_h__
|
---|
27 |
|
---|
28 | #include <VBox/cdefs.h>
|
---|
29 | #include <VBox/types.h>
|
---|
30 | #include <VBox/dbgf.h>
|
---|
31 | #include <stdarg.h>
|
---|
32 |
|
---|
33 | __BEGIN_DECLS
|
---|
34 |
|
---|
35 | /** @def VBOX_WITH_DEBUGGER
|
---|
36 | * The build is with debugger module. Test if this is defined before
|
---|
37 | * registering external debugger commands.
|
---|
38 | */
|
---|
39 | #ifndef VBOX_WITH_DEBUGGER
|
---|
40 | # ifdef DEBUG
|
---|
41 | # define VBOX_WITH_DEBUGGER
|
---|
42 | # endif
|
---|
43 | #endif
|
---|
44 |
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * DBGC variable category.
|
---|
48 | *
|
---|
49 | * Used to describe an argument to a command or function and a functions
|
---|
50 | * return value.
|
---|
51 | */
|
---|
52 | typedef enum DBGCVARCAT
|
---|
53 | {
|
---|
54 | /** Any type is fine. */
|
---|
55 | DBGCVAR_CAT_ANY = 0,
|
---|
56 | /** Any kind of pointer. */
|
---|
57 | DBGCVAR_CAT_POINTER,
|
---|
58 | /** Any kind of pointer with no range option. */
|
---|
59 | DBGCVAR_CAT_POINTER_NO_RANGE,
|
---|
60 | /** GC pointer. */
|
---|
61 | DBGCVAR_CAT_GC_POINTER,
|
---|
62 | /** GC pointer with no range option. */
|
---|
63 | DBGCVAR_CAT_GC_POINTER_NO_RANGE,
|
---|
64 | /** Numeric argument. */
|
---|
65 | DBGCVAR_CAT_NUMBER,
|
---|
66 | /** Numeric argument with no range option. */
|
---|
67 | DBGCVAR_CAT_NUMBER_NO_RANGE,
|
---|
68 | /** String. */
|
---|
69 | DBGCVAR_CAT_STRING,
|
---|
70 | /** Symbol. */
|
---|
71 | DBGCVAR_CAT_SYMBOL
|
---|
72 | } DBGCVARCAT;
|
---|
73 |
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * DBGC variable type.
|
---|
77 | */
|
---|
78 | typedef enum DBGCVARTYPE
|
---|
79 | {
|
---|
80 | /** unknown... */
|
---|
81 | DBGCVAR_TYPE_UNKNOWN = 0,
|
---|
82 | /** Flat GC pointer. */
|
---|
83 | DBGCVAR_TYPE_GC_FLAT,
|
---|
84 | /** Segmented GC pointer. */
|
---|
85 | DBGCVAR_TYPE_GC_FAR,
|
---|
86 | /** Physical GC pointer. */
|
---|
87 | DBGCVAR_TYPE_GC_PHYS,
|
---|
88 | /** Flat HC pointer. */
|
---|
89 | DBGCVAR_TYPE_HC_FLAT,
|
---|
90 | /** Segmented HC pointer. */
|
---|
91 | DBGCVAR_TYPE_HC_FAR,
|
---|
92 | /** Physical HC pointer. */
|
---|
93 | DBGCVAR_TYPE_HC_PHYS,
|
---|
94 | /** String. */
|
---|
95 | DBGCVAR_TYPE_STRING,
|
---|
96 | /** Number. */
|
---|
97 | DBGCVAR_TYPE_NUMBER,
|
---|
98 | /** Symbol. */
|
---|
99 | DBGCVAR_TYPE_SYMBOL,
|
---|
100 | /** Special type used when querying symbols. */
|
---|
101 | DBGCVAR_TYPE_ANY
|
---|
102 | } DBGCVARTYPE;
|
---|
103 |
|
---|
104 | /** Checks if the specified variable type is of a pointer persuasion. */
|
---|
105 | #define DBGCVAR_ISPOINTER(enmType) (enmType >= DBGCVAR_TYPE_GC_FLAT && enmType <= DBGCVAR_TYPE_HC_PHYS)
|
---|
106 | /** Checks if the specified variable type is of a pointer persuasion and of the guest context sort. */
|
---|
107 | #define DBGCVAR_ISGCPOINTER(enmType) (enmType >= DBGCVAR_TYPE_GC_FLAT && enmType <= DBGCVAR_TYPE_GC_PHYS)
|
---|
108 | /** Checks if the specified variable type is of a pointer persuasion and of the host context sort. */
|
---|
109 | #define DBGCVAR_ISHCPOINTER(enmType) (enmType >= DBGCVAR_TYPE_HC_FLAT && enmType <= DBGCVAR_TYPE_HC_PHYS)
|
---|
110 |
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * DBGC variable range type.
|
---|
114 | */
|
---|
115 | typedef enum DBGCVARRANGETYPE
|
---|
116 | {
|
---|
117 | /** No range appliable or no range specified. */
|
---|
118 | DBGCVAR_RANGE_NONE = 0,
|
---|
119 | /** Number of elements. */
|
---|
120 | DBGCVAR_RANGE_ELEMENTS,
|
---|
121 | /** Number of bytes. */
|
---|
122 | DBGCVAR_RANGE_BYTES
|
---|
123 | } DBGCVARRANGETYPE;
|
---|
124 |
|
---|
125 |
|
---|
126 | /**
|
---|
127 | * Variable descriptor.
|
---|
128 | */
|
---|
129 | typedef struct DBGCVARDESC
|
---|
130 | {
|
---|
131 | /** The minimal number of times this argument may occur.
|
---|
132 | * Use 0 here to inidicate that the argument is optional. */
|
---|
133 | unsigned cTimesMin;
|
---|
134 | /** Maximum number of occurences.
|
---|
135 | * Use ~0 here to indicate infinite. */
|
---|
136 | unsigned cTimesMax;
|
---|
137 | /** Argument category. */
|
---|
138 | DBGCVARCAT enmCategory;
|
---|
139 | /** Flags, DBGCVD_FLAGS_* */
|
---|
140 | unsigned fFlags;
|
---|
141 | /** Argument name. */
|
---|
142 | const char *pszName;
|
---|
143 | /** Argument name. */
|
---|
144 | const char *pszDescription;
|
---|
145 | } DBGCVARDESC;
|
---|
146 | /** Pointer to an argument descriptor. */
|
---|
147 | typedef DBGCVARDESC *PDBGCVARDESC;
|
---|
148 | /** Pointer to a const argument descriptor. */
|
---|
149 | typedef const DBGCVARDESC *PCDBGCVARDESC;
|
---|
150 |
|
---|
151 | /** Variable descriptor flags.
|
---|
152 | * @{ */
|
---|
153 | /** Indicates that the variable depends on the previous being present. */
|
---|
154 | #define DBGCVD_FLAGS_DEP_PREV BIT(1)
|
---|
155 | /** @} */
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * DBGC variable.
|
---|
160 | */
|
---|
161 | typedef struct DBGCVAR
|
---|
162 | {
|
---|
163 | /** Pointer to the argument descriptor. */
|
---|
164 | PCDBGCVARDESC pDesc;
|
---|
165 | /** Pointer to the next argument. */
|
---|
166 | struct DBGCVAR *pNext;
|
---|
167 |
|
---|
168 | /** Argument type. */
|
---|
169 | DBGCVARTYPE enmType;
|
---|
170 | /** Type specific. */
|
---|
171 | union
|
---|
172 | {
|
---|
173 | /** Flat GC Address. (DBGCVAR_TYPE_GC_FLAT) */
|
---|
174 | RTGCPTR GCFlat;
|
---|
175 | /** Far (16:32) GC Address. (DBGCVAR_TYPE_GC_FAR) */
|
---|
176 | RTFAR32 GCFar;
|
---|
177 | /** Physical GC Address. (DBGCVAR_TYPE_GC_PHYS) */
|
---|
178 | RTGCPHYS GCPhys;
|
---|
179 | /** Flat HC Address. (DBGCVAR_TYPE_HC_FLAT) */
|
---|
180 | void *pvHCFlat;
|
---|
181 | /** Far (16:32) HC Address. (DBGCVAR_TYPE_HC_FAR) */
|
---|
182 | RTFAR32 HCFar;
|
---|
183 | /** Physical GC Address. (DBGCVAR_TYPE_HC_PHYS) */
|
---|
184 | RTHCPHYS HCPhys;
|
---|
185 | /** String. (DBGCVAR_TYPE_STRING)
|
---|
186 | * The basic idea is the the this is a pointer to the expression we're
|
---|
187 | * parsing, so no messing with freeing. */
|
---|
188 | const char *pszString;
|
---|
189 | /** Number. (DBGCVAR_TYPE_NUMBER) */
|
---|
190 | uint64_t u64Number;
|
---|
191 | } u;
|
---|
192 |
|
---|
193 | /** Range type. */
|
---|
194 | DBGCVARRANGETYPE enmRangeType;
|
---|
195 | /** Range. The use of the content depends on the enmRangeType. */
|
---|
196 | uint64_t u64Range;
|
---|
197 | } DBGCVAR;
|
---|
198 | /** Pointer to a command argument. */
|
---|
199 | typedef DBGCVAR *PDBGCVAR;
|
---|
200 | /** Pointer to a const command argument. */
|
---|
201 | typedef const DBGCVAR *PCDBGCVAR;
|
---|
202 |
|
---|
203 |
|
---|
204 | /** Pointer to helper functions for commands. */
|
---|
205 | typedef struct DBGCCMDHLP *PDBGCCMDHLP;
|
---|
206 |
|
---|
207 | /**
|
---|
208 | * Command helper for writing text to the debug console.
|
---|
209 | *
|
---|
210 | * @returns VBox status.
|
---|
211 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
212 | * @param pvBuf What to write.
|
---|
213 | * @param cbBuf Number of bytes to write.
|
---|
214 | * @param pcbWritten Where to store the number of bytes actually written.
|
---|
215 | * If NULL the entire buffer must be successfully written.
|
---|
216 | */
|
---|
217 | typedef DECLCALLBACK(int) FNDBGCHLPWRITE(PDBGCCMDHLP pCmdHlp, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
|
---|
218 | /** Pointer to a FNDBGCHLPWRITE() function. */
|
---|
219 | typedef FNDBGCHLPWRITE *PFNDBGCHLPWRITE;
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Command helper for writing formatted text to the debug console.
|
---|
223 | *
|
---|
224 | * @returns VBox status.
|
---|
225 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
226 | * @param pcb Where to store the number of bytes written.
|
---|
227 | * @param pszFormat The format string.
|
---|
228 | * This is using the log formatter, so it's format extensions can be used.
|
---|
229 | * @param ... Arguments specified in the format string.
|
---|
230 | */
|
---|
231 | typedef DECLCALLBACK(int) FNDBGCHLPPRINTF(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, ...);
|
---|
232 | /** Pointer to a FNDBGCHLPPRINTF() function. */
|
---|
233 | typedef FNDBGCHLPPRINTF *PFNDBGCHLPPRINTF;
|
---|
234 |
|
---|
235 | /**
|
---|
236 | * Command helper for writing formatted text to the debug console.
|
---|
237 | *
|
---|
238 | * @returns VBox status.
|
---|
239 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
240 | * @param pcb Where to store the number of bytes written.
|
---|
241 | * @param pszFormat The format string.
|
---|
242 | * This is using the log formatter, so it's format extensions can be used.
|
---|
243 | * @param args Arguments specified in the format string.
|
---|
244 | */
|
---|
245 | typedef DECLCALLBACK(int) FNDBGCHLPPRINTFV(PDBGCCMDHLP pCmdHlp, size_t *pcbWritten, const char *pszFormat, va_list args);
|
---|
246 | /** Pointer to a FNDBGCHLPPRINTFV() function. */
|
---|
247 | typedef FNDBGCHLPPRINTFV *PFNDBGCHLPPRINTFV;
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Command helper for formatting and error message for a VBox status code.
|
---|
251 | *
|
---|
252 | * @returns VBox status code appropriate to return from a command.
|
---|
253 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
254 | * @param rc The VBox status code.
|
---|
255 | * @param pcb Where to store the number of bytes written.
|
---|
256 | * @param pszFormat Format string for additional messages. Can be NULL.
|
---|
257 | * @param ... Format arguments, optional.
|
---|
258 | */
|
---|
259 | typedef DECLCALLBACK(int) FNDBGCHLPVBOXERROR(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, ...);
|
---|
260 | /** Pointer to a FNDBGCHLPVBOXERROR() function. */
|
---|
261 | typedef FNDBGCHLPVBOXERROR *PFNDBGCHLPVBOXERROR;
|
---|
262 |
|
---|
263 | /**
|
---|
264 | * Command helper for formatting and error message for a VBox status code.
|
---|
265 | *
|
---|
266 | * @returns VBox status code appropriate to return from a command.
|
---|
267 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
268 | * @param rc The VBox status code.
|
---|
269 | * @param pcb Where to store the number of bytes written.
|
---|
270 | * @param pszFormat Format string for additional messages. Can be NULL.
|
---|
271 | * @param args Format arguments, optional.
|
---|
272 | */
|
---|
273 | typedef DECLCALLBACK(int) FNDBGCHLPVBOXERRORV(PDBGCCMDHLP pCmdHlp, int rc, const char *pszFormat, va_list args);
|
---|
274 | /** Pointer to a FNDBGCHLPVBOXERRORV() function. */
|
---|
275 | typedef FNDBGCHLPVBOXERRORV *PFNDBGCHLPVBOXERRORV;
|
---|
276 |
|
---|
277 | /**
|
---|
278 | * Command helper for reading memory specified by a DBGC variable.
|
---|
279 | *
|
---|
280 | * @returns VBox status code appropriate to return from a command.
|
---|
281 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
282 | * @param pVM VM handle if GC or physical HC address.
|
---|
283 | * @param pvBuffer Where to store the read data.
|
---|
284 | * @param cbRead Number of bytes to read.
|
---|
285 | * @param pVarPointer DBGC variable specifying where to start reading.
|
---|
286 | * @param pcbRead Where to store the number of bytes actually read.
|
---|
287 | * This optional, but it's useful when read GC virtual memory where a
|
---|
288 | * page in the requested range might not be present.
|
---|
289 | * If not specified not-present failure or end of a HC physical page
|
---|
290 | * will cause failure.
|
---|
291 | */
|
---|
292 | typedef DECLCALLBACK(int) FNDBGCHLPMEMREAD(PDBGCCMDHLP pCmdHlp, PVM pVM, void *pvBuffer, size_t cbRead, PCDBGCVAR pVarPointer, size_t *pcbRead);
|
---|
293 | /** Pointer to a FNDBGCHLPMEMREAD() function. */
|
---|
294 | typedef FNDBGCHLPMEMREAD *PFNDBGCHLPMEMREAD;
|
---|
295 |
|
---|
296 | /**
|
---|
297 | * Command helper for writing memory specified by a DBGC variable.
|
---|
298 | *
|
---|
299 | * @returns VBox status code appropriate to return from a command.
|
---|
300 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
301 | * @param pVM VM handle if GC or physical HC address.
|
---|
302 | * @param pvBuffer What to write.
|
---|
303 | * @param cbWrite Number of bytes to write.
|
---|
304 | * @param pVarPointer DBGC variable specifying where to start reading.
|
---|
305 | * @param pcbWritten Where to store the number of bytes written.
|
---|
306 | * This is optional. If NULL be aware that some of the buffer
|
---|
307 | * might have been written to the specified address.
|
---|
308 | */
|
---|
309 | typedef DECLCALLBACK(int) FNDBGCHLPMEMWRITE(PDBGCCMDHLP pCmdHlp, PVM pVM, const void *pvBuffer, size_t cbWrite, PCDBGCVAR pVarPointer, size_t *pcbWritten);
|
---|
310 | /** Pointer to a FNDBGCHLPMEMWRITE() function. */
|
---|
311 | typedef FNDBGCHLPMEMWRITE *PFNDBGCHLPMEMWRITE;
|
---|
312 |
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Evaluates an expression.
|
---|
316 | * (Hopefully the parser and functions are fully reentrant.)
|
---|
317 | *
|
---|
318 | * @returns VBox status code appropriate to return from a command.
|
---|
319 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
320 | * @param pResult Where to store the result.
|
---|
321 | * @param pszExpr The expression. Format string with the format DBGC extensions.
|
---|
322 | * @param ... Format arguments.
|
---|
323 | */
|
---|
324 | typedef DECLCALLBACK(int) FNDBGCHLPEVAL(PDBGCCMDHLP pCmdHlp, PDBGCVAR pResult, const char *pszExpr, ...);
|
---|
325 | /** Pointer to a FNDBGCHLPEVAL() function. */
|
---|
326 | typedef FNDBGCHLPEVAL *PFNDBGCHLPEVAL;
|
---|
327 |
|
---|
328 |
|
---|
329 | /**
|
---|
330 | * Executes command an expression.
|
---|
331 | * (Hopefully the parser and functions are fully reentrant.)
|
---|
332 | *
|
---|
333 | * @returns VBox status code appropriate to return from a command.
|
---|
334 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
335 | * @param pszExpr The expression. Format string with the format DBGC extensions.
|
---|
336 | * @param ... Format arguments.
|
---|
337 | */
|
---|
338 | typedef DECLCALLBACK(int) FNDBGCHLPEXEC(PDBGCCMDHLP pCmdHlp, const char *pszExpr, ...);
|
---|
339 | /** Pointer to a FNDBGCHLPEVAL() function. */
|
---|
340 | typedef FNDBGCHLPEXEC *PFNDBGCHLPEXEC;
|
---|
341 |
|
---|
342 |
|
---|
343 | /**
|
---|
344 | * Helper functions for commands.
|
---|
345 | */
|
---|
346 | typedef struct DBGCCMDHLP
|
---|
347 | {
|
---|
348 | /** Pointer to a FNDBCHLPWRITE() function. */
|
---|
349 | PFNDBGCHLPWRITE pfnWrite;
|
---|
350 | /** Pointer to a FNDBGCHLPPRINTF() function. */
|
---|
351 | PFNDBGCHLPPRINTF pfnPrintf;
|
---|
352 | /** Pointer to a FNDBGCHLPPRINTFV() function. */
|
---|
353 | PFNDBGCHLPPRINTFV pfnPrintfV;
|
---|
354 | /** Pointer to a FNDBGCHLPVBOXERROR() function. */
|
---|
355 | PFNDBGCHLPVBOXERROR pfnVBoxError;
|
---|
356 | /** Pointer to a FNDBGCHLPVBOXERRORV() function. */
|
---|
357 | PFNDBGCHLPVBOXERRORV pfnVBoxErrorV;
|
---|
358 | /** Pointer to a FNDBGCHLPMEMREAD() function. */
|
---|
359 | PFNDBGCHLPMEMREAD pfnMemRead;
|
---|
360 | /** Pointer to a FNDBGCHLPMEMWRITE() function. */
|
---|
361 | PFNDBGCHLPMEMWRITE pfnMemWrite;
|
---|
362 | /** Pointer to a FNDBGCHLPEVAL() function. */
|
---|
363 | PFNDBGCHLPEVAL pfnEval;
|
---|
364 | /** Pointer to a FNDBGCHLPEXEC() function. */
|
---|
365 | PFNDBGCHLPEXEC pfnExec;
|
---|
366 |
|
---|
367 | /**
|
---|
368 | * Converts a DBGC variable to a DBGF address structure.
|
---|
369 | *
|
---|
370 | * @returns VBox status code.
|
---|
371 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
372 | * @param pVar The variable to convert.
|
---|
373 | * @param pAddress The target address.
|
---|
374 | */
|
---|
375 | DECLCALLBACKMEMBER(int, pfnVarToDbgfAddr)(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, PDBGFADDRESS pAddress);
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Converts a DBGC variable to a boolean.
|
---|
379 | *
|
---|
380 | * @returns VBox status code.
|
---|
381 | * @param pCmdHlp Pointer to the command callback structure.
|
---|
382 | * @param pVar The variable to convert.
|
---|
383 | * @param pf Where to store the boolean.
|
---|
384 | */
|
---|
385 | DECLCALLBACKMEMBER(int, pfnVarToBool)(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, bool *pf);
|
---|
386 |
|
---|
387 | } DBGCCMDHLP;
|
---|
388 |
|
---|
389 |
|
---|
390 |
|
---|
391 | /** Pointer to command descriptor. */
|
---|
392 | typedef struct DBGCCMD *PDBGCCMD;
|
---|
393 | /** Pointer to const command descriptor. */
|
---|
394 | typedef const struct DBGCCMD *PCDBGCCMD;
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Command handler.
|
---|
398 | *
|
---|
399 | * The console will call the handler for a command once it's finished
|
---|
400 | * parsing the user input. The command handler function is responsible
|
---|
401 | * for executing the command itself.
|
---|
402 | *
|
---|
403 | * @returns VBox status.
|
---|
404 | * @param pCmd Pointer to the command descriptor (as registered).
|
---|
405 | * @param pCmdHlp Pointer to command helper functions.
|
---|
406 | * @param pVM Pointer to the current VM (if any).
|
---|
407 | * @param paArgs Pointer to (readonly) array of arguments.
|
---|
408 | * @param cArgs Number of arguments in the array.
|
---|
409 | * @param pResult Where to store the result. NULL if no result descriptor was specified.
|
---|
410 | */
|
---|
411 | typedef DECLCALLBACK(int) FNDBGCCMD(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pArgs, unsigned cArgs, PDBGCVAR pResult);
|
---|
412 | /** Pointer to a FNDBGCCMD() function. */
|
---|
413 | typedef FNDBGCCMD *PFNDBGCCMD;
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * DBGC command descriptor.
|
---|
417 | *
|
---|
418 | * If a pResultDesc is specified the command can be called and used
|
---|
419 | * as a function too. If it's a pure function, set fFlags to
|
---|
420 | * DBGCCMD_FLAGS_FUNCTION.
|
---|
421 | */
|
---|
422 | typedef struct DBGCCMD
|
---|
423 | {
|
---|
424 | /** Command string. */
|
---|
425 | const char *pszCmd;
|
---|
426 | /** Minimum number of arguments. */
|
---|
427 | unsigned cArgsMin;
|
---|
428 | /** Max number of arguments. */
|
---|
429 | unsigned cArgsMax;
|
---|
430 | /** Argument descriptors (array). */
|
---|
431 | PCDBGCVARDESC paArgDescs;
|
---|
432 | /** Number of argument descriptors. */
|
---|
433 | unsigned cArgDescs;
|
---|
434 | /** Result descriptor. */
|
---|
435 | PCDBGCVARDESC pResultDesc;
|
---|
436 | /** flags. (reserved for now) */
|
---|
437 | unsigned fFlags;
|
---|
438 | /** Handler function. */
|
---|
439 | PFNDBGCCMD pfnHandler;
|
---|
440 | /** Command syntax. */
|
---|
441 | const char *pszSyntax;
|
---|
442 | /** Command description. */
|
---|
443 | const char *pszDescription;
|
---|
444 | } DBGCCMD;
|
---|
445 |
|
---|
446 | /** DBGCCMD Flags.
|
---|
447 | * @{
|
---|
448 | */
|
---|
449 | /** The description is of a pure function which cannot be invoked
|
---|
450 | * as a command from the commandline. */
|
---|
451 | #define DBGCCMD_FLAGS_FUNCTION 1
|
---|
452 | /** @} */
|
---|
453 |
|
---|
454 |
|
---|
455 |
|
---|
456 | /** Pointer to a DBGC backend. */
|
---|
457 | typedef struct DBGCBACK *PDBGCBACK;
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Checks if there is input.
|
---|
461 | *
|
---|
462 | * @returns true if there is input ready.
|
---|
463 | * @returns false if there not input ready.
|
---|
464 | * @param pBack Pointer to the backend structure supplied by
|
---|
465 | * the backend. The backend can use this to find
|
---|
466 | * it's instance data.
|
---|
467 | * @param cMillies Number of milliseconds to wait on input data.
|
---|
468 | */
|
---|
469 | typedef DECLCALLBACK(bool) FNDBGCBACKINPUT(PDBGCBACK pBack, uint32_t cMillies);
|
---|
470 | /** Pointer to a FNDBGCBACKINPUT() callback. */
|
---|
471 | typedef FNDBGCBACKINPUT *PFNDBGCBACKINPUT;
|
---|
472 |
|
---|
473 | /**
|
---|
474 | * Read input.
|
---|
475 | *
|
---|
476 | * @returns VBox status code.
|
---|
477 | * @param pBack Pointer to the backend structure supplied by
|
---|
478 | * the backend. The backend can use this to find
|
---|
479 | * it's instance data.
|
---|
480 | * @param pvBuf Where to put the bytes we read.
|
---|
481 | * @param cbBuf Maximum nymber of bytes to read.
|
---|
482 | * @param pcbRead Where to store the number of bytes actually read.
|
---|
483 | * If NULL the entire buffer must be filled for a
|
---|
484 | * successful return.
|
---|
485 | */
|
---|
486 | typedef DECLCALLBACK(int) FNDBGCBACKREAD(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead);
|
---|
487 | /** Pointer to a FNDBGCBACKREAD() callback. */
|
---|
488 | typedef FNDBGCBACKREAD *PFNDBGCBACKREAD;
|
---|
489 |
|
---|
490 | /**
|
---|
491 | * Write (output).
|
---|
492 | *
|
---|
493 | * @returns VBox status code.
|
---|
494 | * @param pBack Pointer to the backend structure supplied by
|
---|
495 | * the backend. The backend can use this to find
|
---|
496 | * it's instance data.
|
---|
497 | * @param pvBuf What to write.
|
---|
498 | * @param cbBuf Number of bytes to write.
|
---|
499 | * @param pcbWritten Where to store the number of bytes actually written.
|
---|
500 | * If NULL the entire buffer must be successfully written.
|
---|
501 | */
|
---|
502 | typedef DECLCALLBACK(int) FNDBGCBACKWRITE(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten);
|
---|
503 | /** Pointer to a FNDBGCBACKWRITE() callback. */
|
---|
504 | typedef FNDBGCBACKWRITE *PFNDBGCBACKWRITE;
|
---|
505 |
|
---|
506 |
|
---|
507 | /**
|
---|
508 | * The communication backend provides the console with a number of callbacks
|
---|
509 | * which can be used
|
---|
510 | */
|
---|
511 | typedef struct DBGCBACK
|
---|
512 | {
|
---|
513 | /** Check for input. */
|
---|
514 | PFNDBGCBACKINPUT pfnInput;
|
---|
515 | /** Read input. */
|
---|
516 | PFNDBGCBACKREAD pfnRead;
|
---|
517 | /** Write output. */
|
---|
518 | PFNDBGCBACKWRITE pfnWrite;
|
---|
519 | } DBGCBACK;
|
---|
520 |
|
---|
521 |
|
---|
522 | /**
|
---|
523 | * Make a console instance.
|
---|
524 | *
|
---|
525 | * This will not return until either an 'exit' command is issued or a error code
|
---|
526 | * indicating connection loss is encountered.
|
---|
527 | *
|
---|
528 | * @returns VINF_SUCCESS if console termination caused by the 'exit' command.
|
---|
529 | * @returns The VBox status code causing the console termination.
|
---|
530 | *
|
---|
531 | * @param pVM VM Handle.
|
---|
532 | * @param pBack Pointer to the backend structure. This must contain
|
---|
533 | * a full set of function pointers to service the console.
|
---|
534 | * @param fFlags Reserved, must be zero.
|
---|
535 | * @remark A forced termination of the console is easiest done by forcing the
|
---|
536 | * callbacks to return fatal failures.
|
---|
537 | */
|
---|
538 | DBGDECL(int) DBGCCreate(PVM pVM, PDBGCBACK pBack, unsigned fFlags);
|
---|
539 |
|
---|
540 |
|
---|
541 | /**
|
---|
542 | * Register one or more external commands.
|
---|
543 | *
|
---|
544 | * @returns VBox status.
|
---|
545 | * @param paCommands Pointer to an array of command descriptors.
|
---|
546 | * The commands must be unique. It's not possible
|
---|
547 | * to register the same commands more than once.
|
---|
548 | * @param cCommands Number of commands.
|
---|
549 | */
|
---|
550 | DBGDECL(int) DBGCRegisterCommands(PCDBGCCMD paCommands, unsigned cCommands);
|
---|
551 |
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Deregister one or more external commands previously registered by
|
---|
555 | * DBGCRegisterCommands().
|
---|
556 | *
|
---|
557 | * @returns VBox status.
|
---|
558 | * @param paCommands Pointer to an array of command descriptors
|
---|
559 | * as given to DBGCRegisterCommands().
|
---|
560 | * @param cCommands Number of commands.
|
---|
561 | */
|
---|
562 | DBGDECL(int) DBGCDeregisterCommands(PCDBGCCMD paCommands, unsigned cCommands);
|
---|
563 |
|
---|
564 |
|
---|
565 | /**
|
---|
566 | * Spawns a new thread with a TCP based debugging console service.
|
---|
567 | *
|
---|
568 | * @returns VBox status.
|
---|
569 | * @param pVM VM handle.
|
---|
570 | * @param ppvData Where to store the pointer to instance data.
|
---|
571 | */
|
---|
572 | DBGDECL(int) DBGCTcpCreate(PVM pVM, void **ppvUser);
|
---|
573 |
|
---|
574 | /**
|
---|
575 | * Terminates any running TCP base debugger consolse service.
|
---|
576 | *
|
---|
577 | * @returns VBox status.
|
---|
578 | * @param pVM VM handle.
|
---|
579 | * @param pvData Instance data set by DBGCTcpCreate().
|
---|
580 | */
|
---|
581 | DBGDECL(int) DBGCTcpTerminate(PVM pVM, void *pvData);
|
---|
582 |
|
---|
583 |
|
---|
584 | __END_DECLS
|
---|
585 |
|
---|
586 | #endif /* __VBox_dbg_h__ */
|
---|