DebugServer2
Loading...
Searching...
No Matches
HardwareBreakpointManager.h
1//
2// Copyright (c) 2014-present, Facebook, Inc.
3// All rights reserved.
4//
5// This source code is licensed under the University of Illinois/NCSA Open
6// Source License found in the LICENSE file in the root directory of this
7// source tree. An additional grant of patent rights can be found in the
8// PATENTS file in the same directory.
9//
10
11#pragma once
12
13#include "DebugServer2/Core/BreakpointManager.h"
14
15#include <unordered_map>
16#include <unordered_set>
17
18namespace ds2 {
19
21public:
24
25public:
26 ErrorCode add(Address const &address, Lifetime lifetime, size_t size,
27 Mode mode) override;
28 ErrorCode remove(Address const &address) override;
29
30public:
31 int hit(Target::Thread *thread, Site &site) override;
32
33protected:
34 ErrorCode enableLocation(Site const &site,
35 Target::Thread *thread = nullptr) override;
36 virtual ErrorCode enableLocation(Site const &site, int idx,
37 Target::Thread *thread);
38 ErrorCode disableLocation(Site const &site,
39 Target::Thread *thread = nullptr) override;
40 virtual ErrorCode disableLocation(int idx, Target::Thread *thread);
41
42protected:
43 bool enabled(Target::Thread *thread = nullptr) const override;
44
45public:
46 virtual size_t maxWatchpoints();
47
48public:
49 void enable(Target::Thread *thread = nullptr) override;
50 void disable(Target::Thread *thread = nullptr) override;
51
52protected:
53 ErrorCode isValid(Address const &address, size_t size,
54 Mode mode) const override;
55 size_t chooseBreakpointSize(Address const &address) const override;
56
57protected:
58 virtual int getAvailableLocation();
59
60protected:
61 virtual void
62 enumerateThreads(Target::Thread *thread,
63 std::function<void(Target::Thread *t)> const &cb) const;
64
65protected:
66 ErrorCode readDebugRegisters(Target::Thread *thread,
67 std::vector<uint64_t> &regs) const;
68 ErrorCode writeDebugRegisters(Target::Thread *thread,
69 std::vector<uint64_t> &regs) const;
70
71protected:
72 std::vector<uint64_t> _locations;
73 std::unordered_set<ThreadId> _enabled;
74
75#if defined(ARCH_X86) || defined(ARCH_X86_64)
76protected:
77 virtual ErrorCode disableDebugCtrlReg(uint64_t &ctrlReg, int idx);
78 virtual ErrorCode enableDebugCtrlReg(uint64_t &ctrlReg, int idx, Mode mode,
79 int size);
80#endif
81
82#if defined(ARCH_ARM64) && defined(OS_WIN32)
83protected:
84 // Last known contents of each enabled watchpoint's memory range, keyed by
85 // slot index. Windows ARM64 has no hardware signal for "which (if any)
86 // watchpoint actually trapped" (see
87 // Sources/Core/Windows/ARM64/HardwareBreakpointManager.cpp), so hit()
88 // compares against this to tell whether a stop that could be either a
89 // watchpoint or an unrelated explicit step actually touched a watched
90 // byte.
91 std::unordered_map<int, ByteVector> _lastKnownValues;
92#endif
93
94public:
95 virtual bool fillStopInfo(Target::Thread *thread,
96 StopInfo &stopInfo) override;
97};
98} // namespace ds2
Definition Types.h:96
Definition BreakpointManager.h:20
Definition HardwareBreakpointManager.h:20
Definition ProcessBase.h:25
Definition BreakpointManager.h:36
Definition Types.h:132