LLDB mainline
WatchpointAlgorithms.h
Go to the documentation of this file.
1//===-- WatchpointAlgorithms.h ----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H
10#define LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H
11
14#include "lldb/lldb-private.h"
15
16#include <vector>
17
18namespace lldb_private {
19
21
22public:
23 /// Convert a user's watchpoint request into an array of memory
24 /// regions, each region watched by one hardware watchpoint register.
25 ///
26 /// \param[in] addr
27 /// The start address specified by the user.
28 ///
29 /// \param[in] size
30 /// The number of bytes the user wants to watch.
31 ///
32 /// \param[in] read
33 /// True if we are watching for read accesses.
34 ///
35 /// \param[in] write
36 /// True if we are watching for write accesses.
37 /// \a read and \a write may both be true.
38 /// There is no "modify" style for WatchpointResources -
39 /// WatchpointResources are akin to the hardware watchpoint
40 /// registers which are either in terms of read or write.
41 /// "modify" distinction is done at the Watchpoint layer, where
42 /// we check the actual range of bytes the user requested.
43 ///
44 /// \param[in] supported_features
45 /// The bit flags in this parameter are set depending on which
46 /// WatchpointHardwareFeature enum values the current target supports.
47 /// The eWatchpointHardwareFeatureUnknown bit may be set if we
48 /// don't have specific information about what the remote stub
49 /// can support, and a reasonablec default will be used.
50 ///
51 /// \param[in] arch
52 /// The ArchSpec of the current Target.
53 ///
54 /// \return
55 /// A vector of WatchpointResourceSP's, one per hardware watchpoint
56 /// register needed. We may return more WatchpointResources than the
57 /// target can watch at once; if all resources cannot be set, the
58 /// watchpoint cannot be set.
59 static std::vector<lldb::WatchpointResourceSP> AtomizeWatchpointRequest(
60 lldb::addr_t addr, size_t size, bool read, bool write,
61 WatchpointHardwareFeature supported_features, ArchSpec &arch);
62
63protected:
64 struct Region {
66 size_t size;
67 };
68
69 /// Convert a user's watchpoint request into an array of Regions,
70 /// each of which can be watched by a single hardware watchpoint
71 /// that can watch power-of-2 size & aligned memory regions.
72 ///
73 /// This is the default algorithm if we have no further information;
74 /// most watchpoint implementations can be assumed to be able to watch up
75 /// to sizeof(void*) regions of memory, in power-of-2 sizes and alignments.
76 /// e.g. on a 64-bit target: 1, 2, 4, 8 or bytes with a single hardware
77 /// watchpoint register.
78 ///
79 /// \param[in] user_addr
80 /// The user's start address.
81 ///
82 /// \param[in] user_size
83 /// The user's specified byte length.
84 ///
85 /// \param[in] min_byte_size
86 /// The minimum byte size of the range of memory that can be watched
87 /// with one watchpoint register.
88 /// In most cases, this will be 1. AArch64 MASK watchpoints can
89 /// watch a minimum of 8 bytes (although Byte Address Select watchpoints
90 /// can watch 1 to pointer-size bytes in a pointer-size aligned granule).
91 ///
92 /// \param[in] max_byte_size
93 /// The maximum byte size supported for one watchpoint on this target.
94 ///
95 /// \param[in] address_byte_size
96 /// The address byte size on this target.
97 static std::vector<Region> PowerOf2Watchpoints(lldb::addr_t user_addr,
98 size_t user_size,
99 size_t min_byte_size,
100 size_t max_byte_size,
101 uint32_t address_byte_size);
102};
103
104} // namespace lldb_private
105
106#endif // LLDB_BREAKPOINT_WATCHPOINTALGORITHMS_H
An architecture specification class.
Definition: ArchSpec.h:31
static std::vector< Region > PowerOf2Watchpoints(lldb::addr_t user_addr, size_t user_size, size_t min_byte_size, size_t max_byte_size, uint32_t address_byte_size)
Convert a user's watchpoint request into an array of Regions, each of which can be watched by a singl...
static std::vector< lldb::WatchpointResourceSP > AtomizeWatchpointRequest(lldb::addr_t addr, size_t size, bool read, bool write, WatchpointHardwareFeature supported_features, ArchSpec &arch)
Convert a user's watchpoint request into an array of memory regions, each region watched by one hardw...
A class that represents a running process on the host machine.
uint64_t addr_t
Definition: lldb-types.h:80