-
Notifications
You must be signed in to change notification settings - Fork 13
/
hardwarebp.h
36 lines (25 loc) · 896 Bytes
/
hardwarebp.h
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
// Copyright (c) 2000 Mike Morearty <mike@morearty.com>
// Original source and docs: http://www.morearty.com/code/breakpoint
#ifndef _HARDWAREBP_H_
#define _HARDWAREBP_H_
#ifdef _DEBUG
class HardwareBreakpoint
{
public:
HardwareBreakpoint() { m_index = -1; }
~HardwareBreakpoint() { Clear(); }
// The enum values correspond to the values used by the Intel Pentium,
// so don't change them!
enum Condition { Write = 1, Read /* or write! */ = 3 };
void Set(void* address, int len /* 1, 2, or 4 */, Condition when);
void Clear();
protected:
inline void SetBits(unsigned long& dw, int lowBit, int bits, int newValue)
{
int mask = (1 << bits) - 1; // e.g. 1 becomes 0001, 2 becomes 0011, 3 becomes 0111
dw = (dw & ~(mask << lowBit)) | (newValue << lowBit);
}
int m_index; // -1 means not set; 0-3 means we've set that hardware bp
};
#endif // _DEBUG
#endif // _HARDWAREBP_H_