This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
HardwareBreakpointManager.h
86 lines (69 loc) · 2.52 KB
/
HardwareBreakpointManager.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
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
//
// Copyright (c) 2014-present, Facebook, Inc.
// All rights reserved.
//
// This source code is licensed under the University of Illinois/NCSA Open
// Source License found in the LICENSE file in the root directory of this
// source tree. An additional grant of patent rights can be found in the
// PATENTS file in the same directory.
//
#pragma once
#include "DebugServer2/Core/BreakpointManager.h"
#include <unordered_set>
namespace ds2 {
class HardwareBreakpointManager : public BreakpointManager {
public:
HardwareBreakpointManager(Target::ProcessBase *process);
~HardwareBreakpointManager() override;
public:
ErrorCode add(Address const &address, Type type, size_t size,
Mode mode) override;
ErrorCode remove(Address const &address) override;
public:
int hit(Target::Thread *thread, Site &site) override;
protected:
ErrorCode enableLocation(Site const &site,
Target::Thread *thread = nullptr) override;
virtual ErrorCode enableLocation(Site const &site, int idx,
Target::Thread *thread);
ErrorCode disableLocation(Site const &site,
Target::Thread *thread = nullptr) override;
virtual ErrorCode disableLocation(int idx, Target::Thread *thread);
protected:
bool enabled(Target::Thread *thread = nullptr) const override;
public:
virtual size_t maxWatchpoints();
public:
void enable(Target::Thread *thread = nullptr) override;
void disable(Target::Thread *thread = nullptr) override;
protected:
ErrorCode isValid(Address const &address, size_t size,
Mode mode) const override;
protected:
virtual int getAvailableLocation();
protected:
virtual void
enumerateThreads(Target::Thread *thread,
std::function<void(Target::Thread *t)> const &cb) const;
protected:
ErrorCode readDebugRegisters(Target::Thread *thread,
std::vector<uint64_t> ®s) const;
ErrorCode writeDebugRegisters(Target::Thread *thread,
std::vector<uint64_t> ®s) const;
protected:
struct Location {
Location()
:address(0) value(0){}
uint64_t address;
uint64_t value;
};
std::vector<Location> _locations;
std::unordered_set<ThreadId> _enabled;
#if defined(ARCH_X86) || defined(ARCH_X86_64)
protected:
virtual ErrorCode disableDebugCtrlReg(uint64_t &ctrlReg, int idx);
virtual ErrorCode enableDebugCtrlReg(uint64_t &ctrlReg, int idx, Mode mode,
int size);
#endif
};
} // namespace ds2