1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/* $Id: DBGFAll.cpp $ */
/** @file
* DBGF - Debugger Facility, All Context Code.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DBGF
#include <VBox/dbgf.h>
#include "DBGFInternal.h"
#include <VBox/vm.h>
#include <iprt/assert.h>
/**
* Gets the hardware breakpoint configuration as DR7.
*
* @returns DR7 from the DBGF point of view.
* @param pVM The VM handle.
*/
VMMDECL(RTGCUINTREG) DBGFBpGetDR7(PVM pVM)
{
RTGCUINTREG uDr7 = X86_DR7_GD | X86_DR7_GE | X86_DR7_LE | X86_DR7_MB1_MASK;
PDBGFBP pBp = &pVM->dbgf.s.aHwBreakpoints[0];
unsigned cLeft = RT_ELEMENTS(pVM->dbgf.s.aHwBreakpoints);
while (cLeft-- > 0)
{
if ( pBp->enmType == DBGFBPTYPE_REG
&& pBp->fEnabled)
{
static const uint8_t s_au8Sizes[8] =
{
X86_DR7_LEN_BYTE, X86_DR7_LEN_BYTE, X86_DR7_LEN_WORD, X86_DR7_LEN_BYTE,
X86_DR7_LEN_DWORD,X86_DR7_LEN_BYTE, X86_DR7_LEN_BYTE, X86_DR7_LEN_QWORD
};
uDr7 |= X86_DR7_G(pBp->u.Reg.iReg)
| X86_DR7_RW(pBp->u.Reg.iReg, pBp->u.Reg.fType)
| X86_DR7_LEN(pBp->u.Reg.iReg, s_au8Sizes[pBp->u.Reg.cb]);
}
pBp++;
}
return uDr7;
}
/**
* Gets the address of the hardware breakpoint number 0.
*
* @returns DR0 from the DBGF point of view.
* @param pVM The VM handle.
*/
VMMDECL(RTGCUINTREG) DBGFBpGetDR0(PVM pVM)
{
PCDBGFBP pBp = &pVM->dbgf.s.aHwBreakpoints[0];
Assert(pBp->u.Reg.iReg == 0);
return pBp->GCPtr;
}
/**
* Gets the address of the hardware breakpoint number 1.
*
* @returns DR1 from the DBGF point of view.
* @param pVM The VM handle.
*/
VMMDECL(RTGCUINTREG) DBGFBpGetDR1(PVM pVM)
{
PCDBGFBP pBp = &pVM->dbgf.s.aHwBreakpoints[1];
Assert(pBp->u.Reg.iReg == 1);
return pBp->GCPtr;
}
/**
* Gets the address of the hardware breakpoint number 2.
*
* @returns DR2 from the DBGF point of view.
* @param pVM The VM handle.
*/
VMMDECL(RTGCUINTREG) DBGFBpGetDR2(PVM pVM)
{
PCDBGFBP pBp = &pVM->dbgf.s.aHwBreakpoints[2];
Assert(pBp->u.Reg.iReg == 2);
return pBp->GCPtr;
}
/**
* Gets the address of the hardware breakpoint number 3.
*
* @returns DR3 from the DBGF point of view.
* @param pVM The VM handle.
*/
VMMDECL(RTGCUINTREG) DBGFBpGetDR3(PVM pVM)
{
PCDBGFBP pBp = &pVM->dbgf.s.aHwBreakpoints[3];
Assert(pBp->u.Reg.iReg == 3);
return pBp->GCPtr;
}
/**
* Returns single stepping state
*
* @returns stepping or not
* @param pVM The VM handle.
*/
VMMDECL(bool) DBGFIsStepping(PVM pVM)
{
return pVM->dbgf.s.fSingleSteppingRaw;
}
|