VirtualBox

source: vbox/trunk/include/VBox/dbgf.h@ 3257

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

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 49.1 KB
Line 
1/** @file
2 * DBGF - Debugging Facility.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef __VBox_dbgf_h__
22#define __VBox_dbgf_h__
23
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/vmm.h>
28#include <VBox/log.h>
29
30#include <iprt/stdarg.h>
31
32__BEGIN_DECLS
33
34
35/** @defgroup grp_dbgf The Debugging Facility API
36 * @{
37 */
38
39#ifdef IN_GC
40/** @addgroup grp_dbgf_gc The GC DBGF API
41 * @ingroup grp_dbgf
42 * @{
43 */
44
45/**
46 * \#DB (Debug event) handler.
47 *
48 * @returns VBox status code.
49 * VINF_SUCCESS means we completely handled this trap,
50 * other codes are passed execution to host context.
51 *
52 * @param pVM The VM handle.
53 * @param pRegFrame Pointer to the register frame for the trap.
54 * @param uDr6 The DR6 register value.
55 */
56DBGFGCDECL(int) DBGFGCTrap01Handler(PVM pVM, PCPUMCTXCORE pRegFrame, RTUINTREG uDr6);
57
58/**
59 * \#BP (Breakpoint) handler.
60 *
61 * @returns VBox status code.
62 * VINF_SUCCESS means we completely handled this trap,
63 * other codes are passed execution to host context.
64 *
65 * @param pVM The VM handle.
66 * @param pRegFrame Pointer to the register frame for the trap.
67 */
68DBGFGCDECL(int) DBGFGCTrap03Handler(PVM pVM, PCPUMCTXCORE pRegFrame);
69
70/** @} */
71#endif
72
73#ifdef IN_RING0
74/** @addgroup grp_dbgf_gc The R0 DBGF API
75 * @ingroup grp_dbgf
76 * @{
77 */
78
79/**
80 * \#DB (Debug event) handler.
81 *
82 * @returns VBox status code.
83 * VINF_SUCCESS means we completely handled this trap,
84 * other codes are passed execution to host context.
85 *
86 * @param pVM The VM handle.
87 * @param pRegFrame Pointer to the register frame for the trap.
88 * @param uDr6 The DR6 register value.
89 */
90DBGFR0DECL(int) DBGFR0Trap01Handler(PVM pVM, PCPUMCTXCORE pRegFrame, RTUINTREG uDr6);
91
92/**
93 * \#BP (Breakpoint) handler.
94 *
95 * @returns VBox status code.
96 * VINF_SUCCESS means we completely handled this trap,
97 * other codes are passed execution to host context.
98 *
99 * @param pVM The VM handle.
100 * @param pRegFrame Pointer to the register frame for the trap.
101 */
102DBGFR0DECL(int) DBGFR0Trap03Handler(PVM pVM, PCPUMCTXCORE pRegFrame);
103
104/** @} */
105#endif
106
107
108
109/**
110 * Mixed address.
111 */
112typedef struct DBGFADDRESS
113{
114 /** The flat address. */
115 RTGCUINTPTR FlatPtr;
116 /** The selector offset address. */
117 RTGCUINTPTR off;
118 /** The selector. DBGF_SEL_FLAT is a legal value. */
119 RTSEL Sel;
120 /** Flags describing further details about the address. */
121 uint16_t fFlags;
122} DBGFADDRESS;
123/** Pointer to a mixed address. */
124typedef DBGFADDRESS *PDBGFADDRESS;
125/** Pointer to a const mixed address. */
126typedef const DBGFADDRESS *PCDBGFADDRESS;
127
128/** @name DBGFADDRESS Flags.
129 * @{ */
130/** A 16:16 far address. */
131#define DBGFADDRESS_FLAGS_FAR16 0
132/** A 16:32 far address. */
133#define DBGFADDRESS_FLAGS_FAR32 1
134/** A 16:64 far address. */
135#define DBGFADDRESS_FLAGS_FAR64 2
136/** A flat address. */
137#define DBGFADDRESS_FLAGS_FLAT 3
138/** The address type mask. */
139#define DBGFADDRESS_FLAGS_TYPE_MASK 3
140
141/** Set if the address is valid. */
142#define DBGFADDRESS_FLAGS_VALID BIT(2)
143
144/** The address is within the hypervisor memoary area (HMA).
145 * If not set, the address can be assumed to be a guest address. */
146#define DBGFADDRESS_FLAGS_HMA BIT(3)
147
148/** Checks if the mixed address is flat or not. */
149#define DBGFADDRESS_IS_FLAT(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FLAT )
150/** Checks if the mixed address is far 16:16 or not. */
151#define DBGFADDRESS_IS_FAR16(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR16 )
152/** Checks if the mixed address is far 16:32 or not. */
153#define DBGFADDRESS_IS_FAR32(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR32 )
154/** Checks if the mixed address is far 16:64 or not. */
155#define DBGFADDRESS_IS_FAR64(pAddress) ( ((pAddress)->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) == DBGFADDRESS_FLAGS_FAR64 )
156/** Checks if the mixed address is valid. */
157#define DBGFADDRESS_IS_VALID(pAddress) ( (pAddress)->fFlags & DBGFADDRESS_FLAGS_VALID )
158/** @} */
159
160/**
161 * Creates a mixed address from a Sel:off pair.
162 *
163 * @returns VBox status code.
164 * @param pVM The VM handle.
165 * @param pAddress Where to store the mixed address.
166 * @param Sel The selector part.
167 * @param off The offset part.
168 */
169DBGFR3DECL(int) DBGFR3AddrFromSelOff(PVM pVM, PDBGFADDRESS pAddress, RTSEL Sel, RTUINTPTR off);
170
171/**
172 * Creates a mixed address from a flat address.
173 *
174 * @param pVM The VM handle.
175 * @param pAddress Where to store the mixed address.
176 * @param FlatPtr The flat pointer.
177 */
178DBGFR3DECL(void) DBGFR3AddrFromFlat(PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR FlatPtr);
179
180/**
181 * Checks if the specified address is valid (checks the structure pointer too).
182 *
183 * @returns true if valid.
184 * @returns false if invalid.
185 * @param pVM The VM handle.
186 * @param pAddress The address to validate.
187 */
188DBGFR3DECL(bool) DBGFR3AddrIsValid(PVM pVM, PCDBGFADDRESS pAddress);
189
190
191
192
193/**
194 * VMM Debug Event Type.
195 */
196typedef enum DBGFEVENTTYPE
197{
198 /** Halt completed.
199 * This notifies that a halt command have been successfully completed.
200 */
201 DBGFEVENT_HALT_DONE = 0,
202 /** Detach completed.
203 * This notifies that the detach command have been successfully completed.
204 */
205 DBGFEVENT_DETACH_DONE,
206 /** The command from the debugger is not recognized.
207 * This means internal error or half implemented features.
208 */
209 DBGFEVENT_INVALID_COMMAND,
210
211
212 /** Fatal error.
213 * This notifies a fatal error in the VMM and that the debugger get's a
214 * chance to first hand information about the the problem.
215 */
216 DBGFEVENT_FATAL_ERROR = 100,
217 /** Breakpoint Hit.
218 * This notifies that a breakpoint installed by the debugger was hit. The
219 * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
220 */
221 DBGFEVENT_BREAKPOINT,
222 /** Breakpoint Hit in the Hypervisor.
223 * This notifies that a breakpoint installed by the debugger was hit. The
224 * identifier of the breakpoint can be found in the DBGFEVENT::u::Bp::iBp member.
225 */
226 DBGFEVENT_BREAKPOINT_HYPER,
227 /** Assertion in the Hypervisor (breakpoint instruction).
228 * This notifies that a breakpoint instruction was hit in the hypervisor context.
229 */
230 DBGFEVENT_ASSERTION_HYPER,
231 /** Single Stepped.
232 * This notifies that a single step operation was completed.
233 */
234 DBGFEVENT_STEPPED,
235 /** Single Stepped.
236 * This notifies that a hypervisor single step operation was completed.
237 */
238 DBGFEVENT_STEPPED_HYPER,
239 /** The developer have used the DBGFSTOP macro or the PDMDeviceDBGFSTOP function
240 * to bring up the debugger at a specific place.
241 */
242 DBGFEVENT_DEV_STOP,
243 /** The VM is terminating.
244 * When this notification is received, the debugger thread should detach ASAP.
245 */
246 DBGFEVENT_TERMINATING,
247
248 /** The usual 32-bit hack. */
249 DBGFEVENT_32BIT_HACK = 0x7fffffff
250} DBGFEVENTTYPE;
251
252
253/**
254 * The context of an event.
255 */
256typedef enum DBGFEVENTCTX
257{
258 /** The usual invalid entry. */
259 DBGFEVENTCTX_INVALID = 0,
260 /** Raw mode. */
261 DBGFEVENTCTX_RAW,
262 /** Recompiled mode. */
263 DBGFEVENTCTX_REM,
264 /** VMX / AVT mode. */
265 DBGFEVENTCTX_HWACCL,
266 /** Hypervisor context. */
267 DBGFEVENTCTX_HYPER,
268 /** Other mode */
269 DBGFEVENTCTX_OTHER,
270
271 /** The usual 32-bit hack */
272 DBGFEVENTCTX_32BIT_HACK = 0x7fffffff
273} DBGFEVENTCTX;
274
275/**
276 * VMM Debug Event.
277 */
278typedef struct DBGFEVENT
279{
280 /** Type. */
281 DBGFEVENTTYPE enmType;
282 /** Context */
283 DBGFEVENTCTX enmCtx;
284 /** Type specific data. */
285 union
286 {
287 /** Fatal error details. */
288 struct
289 {
290 /** The GC return code. */
291 int rc;
292 } FatalError;
293
294 /** Source location. */
295 struct
296 {
297 /** File name. */
298 R3PTRTYPE(const char *) pszFile;
299 /** Function name. */
300 R3PTRTYPE(const char *) pszFunction;
301 /** Message. */
302 R3PTRTYPE(const char *) pszMessage;
303 /** Line number. */
304 unsigned uLine;
305 } Src;
306
307 /** Assertion messages. */
308 struct
309 {
310 /** The first message. */
311 R3PTRTYPE(const char *) pszMsg1;
312 /** The second message. */
313 R3PTRTYPE(const char *) pszMsg2;
314 } Assert;
315
316 /** Breakpoint. */
317 struct DBGFEVENTBP
318 {
319 /** The identifier of the breakpoint which was hit. */
320 RTUINT iBp;
321 } Bp;
322 /** Padding for ensuring that the structure is 8 byte aligned. */
323 uint64_t au64Padding[4];
324 } u;
325} DBGFEVENT;
326/** Pointer to VMM Debug Event. */
327typedef DBGFEVENT *PDBGFEVENT;
328/** Pointer to const VMM Debug Event. */
329typedef const DBGFEVENT *PCDBGFEVENT;
330
331
332/** @def DBGFSTOP
333 * Stops the debugger raising a DBGFEVENT_DEVELOPER_STOP event.
334 *
335 * @returns VBox status code which must be propagated up to EM if not VINF_SUCCESS.
336 * @param pVM VM Handle.
337 */
338#ifdef VBOX_STRICT
339# define DBGFSTOP(pVM) DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, __FILE__, __LINE__, __PRETTY_FUNCTION__, NULL)
340#else
341# define DBGFSTOP(pVM) VINF_SUCCESS
342#endif
343
344/**
345 * Initializes the DBGF.
346 *
347 * @returns VBox status code.
348 * @param pVM VM handle.
349 */
350DBGFR3DECL(int) DBGFR3Init(PVM pVM);
351
352/**
353 * Termiantes and cleans up resources allocated by the DBGF.
354 *
355 * @returns VBox status code.
356 * @param pVM VM Handle.
357 */
358DBGFR3DECL(int) DBGFR3Term(PVM pVM);
359
360/**
361 * Applies relocations to data and code managed by this
362 * component. This function will be called at init and
363 * whenever the VMM need to relocate it self inside the GC.
364 *
365 * @param pVM VM handle.
366 * @param offDelta Relocation delta relative to old location.
367 */
368DBGFR3DECL(void) DBGFR3Relocate(PVM pVM, RTGCINTPTR offDelta);
369
370/**
371 * Forced action callback.
372 * The VMM will call this from it's main loop when VM_FF_DBGF is set.
373 *
374 * The function checks and executes pending commands from the debugger.
375 *
376 * @returns VINF_SUCCESS normally.
377 * @returns VERR_DBGF_RAISE_FATAL_ERROR to pretend a fatal error happend.
378 * @param pVM VM Handle.
379 */
380DBGFR3DECL(int) DBGFR3VMMForcedAction(PVM pVM);
381
382/**
383 * Send a generic debugger event which takes no data.
384 *
385 * @returns VBox status.
386 * @param pVM The VM handle.
387 * @param enmEvent The event to send.
388 */
389DBGFR3DECL(int) DBGFR3Event(PVM pVM, DBGFEVENTTYPE enmEvent);
390
391/**
392 * Send a debugger event which takes the full source file location.
393 *
394 * @returns VBox status.
395 * @param pVM The VM handle.
396 * @param enmEvent The event to send.
397 * @param pszFile Source file.
398 * @param uLine Line number in source file.
399 * @param pszFunction Function name.
400 * @param pszFormat Message which accompanies the event.
401 * @param ... Message arguments.
402 */
403DBGFR3DECL(int) DBGFR3EventSrc(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, ...);
404
405/**
406 * Send a debugger event which takes the full source file location.
407 *
408 * @returns VBox status.
409 * @param pVM The VM handle.
410 * @param enmEvent The event to send.
411 * @param pszFile Source file.
412 * @param uLine Line number in source file.
413 * @param pszFunction Function name.
414 * @param pszFormat Message which accompanies the event.
415 * @param args Message arguments.
416 */
417DBGFR3DECL(int) DBGFR3EventSrcV(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszFile, unsigned uLine, const char *pszFunction, const char *pszFormat, va_list args);
418
419/**
420 * Send a debugger event which takes the two assertion messages.
421 *
422 * @returns VBox status.
423 * @param pVM The VM handle.
424 * @param enmEvent The event to send.
425 * @param pszMsg1 First assertion message.
426 * @param pszMsg2 Second assertion message.
427 */
428DBGFR3DECL(int) DBGFR3EventAssertion(PVM pVM, DBGFEVENTTYPE enmEvent, const char *pszMsg1, const char *pszMsg2);
429
430/**
431 * Breakpoint was hit somewhere.
432 * Figure out which breakpoint it is and notify the debugger.
433 *
434 * @returns VBox status.
435 * @param pVM The VM handle.
436 * @param enmEvent DBGFEVENT_BREAKPOINT_HYPER or DBGFEVENT_BREAKPOINT.
437 */
438DBGFR3DECL(int) DBGFR3EventBreakpoint(PVM pVM, DBGFEVENTTYPE enmEvent);
439
440/**
441 * Attaches a debugger to the specified VM.
442 *
443 * Only one debugger at a time.
444 *
445 * @returns VBox status code.
446 * @param pVM VM Handle.
447 */
448DBGFR3DECL(int) DBGFR3Attach(PVM pVM);
449
450/**
451 * Detaches a debugger from the specified VM.
452 *
453 * Caller must be attached to the VM.
454 *
455 * @returns VBox status code.
456 * @param pVM VM Handle.
457 */
458DBGFR3DECL(int) DBGFR3Detach(PVM pVM);
459
460/**
461 * Wait for a debug event.
462 *
463 * @returns VBox status. Will not return VBOX_INTERRUPTED.
464 * @param pVM VM handle.
465 * @param cMillies Number of millies to wait.
466 * @param ppEvent Where to store the event pointer.
467 */
468DBGFR3DECL(int) DBGFR3EventWait(PVM pVM, unsigned cMillies, PCDBGFEVENT *ppEvent);
469
470/**
471 * Halts VM execution.
472 *
473 * After calling this the VM isn't actually halted till an DBGFEVENT_HALT_DONE
474 * arrives. Until that time it's not possible to issue any new commands.
475 *
476 * @returns VBox status.
477 * @param pVM VM handle.
478 */
479DBGFR3DECL(int) DBGFR3Halt(PVM pVM);
480
481/**
482 * Checks if the VM is halted by the debugger.
483 *
484 * @returns True if halted.
485 * @returns False if not halted.
486 * @param pVM VM handle.
487 */
488DBGFR3DECL(bool) DBGFR3IsHalted(PVM pVM);
489
490/**
491 * Checks if the the debugger can wait for events or not.
492 *
493 * This function is only used by lazy, multiplexing debuggers. :-)
494 *
495 * @returns True if waitable.
496 * @returns False if not waitable.
497 * @param pVM VM handle.
498 */
499DBGFR3DECL(bool) DBGFR3CanWait(PVM pVM);
500
501/**
502 * Resumes VM execution.
503 *
504 * There is no receipt event on this command.
505 *
506 * @returns VBox status.
507 * @param pVM VM handle.
508 */
509DBGFR3DECL(int) DBGFR3Resume(PVM pVM);
510
511/**
512 * Step Into.
513 *
514 * A single step event is generated from this command.
515 * The current implementation is not reliable, so don't rely on the event comming.
516 *
517 * @returns VBox status.
518 * @param pVM VM handle.
519 */
520DBGFR3DECL(int) DBGFR3Step(PVM pVM);
521
522/**
523 * Call this to single step rawmode or recompiled mode.
524 *
525 * You must pass down the return code to the EM loop! That's
526 * where the actual single stepping take place (at least in the
527 * current implementation).
528 *
529 * @returns VINF_EM_DBG_STEP
530 * @thread EMT
531 */
532DBGFR3DECL(int) DBGFR3PrgStep(PVM pVM);
533
534
535/** Breakpoint type. */
536typedef enum DBGFBPTYPE
537{
538 /** Free breakpoint entry. */
539 DBGFBPTYPE_FREE = 0,
540 /** Debug register. */
541 DBGFBPTYPE_REG,
542 /** INT 3 instruction. */
543 DBGFBPTYPE_INT3,
544 /** Recompiler. */
545 DBGFBPTYPE_REM,
546 /** ensure 32-bit size. */
547 DBGFBPTYPE_32BIT_HACK = 0x7fffffff
548} DBGFBPTYPE;
549
550
551/**
552 * A Breakpoint.
553 */
554typedef struct DBGFBP
555{
556 /** The number of breakpoint hits. */
557 uint64_t cHits;
558 /** The hit number which starts to trigger the breakpoint. */
559 uint64_t iHitTrigger;
560 /** The hit number which stops triggering the breakpoint (disables it).
561 * Use ~(uint64_t)0 if it should never stop. */
562 uint64_t iHitDisable;
563 /** The Flat GC address of the breakpoint.
564 * (PC register value if REM type?) */
565 RTGCUINTPTR GCPtr;
566 /** The breakpoint id. */
567 RTUINT iBp;
568 /** The breakpoint status - enabled or disabled. */
569 bool fEnabled;
570
571 /** The breakpoint type. */
572 DBGFBPTYPE enmType;
573 /** Union of type specific data. */
574 union
575 {
576 /** Debug register data. */
577 struct DBGFBPREG
578 {
579 /** The debug register number. */
580 uint8_t iReg;
581 /** The access type (one of the X86_DR7_RW_* value). */
582 uint8_t fType;
583 /** The access size. */
584 uint8_t cb;
585 } Reg;
586 /** Recompiler breakpoint data. */
587 struct DBGFBPINT3
588 {
589 /** The byte value we replaced by the INT 3 instruction. */
590 uint8_t bOrg;
591 } Int3;
592
593 /** Recompiler breakpoint data. */
594 struct DBGFBPREM
595 {
596 /** nothing yet */
597 uint8_t fDummy;
598 } Rem;
599 /** Paddind to ensure that the size is identical on win32 and linux. */
600 uint64_t u64Padding;
601 } u;
602} DBGFBP;
603
604/** Pointer to a breakpoint. */
605typedef DBGFBP *PDBGFBP;
606/** Pointer to a const breakpoint. */
607typedef const DBGFBP *PCDBGFBP;
608
609
610/**
611 * Sets a breakpoint (int 3 based).
612 *
613 * @returns VBox status code.
614 * @param pVM The VM handle.
615 * @param pAddress The address of the breakpoint.
616 * @param iHitTrigger The hit count at which the breakpoint start triggering.
617 * Use 0 (or 1) if it's gonna trigger at once.
618 * @param iHitDisable The hit count which disables the breakpoint.
619 * Use ~(uint64_t) if it's never gonna be disabled.
620 * @param piBp Where to store the breakpoint id. (optional)
621 * @thread Any thread.
622 */
623DBGFR3DECL(int) DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
624
625/**
626 * Sets a register breakpoint.
627 *
628 * @returns VBox status code.
629 * @param pVM The VM handle.
630 * @param pAddress The address of the breakpoint.
631 * @param iHitTrigger The hit count at which the breakpoint start triggering.
632 * Use 0 (or 1) if it's gonna trigger at once.
633 * @param iHitDisable The hit count which disables the breakpoint.
634 * Use ~(uint64_t) if it's never gonna be disabled.
635 * @param fType The access type (one of the X86_DR7_RW_* defines).
636 * @param cb The access size - 1,2,4 or 8 (the latter is AMD64 long mode only.
637 * Must be 1 if fType is X86_DR7_RW_EO.
638 * @param piBp Where to store the breakpoint id. (optional)
639 * @thread Any thread.
640 */
641DBGFR3DECL(int) DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
642 uint8_t fType, uint8_t cb, PRTUINT piBp);
643
644/**
645 * Sets a recompiler breakpoint.
646 *
647 * @returns VBox status code.
648 * @param pVM The VM handle.
649 * @param pAddress The address of the breakpoint.
650 * @param iHitTrigger The hit count at which the breakpoint start triggering.
651 * Use 0 (or 1) if it's gonna trigger at once.
652 * @param iHitDisable The hit count which disables the breakpoint.
653 * Use ~(uint64_t) if it's never gonna be disabled.
654 * @param piBp Where to store the breakpoint id. (optional)
655 * @thread Any thread.
656 */
657DBGFR3DECL(int) DBGFR3BpSetREM(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, PRTUINT piBp);
658
659/**
660 * Clears a breakpoint.
661 *
662 * @returns VBox status code.
663 * @param pVM The VM handle.
664 * @param iBp The id of the breakpoint which should be removed (cleared).
665 * @thread Any thread.
666 */
667DBGFR3DECL(int) DBGFR3BpClear(PVM pVM, RTUINT iBp);
668
669/**
670 * Enables a breakpoint.
671 *
672 * @returns VBox status code.
673 * @param pVM The VM handle.
674 * @param iBp The id of the breakpoint which should be enabled.
675 * @thread Any thread.
676 */
677DBGFR3DECL(int) DBGFR3BpEnable(PVM pVM, RTUINT iBp);
678
679/**
680 * Disables a breakpoint.
681 *
682 * @returns VBox status code.
683 * @param pVM The VM handle.
684 * @param iBp The id of the breakpoint which should be disabled.
685 * @thread Any thread.
686 */
687DBGFR3DECL(int) DBGFR3BpDisable(PVM pVM, RTUINT iBp);
688
689/**
690 * Breakpoint enumeration callback function.
691 *
692 * @returns VBox status code. Any failure will stop the enumeration.
693 * @param pVM The VM handle.
694 * @param pvUser The user argument.
695 * @param pBp Pointer to the breakpoint information. (readonly)
696 */
697typedef DECLCALLBACK(int) FNDBGFBPENUM(PVM pVM, void *pvUser, PCDBGFBP pBp);
698/** Pointer to a breakpoint enumeration callback function. */
699typedef FNDBGFBPENUM *PFNDBGFBPENUM;
700
701/**
702 * Enumerate the breakpoints.
703 *
704 * @returns VBox status code.
705 * @param pVM The VM handle.
706 * @param pfnCallback The callback function.
707 * @param pvUser The user argument to pass to the callback.
708 * @thread Any thread but the callback will be called from EMT.
709 */
710DBGFR3DECL(int) DBGFR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
711
712
713/**
714 * Gets the hardware breakpoint configuration as DR7.
715 *
716 * @returns DR7 from the DBGF point of view.
717 * @param pVM The VM handle.
718 */
719DBGFDECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM);
720
721/**
722 * Gets the address of the hardware breakpoint number 0.
723 *
724 * @returns DR0 from the DBGF point of view.
725 * @param pVM The VM handle.
726 */
727DBGFDECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM);
728
729/**
730 * Gets the address of the hardware breakpoint number 1.
731 *
732 * @returns DR1 from the DBGF point of view.
733 * @param pVM The VM handle.
734 */
735DBGFDECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM);
736
737/**
738 * Gets the address of the hardware breakpoint number 2.
739 *
740 * @returns DR2 from the DBGF point of view.
741 * @param pVM The VM handle.
742 */
743DBGFDECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM);
744
745/**
746 * Gets the address of the hardware breakpoint number 3.
747 *
748 * @returns DR3 from the DBGF point of view.
749 * @param pVM The VM handle.
750 */
751DBGFDECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM);
752
753/**
754 * Returns single stepping state
755 *
756 * @returns stepping or not
757 * @param pVM The VM handle.
758 */
759DBGFDECL(bool) DBGFIsStepping(PVM pVM);
760
761
762/** Pointer to a info helper callback structure. */
763typedef struct DBGFINFOHLP *PDBGFINFOHLP;
764/** Pointer to a const info helper callback structure. */
765typedef const struct DBGFINFOHLP *PCDBGFINFOHLP;
766
767/**
768 * Info helper callback structure.
769 */
770typedef struct DBGFINFOHLP
771{
772 /**
773 * Print formatted string.
774 *
775 * @param pHlp Pointer to this structure.
776 * @param pszFormat The format string.
777 * @param ... Arguments.
778 */
779 DECLCALLBACKMEMBER(void, pfnPrintf)(PCDBGFINFOHLP pHlp, const char *pszFormat, ...);
780
781 /**
782 * Print formatted string.
783 *
784 * @param pHlp Pointer to this structure.
785 * @param pszFormat The format string.
786 * @param args Argument list.
787 */
788 DECLCALLBACKMEMBER(void, pfnPrintfV)(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args);
789} DBGFINFOHLP;
790
791
792/**
793 * Info handler, device version.
794 *
795 * @param pDevIns Device instance which registered the info.
796 * @param pHlp Callback functions for doing output.
797 * @param pszArgs Argument string. Optional and specific to the handler.
798 */
799typedef DECLCALLBACK(void) FNDBGFHANDLERDEV(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
800/** Pointer to a FNDBGFHANDLERDEV function. */
801typedef FNDBGFHANDLERDEV *PFNDBGFHANDLERDEV;
802
803/**
804 * Info handler, driver version.
805 *
806 * @param pDrvIns Driver instance which registered the info.
807 * @param pHlp Callback functions for doing output.
808 * @param pszArgs Argument string. Optional and specific to the handler.
809 */
810typedef DECLCALLBACK(void) FNDBGFHANDLERDRV(PPDMDRVINS pDrvIns, PCDBGFINFOHLP pHlp, const char *pszArgs);
811/** Pointer to a FNDBGFHANDLERDRV function. */
812typedef FNDBGFHANDLERDRV *PFNDBGFHANDLERDRV;
813
814/**
815 * Info handler, internal version.
816 *
817 * @param pVM The VM handle.
818 * @param pHlp Callback functions for doing output.
819 * @param pszArgs Argument string. Optional and specific to the handler.
820 */
821typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
822/** Pointer to a FNDBGFHANDLERINT function. */
823typedef FNDBGFHANDLERINT *PFNDBGFHANDLERINT;
824
825/**
826 * Info handler, external version.
827 *
828 * @param pvUser User argument.
829 * @param pHlp Callback functions for doing output.
830 * @param pszArgs Argument string. Optional and specific to the handler.
831 */
832typedef DECLCALLBACK(void) FNDBGFHANDLEREXT(void *pvUser, PCDBGFINFOHLP pHlp, const char *pszArgs);
833/** Pointer to a FNDBGFHANDLEREXT function. */
834typedef FNDBGFHANDLEREXT *PFNDBGFHANDLEREXT;
835
836
837/** @name Flags for the info registration functions.
838 * @{ */
839/** The handler must run on the EMT. */
840#define DBGFINFO_FLAGS_RUN_ON_EMT BIT(0)
841/** @} */
842
843
844/**
845 * Register a info handler owned by a device.
846 *
847 * @returns VBox status code.
848 * @param pVM VM handle.
849 * @param pszName The identifier of the info.
850 * @param pszDesc The description of the info and any arguments the handler may take.
851 * @param pfnHandler The handler function to be called to display the info.
852 * @param pDevIns The device instance owning the info.
853 */
854DBGFR3DECL(int) DBGFR3InfoRegisterDevice(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDEV pfnHandler, PPDMDEVINS pDevIns);
855
856/**
857 * Register a info handler owned by a driver.
858 *
859 * @returns VBox status code.
860 * @param pVM VM handle.
861 * @param pszName The identifier of the info.
862 * @param pszDesc The description of the info and any arguments the handler may take.
863 * @param pfnHandler The handler function to be called to display the info.
864 * @param pDrvIns The driver instance owning the info.
865 */
866DBGFR3DECL(int) DBGFR3InfoRegisterDriver(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERDRV pfnHandler, PPDMDRVINS pDrvIns);
867
868/**
869 * Register a info handler owned by an internal component.
870 *
871 * @returns VBox status code.
872 * @param pVM VM handle.
873 * @param pszName The identifier of the info.
874 * @param pszDesc The description of the info and any arguments the handler may take.
875 * @param pfnHandler The handler function to be called to display the info.
876 */
877DBGFR3DECL(int) DBGFR3InfoRegisterInternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler);
878
879/**
880 * Register a info handler owned by an internal component.
881 *
882 * @returns VBox status code.
883 * @param pVM VM handle.
884 * @param pszName The identifier of the info.
885 * @param pszDesc The description of the info and any arguments the handler may take.
886 * @param pfnHandler The handler function to be called to display the info.
887 * @param fFlags Flags, see the DBGFINFO_FLAGS_*.
888 */
889DBGFR3DECL(int) DBGFR3InfoRegisterInternalEx(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLERINT pfnHandler, uint32_t fFlags);
890
891/**
892 * Register a info handler owned by an external component.
893 *
894 * @returns VBox status code.
895 * @param pVM VM handle.
896 * @param pszName The identifier of the info.
897 * @param pszDesc The description of the info and any arguments the handler may take.
898 * @param pfnHandler The handler function to be called to display the info.
899 * @param pvUser User argument to be passed to the handler.
900 */
901DBGFR3DECL(int) DBGFR3InfoRegisterExternal(PVM pVM, const char *pszName, const char *pszDesc, PFNDBGFHANDLEREXT pfnHandler, void *pvUser);
902
903/**
904 * Deregister one(/all) info handler(s) owned by a device.
905 *
906 * @returns VBox status code.
907 * @param pVM VM Handle.
908 * @param pDevIns Device instance.
909 * @param pszName The identifier of the info. If NULL all owned by the device.
910 */
911DBGFR3DECL(int) DBGFR3InfoDeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName);
912
913/**
914 * Deregister one(/all) info handler(s) owned by a driver.
915 *
916 * @returns VBox status code.
917 * @param pVM VM Handle.
918 * @param pDrvIns Driver instance.
919 * @param pszName The identifier of the info. If NULL all owned by the driver.
920 */
921DBGFR3DECL(int) DBGFR3InfoDeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName);
922
923/**
924 * Deregister a info handler owned by an internal component.
925 *
926 * @returns VBox status code.
927 * @param pVM VM Handle.
928 * @param pszName The identifier of the info. If NULL all owned by the device.
929 */
930DBGFR3DECL(int) DBGFR3InfoDeregisterInternal(PVM pVM, const char *pszName);
931
932/**
933 * Deregister a info handler owned by an external component.
934 *
935 * @returns VBox status code.
936 * @param pVM VM Handle.
937 * @param pszName The identifier of the info. If NULL all owned by the device.
938 */
939DBGFR3DECL(int) DBGFR3InfoDeregisterExternal(PVM pVM, const char *pszName);
940
941/**
942 * Display a piece of info writing to the supplied handler.
943 *
944 * @returns VBox status code.
945 * @param pVM VM handle.
946 * @param pszName The identifier of the info to display.
947 * @param pszArgs Arguments to the info handler.
948 * @param pHlp The output helper functions. If NULL the logger will be used.
949 */
950DBGFR3DECL(int) DBGFR3Info(PVM pVM, const char *pszName, const char *pszArgs, PCDBGFINFOHLP pHlp);
951
952/** @def DBGFR3InfoLog
953 * Display a piece of info writing to the log if enabled.
954 *
955 * @param pVM VM handle.
956 * @param pszName The identifier of the info to display.
957 * @param pszArgs Arguments to the info handler.
958 */
959#ifdef LOG_ENABLED
960#define DBGFR3InfoLog(pVM, pszName, pszArgs) \
961 do { \
962 if (LogIsEnabled()) \
963 DBGFR3Info(pVM, pszName, pszArgs, NULL); \
964 } while (0)
965#else
966#define DBGFR3InfoLog(pVM, pszName, pszArgs) do { } while (0)
967#endif
968
969
970/**
971 * Changes the logger group settings.
972 *
973 * @returns VBox status code.
974 * @param pVM The VM handle.
975 * @param pszGroupSettings The group settings string. (VBOX_LOG)
976 */
977DBGFR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings);
978
979/**
980 * Changes the logger flag settings.
981 *
982 * @returns VBox status code.
983 * @param pVM The VM handle.
984 * @param pszFlagSettings The flag settings string. (VBOX_LOG_FLAGS)
985 */
986DBGFR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings);
987
988/**
989 * Changes the logger destination settings.
990 *
991 * @returns VBox status code.
992 * @param pVM The VM handle.
993 * @param pszDestSettings The destination settings string. (VBOX_LOG_DEST)
994 */
995DBGFR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings);
996
997
998/**
999 * Enumeration callback for use with DBGFR3InfoEnum.
1000 *
1001 * @returns VBox status code.
1002 * A status code indicating failure will end the enumeration
1003 * and DBGFR3InfoEnum will return with that status code.
1004 * @param pVM VM handle.
1005 * @param pszName Info identifier name.
1006 * @param pszDesc The description.
1007 */
1008typedef DECLCALLBACK(int) FNDBGFINFOENUM(PVM pVM, const char *pszName, const char *pszDesc, void *pvUser);
1009/** Pointer to a FNDBGFINFOENUM function. */
1010typedef FNDBGFINFOENUM *PFNDBGFINFOENUM;
1011
1012/**
1013 * Enumerate all the register info handlers.
1014 *
1015 * @returns VBox status code.
1016 * @param pVM VM handle.
1017 * @param pfnCallback Pointer to callback function.
1018 * @param pvUser User argument to pass to the callback.
1019 */
1020DBGFR3DECL(int) DBGFR3InfoEnum(PVM pVM, PFNDBGFINFOENUM pfnCallback, void *pvUser);
1021
1022/**
1023 * Gets the logger info helper.
1024 * The returned info helper will unconditionally write all output to the log.
1025 *
1026 * @returns Pointer to the logger info helper.
1027 */
1028DBGFR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogHlp(void);
1029
1030/**
1031 * Gets the release logger info helper.
1032 * The returned info helper will unconditionally write all output to the release log.
1033 *
1034 * @returns Pointer to the release logger info helper.
1035 */
1036DBGFR3DECL(PCDBGFINFOHLP) DBGFR3InfoLogRelHlp(void);
1037
1038
1039
1040/** Max length (including '\\0') of a symbol name. */
1041#define DBGF_SYMBOL_NAME_LENGTH 512
1042
1043/**
1044 * Debug symbol.
1045 */
1046typedef struct DBGFSYMBOL
1047{
1048 /** Symbol value (address). */
1049 RTGCUINTPTR Value;
1050 /** Symbol size. */
1051 uint32_t cb;
1052 /** Symbol Flags. (reserved). */
1053 uint32_t fFlags;
1054 /** Symbol name. */
1055 char szName[DBGF_SYMBOL_NAME_LENGTH];
1056} DBGFSYMBOL;
1057/** Pointer to debug symbol. */
1058typedef DBGFSYMBOL *PDBGFSYMBOL;
1059/** Pointer to const debug symbol. */
1060typedef const DBGFSYMBOL *PCDBGFSYMBOL;
1061
1062/**
1063 * Debug line number information.
1064 */
1065typedef struct DBGFLINE
1066{
1067 /** Address. */
1068 RTGCUINTPTR Address;
1069 /** Line number. */
1070 uint32_t uLineNo;
1071 /** Filename. */
1072 char szFilename[260];
1073} DBGFLINE;
1074/** Pointer to debug line number. */
1075typedef DBGFLINE *PDBGFLINE;
1076/** Pointer to const debug line number. */
1077typedef const DBGFLINE *PCDBGFLINE;
1078
1079
1080/**
1081 * Load debug info, optionally related to a specific module.
1082 *
1083 * @returns VBox status.
1084 * @param pVM VM Handle.
1085 * @param pszFilename Path to the file containing the symbol information.
1086 * This can be the executable image, a flat symbol file of some kind or stripped debug info.
1087 * @param AddressDelta The value to add to the loaded symbols.
1088 * @param pszName Short hand name for the module. If not related to a module specify NULL.
1089 * @param Address Address which the image is loaded at. This will be used to reference the module other places in the api.
1090 * Ignored when pszName is NULL.
1091 * @param cbImage Size of the image.
1092 * Ignored when pszName is NULL.
1093 */
1094DBGFR3DECL(int) DBGFR3ModuleLoad(PVM pVM, const char *pszFilename, RTGCUINTPTR AddressDelta, const char *pszName, RTGCUINTPTR ModuleAddress, unsigned cbImage);
1095
1096/**
1097 * Interface used by PDMR3LdrRelocate for telling us that a GC module has been relocated.
1098 *
1099 * @param pVM The VM handle.
1100 * @param OldImageBase The old image base.
1101 * @param NewImageBase The new image base.
1102 * @param cbImage The image size.
1103 * @param pszFilename The image filename.
1104 * @param pszName The module name.
1105 */
1106DBGFR3DECL(void) DBGFR3ModuleRelocate(PVM pVM, RTGCUINTPTR OldImageBase, RTGCUINTPTR NewImageBase, unsigned cbImage,
1107 const char *pszFilename, const char *pszName);
1108
1109/**
1110 * Adds a symbol to the debug info manager.
1111 *
1112 * @returns VBox status.
1113 * @param pVM VM Handle.
1114 * @param ModuleAddress Module address. Use 0 if no module.
1115 * @param SymbolAddress Symbol address
1116 * @param cbSymbol Size of the symbol. Use 0 if info not available.
1117 * @param pszSymbol Symbol name.
1118 */
1119DBGFR3DECL(int) DBGFR3SymbolAdd(PVM pVM, RTGCUINTPTR ModuleAddress, RTGCUINTPTR SymbolAddress, RTUINT cbSymbol, const char *pszSymbol);
1120
1121/**
1122 * Find symbol by address (nearest).
1123 *
1124 * @returns VBox status.
1125 * @param pVM VM handle.
1126 * @param Address Address.
1127 * @param poffDisplacement Where to store the symbol displacement from Address.
1128 * @param pSymbol Where to store the symbol info.
1129 */
1130DBGFR3DECL(int) DBGFR3SymbolByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFSYMBOL pSymbol);
1131
1132/**
1133 * Find symbol by name (first).
1134 *
1135 * @returns VBox status.
1136 * @param pVM VM handle.
1137 * @param pszSymbol Symbol name.
1138 * @param pSymbol Where to store the symbol info.
1139 */
1140DBGFR3DECL(int) DBGFR3SymbolByName(PVM pVM, const char *pszSymbol, PDBGFSYMBOL pSymbol);
1141
1142/**
1143 * Find symbol by address (nearest), allocate return buffer.
1144 *
1145 * @returns Pointer to the symbol. Must be freed using DBGFR3SymbolFree().
1146 * @returns NULL if the symbol was not found or if we're out of memory.
1147 * @param pVM VM handle.
1148 * @param Address Address.
1149 * @param poffDisplacement Where to store the symbol displacement from Address.
1150 */
1151DBGFR3DECL(PDBGFSYMBOL) DBGFR3SymbolByAddrAlloc(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement);
1152
1153/**
1154 * Find symbol by name (first), allocate return buffer.
1155 *
1156 * @returns Pointer to the symbol. Must be freed using DBGFR3SymbolFree().
1157 * @returns NULL if the symbol was not found or if we're out of memory.
1158 * @param pVM VM handle.
1159 * @param pszSymbol Symbol name.
1160 * @param ppSymbol Where to store the pointer to the symbol info.
1161 */
1162DBGFR3DECL(PDBGFSYMBOL) DBGFR3SymbolByNameAlloc(PVM pVM, const char *pszSymbol);
1163
1164/**
1165 * Frees a symbol returned by DBGFR3SymbolbyNameAlloc() or DBGFR3SymbolByAddressAlloc().
1166 *
1167 * @param pSymbol Pointer to the symbol.
1168 */
1169DBGFR3DECL(void) DBGFR3SymbolFree(PDBGFSYMBOL pSymbol);
1170
1171/**
1172 * Find line by address (nearest).
1173 *
1174 * @returns VBox status.
1175 * @param pVM VM handle.
1176 * @param Address Address.
1177 * @param poffDisplacement Where to store the line displacement from Address.
1178 * @param pLine Where to store the line info.
1179 */
1180DBGFR3DECL(int) DBGFR3LineByAddr(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement, PDBGFLINE pLine);
1181
1182/**
1183 * Find line by address (nearest), allocate return buffer.
1184 *
1185 * @returns Pointer to the line. Must be freed using DBGFR3LineFree().
1186 * @returns NULL if the line was not found or if we're out of memory.
1187 * @param pVM VM handle.
1188 * @param Address Address.
1189 * @param poffDisplacement Where to store the line displacement from Address.
1190 */
1191DBGFR3DECL(PDBGFLINE) DBGFR3LineByAddrAlloc(PVM pVM, RTGCUINTPTR Address, PRTGCINTPTR poffDisplacement);
1192
1193/**
1194 * Frees a line returned by DBGFR3LineByAddressAlloc().
1195 *
1196 * @param pLine Pointer to the line.
1197 */
1198DBGFR3DECL(void) DBGFR3LineFree(PDBGFLINE pLine);
1199
1200/**
1201 * Return type.
1202 */
1203typedef enum DBGFRETRUNTYPE
1204{
1205 /** The usual invalid 0 value. */
1206 DBGFRETURNTYPE_INVALID = 0,
1207 /** Near 16-bit return. */
1208 DBGFRETURNTYPE_NEAR16,
1209 /** Near 32-bit return. */
1210 DBGFRETURNTYPE_NEAR32,
1211 /** Near 64-bit return. */
1212 DBGFRETURNTYPE_NEAR64,
1213 /** Far 16:16 return. */
1214 DBGFRETURNTYPE_FAR16,
1215 /** Far 16:32 return. */
1216 DBGFRETURNTYPE_FAR32,
1217 /** Far 16:64 return. */
1218 DBGFRETURNTYPE_FAR64,
1219 /** 16-bit iret return (e.g. real or 286 protect mode). */
1220 DBGFRETURNTYPE_IRET16,
1221 /** 32-bit iret return. */
1222 DBGFRETURNTYPE_IRET32,
1223 /** 32-bit iret return. */
1224 DBGFRETURNTYPE_IRET32_PRIV,
1225 /** 32-bit iret return to V86 mode. */
1226 DBGFRETURNTYPE_IRET32_V86,
1227 /** @todo 64-bit iret return. */
1228 DBGFRETURNTYPE_IRET64,
1229 /** The usual 32-bit blowup. */
1230 DBGFRETURNTYPE_32BIT_HACK = 0x7fffffff
1231} DBGFRETURNTYPE;
1232
1233
1234/**
1235 * Figures the size of the return state on the stack.
1236 *
1237 * @returns number of bytes. 0 if invalid parameter.
1238 * @param enmRetType The type of return.
1239 */
1240DECLINLINE(unsigned) DBGFReturnTypeSize(DBGFRETURNTYPE enmRetType)
1241{
1242 switch (enmRetType)
1243 {
1244 case DBGFRETURNTYPE_NEAR16: return 2;
1245 case DBGFRETURNTYPE_NEAR32: return 4;
1246 case DBGFRETURNTYPE_NEAR64: return 8;
1247 case DBGFRETURNTYPE_FAR16: return 4;
1248 case DBGFRETURNTYPE_FAR32: return 4;
1249 case DBGFRETURNTYPE_FAR64: return 8;
1250 case DBGFRETURNTYPE_IRET16: return 6;
1251 case DBGFRETURNTYPE_IRET32: return 4*3;
1252 case DBGFRETURNTYPE_IRET32_PRIV: return 4*5;
1253 case DBGFRETURNTYPE_IRET32_V86: return 4*9;
1254 case DBGFRETURNTYPE_IRET64:
1255 default:
1256 return 0;
1257 }
1258}
1259
1260
1261/** Pointer to stack frame info. */
1262typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
1263/**
1264 * Info about a stack frame.
1265 */
1266typedef struct DBGFSTACKFRAME
1267{
1268 /** Frame number. */
1269 RTUINT iFrame;
1270 /** Frame flags. */
1271 RTUINT fFlags;
1272 /** The frame address.
1273 * The off member is [e|r]bp and the Sel member is ss. */
1274 DBGFADDRESS AddrFrame;
1275 /** The stack address of the frame.
1276 * The off member is [e|r]sp and the Sel member is ss. */
1277 DBGFADDRESS AddrStack;
1278 /** The program counter (PC) address of the frame.
1279 * The off member is [e|r]ip and the Sel member is cs. */
1280 DBGFADDRESS AddrPC;
1281 /** Pointer to the symbol nearest the program counter (PC). NULL if not found. */
1282 PDBGFSYMBOL pSymPC;
1283 /** Pointer to the linnumber nearest the program counter (PC). NULL if not found. */
1284 PDBGFLINE pLinePC;
1285
1286 /** The return frame address.
1287 * The off member is [e|r]bp and the Sel member is ss. */
1288 DBGFADDRESS AddrReturnFrame;
1289 /** The return stack address.
1290 * The off member is [e|r]sp and the Sel member is ss. */
1291 DBGFADDRESS AddrReturnStack;
1292 /** The way this frame returns to the next one. */
1293 DBGFRETURNTYPE enmReturnType;
1294
1295 /** The program counter (PC) address which the frame returns to.
1296 * The off member is [e|r]ip and the Sel member is cs. */
1297 DBGFADDRESS AddrReturnPC;
1298 /** Pointer to the symbol nearest the return PC. NULL if not found. */
1299 PDBGFSYMBOL pSymReturnPC;
1300 /** Pointer to the linnumber nearest the return PC. NULL if not found. */
1301 PDBGFLINE pLineReturnPC;
1302
1303 /** 32-bytes of stack arguments. */
1304 union
1305 {
1306 /** 64-bit view */
1307 uint64_t au64[4];
1308 /** 32-bit view */
1309 uint32_t au32[8];
1310 /** 16-bit view */
1311 uint16_t au16[16];
1312 /** 8-bit view */
1313 uint8_t au8[32];
1314 } Args;
1315
1316 /** Pointer to the next frame.
1317 * Might not be used in some cases, so consider it internal. */
1318 PDBGFSTACKFRAME pNext;
1319 /** Pointer to the first frame.
1320 * Might not be used in some cases, so consider it internal. */
1321 PDBGFSTACKFRAME pFirst;
1322} DBGFSTACKFRAME;
1323
1324/** @name DBGFSTACKFRAME Flags.
1325 * @{ */
1326/** Set if the content of the frame is filled in by DBGFR3StackWalk() and can be used
1327 * to construct the next frame. */
1328#define DBGFSTACKFRAME_FLAGS_ALL_VALID BIT(0)
1329/** This is the last stack frame we can read.
1330 * This flag is not set if the walk stop because of max dept or recursion. */
1331#define DBGFSTACKFRAME_FLAGS_LAST BIT(1)
1332/** This is the last record because we detected a loop. */
1333#define DBGFSTACKFRAME_FLAGS_LOOP BIT(2)
1334/** This is the last record because we reached the maximum depth. */
1335#define DBGFSTACKFRAME_FLAGS_MAX_DEPTH BIT(3)
1336/** @} */
1337
1338/**
1339 * Begins a stack walk.
1340 * This will construct and obtain the first frame.
1341 *
1342 * @returns VINF_SUCCESS on success.
1343 * @returns VERR_NO_MEMORY if we're out of memory.
1344 * @param pVM The VM handle.
1345 * @param pFrame The stack frame info structure.
1346 * On input this structure must be memset to zero.
1347 * If wanted, the AddrPC, AddrStack and AddrFrame fields may be set
1348 * to valid addresses after memsetting it. Any of those fields not set
1349 * will be fetched from the guest CPU state.
1350 * On output the structure will contain all the information we were able to
1351 * obtain about the stack frame.
1352 */
1353DBGFR3DECL(int) DBGFR3StackWalkBeginGuest(PVM pVM, PDBGFSTACKFRAME pFrame);
1354
1355/**
1356 * Begins a stack walk.
1357 * This will construct and obtain the first frame.
1358 *
1359 * @returns VINF_SUCCESS on success.
1360 * @returns VERR_NO_MEMORY if we're out of memory.
1361 * @param pVM The VM handle.
1362 * @param pFrame The stack frame info structure.
1363 * On input this structure must be memset to zero.
1364 * If wanted, the AddrPC, AddrStack and AddrFrame fields may be set
1365 * to valid addresses after memsetting it. Any of those fields not set
1366 * will be fetched from the hypervisor CPU state.
1367 * On output the structure will contain all the information we were able to
1368 * obtain about the stack frame.
1369 */
1370DBGFR3DECL(int) DBGFR3StackWalkBeginHyper(PVM pVM, PDBGFSTACKFRAME pFrame);
1371
1372/**
1373 * Gets the next stack frame.
1374 *
1375 * @returns VINF_SUCCESS
1376 * @returns VERR_NO_MORE_FILES if not more stack frames.
1377 * @param pVM The VM handle.
1378 * @param pFrame Pointer to the current frame on input, content is replaced with the next frame on successful return.
1379 */
1380DBGFR3DECL(int) DBGFR3StackWalkNext(PVM pVM, PDBGFSTACKFRAME pFrame);
1381
1382/**
1383 * Ends a stack walk process.
1384 *
1385 * This *must* be called after a successful first call to any of the stack
1386 * walker functions. If not called we will leak memory or other resources.
1387 *
1388 * @param pVM The VM handle.
1389 * @param pFrame The stackframe as returned by the last stack walk call.
1390 */
1391DBGFR3DECL(void) DBGFR3StackWalkEnd(PVM pVM, PDBGFSTACKFRAME pFrame);
1392
1393
1394
1395
1396/** Flags to pass to DBGFR3DisasInstrEx().
1397 * @{ */
1398/** Disassemble the current guest instruction, with annotations. */
1399#define DBGF_DISAS_FLAGS_CURRENT_GUEST BIT(0)
1400/** Disassemble the current hypervisor instruction, with annotations. */
1401#define DBGF_DISAS_FLAGS_CURRENT_HYPER BIT(1)
1402/** No annotations for current context. */
1403#define DBGF_DISAS_FLAGS_NO_ANNOTATION BIT(2)
1404/** No symbol lookup. */
1405#define DBGF_DISAS_FLAGS_NO_SYMBOLS BIT(3)
1406/** No instruction bytes. */
1407#define DBGF_DISAS_FLAGS_NO_BYTES BIT(4)
1408/** No address in the output. */
1409#define DBGF_DISAS_FLAGS_NO_ADDRESS BIT(5)
1410/** @} */
1411
1412/** Special flat selector. */
1413#define DBGF_SEL_FLAT 1
1414
1415/**
1416 * Disassembles the one instruction according to the specified flags and address.
1417 *
1418 * @returns VBox status code.
1419 * @param pVM VM handle.
1420 * @param Sel The code selector. This used to determin the 32/16 bit ness and
1421 * calculation of the actual instruction address.
1422 * Use DBGF_SEL_FLAT for specifying a flat address.
1423 * @param GCPtr The code address relative to the base of Sel.
1424 * @param fFlags Flags controlling where to start and how to format.
1425 * A combination of the DBGF_DISAS_FLAGS_* #defines.
1426 * @param pszOutput Output buffer.
1427 * @param cchOutput Size of the output buffer.
1428 * @param pcbInstr Where to return the size of the instruction.
1429 */
1430DBGFR3DECL(int) DBGFR3DisasInstrEx(PVM pVM, RTSEL Sel, RTGCPTR GCPtr, unsigned fFlags, char *pszOutput, uint32_t cchOutput, uint32_t *pcbInstr);
1431
1432/**
1433 * Disassembles the current instruction.
1434 * Addresses will be tried resolved to symbols
1435 *
1436 * @returns VBox status code.
1437 * @param pVM VM handle.
1438 * @param Sel The code selector. This used to determin the 32/16 bit ness and
1439 * calculation of the actual instruction address.
1440 * Use DBGF_SEL_FLAT for specifying a flat address.
1441 * @param GCPtr The code address relative to the base of Sel.
1442 * @param pszOutput Output buffer.
1443 * @param cbOutput Size of the output buffer.
1444 */
1445DBGFR3DECL(int) DBGFR3DisasInstr(PVM pVM, RTSEL Sel, RTGCPTR GCPtr, char *pszOutput, uint32_t cbOutput);
1446
1447/**
1448 * Disassembles the current instruction.
1449 * All registers and data will be displayed. Addresses will be attempted resolved to symbols
1450 *
1451 * @returns VBox status code.
1452 * @param pVM VM handle.
1453 * @param pszOutput Output buffer.
1454 * @param cbOutput Size of the output buffer.
1455 */
1456DBGFR3DECL(int) DBGFR3DisasInstrCurrent(PVM pVM, char *pszOutput, uint32_t cbOutput);
1457
1458/**
1459 * Disassembles the current guest context instruction and writes it to the log.
1460 * All registers and data will be displayed. Addresses will be attempted resolved to symbols.
1461 *
1462 * @returns VBox status code.
1463 * @param pVM VM handle.
1464 * @param pszPrefix Short prefix string to the dissassembly string. (optional)
1465 */
1466DBGFR3DECL(int) DBGFR3DisasInstrCurrentLogInternal(PVM pVM, const char *pszPrefix);
1467
1468/** @def DBGFR3DisasInstrCurrentLog
1469 * Disassembles the current guest context instruction and writes it to the log.
1470 * All registers and data will be displayed. Addresses will be attempted resolved to symbols.
1471 */
1472#ifdef LOG_ENABLED
1473# define DBGFR3DisasInstrCurrentLog(pVM, pszPrefix) \
1474 do { \
1475 if (LogIsEnabled()) \
1476 DBGFR3DisasInstrCurrentLogInternal(pVM, pszPrefix); \
1477 } while (0)
1478#else
1479# define DBGFR3DisasInstrCurrentLog(pVM, pszPrefix) do { } while (0)
1480#endif
1481
1482/**
1483 * Disassembles the specified guest context instruction and writes it to the log.
1484 * Addresses will be attempted resolved to symbols.
1485 *
1486 * @returns VBox status code.
1487 * @param pVM VM handle.
1488 * @param Sel The code selector. This used to determin the 32/16 bit-ness and
1489 * calculation of the actual instruction address.
1490 * @param GCPtr The code address relative to the base of Sel.
1491 */
1492DBGFR3DECL(int) DBGFR3DisasInstrLogInternal(PVM pVM, RTSEL Sel, RTGCPTR GCPtr);
1493
1494/** @def DBGFR3DisasInstrLog
1495 * Disassembles the specified guest context instruction and writes it to the log.
1496 * Addresses will be attempted resolved to symbols.
1497 */
1498#ifdef LOG_ENABLED
1499# define DBGFR3DisasInstrLog(pVM, Sel, GCPtr) \
1500 do { \
1501 if (LogIsEnabled()) \
1502 DBGFR3DisasInstrLogInternal(pVM, Sel, GCPtr); \
1503 } while (0)
1504#else
1505# define DBGFR3DisasInstrLog(pVM, Sel, GCPtr) do { } while (0)
1506#endif
1507
1508/** @} */
1509
1510__END_DECLS
1511
1512#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