LLDB mainline
Classes | Static Public Member Functions | Static Protected Member Functions | List of all members
lldb_private::WatchpointAlgorithms Class Reference

#include <WatchpointAlgorithms.h>

Classes

struct  Region
 

Static Public Member Functions

static std::vector< lldb::WatchpointResourceSPAtomizeWatchpointRequest (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 hardware watchpoint register.
 

Static Protected Member Functions

static std::vector< RegionPowerOf2Watchpoints (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 single hardware watchpoint that can watch power-of-2 size & aligned memory regions.
 

Detailed Description

Definition at line 20 of file WatchpointAlgorithms.h.

Member Function Documentation

◆ AtomizeWatchpointRequest()

std::vector< WatchpointResourceSP > WatchpointAlgorithms::AtomizeWatchpointRequest ( lldb::addr_t  addr,
size_t  size,
bool  read,
bool  write,
WatchpointHardwareFeature  supported_features,
ArchSpec arch 
)
static

Convert a user's watchpoint request into an array of memory regions, each region watched by one hardware watchpoint register.

Parameters
[in]addrThe start address specified by the user.
[in]sizeThe number of bytes the user wants to watch.
[in]readTrue if we are watching for read accesses.
[in]writeTrue if we are watching for write accesses. read and write may both be true. There is no "modify" style for WatchpointResources - WatchpointResources are akin to the hardware watchpoint registers which are either in terms of read or write. "modify" distinction is done at the Watchpoint layer, where we check the actual range of bytes the user requested.
[in]supported_featuresThe bit flags in this parameter are set depending on which WatchpointHardwareFeature enum values the current target supports. The eWatchpointHardwareFeatureUnknown bit may be set if we don't have specific information about what the remote stub can support, and a reasonablec default will be used.
[in]archThe ArchSpec of the current Target.
Returns
A vector of WatchpointResourceSP's, one per hardware watchpoint register needed. We may return more WatchpointResources than the target can watch at once; if all resources cannot be set, the watchpoint cannot be set.

Definition at line 24 of file WatchpointAlgorithms.cpp.

References lldb_private::ArchSpec::GetAddressByteSize(), lldb_private::GetLog(), INT32_MAX, LLDB_LOGV, PowerOf2Watchpoints(), and lldb_private::Watchpoints.

Referenced by lldb_private::process_gdb_remote::ProcessGDBRemote::EnableWatchpoint().

◆ PowerOf2Watchpoints()

std::vector< WatchpointAlgorithms::Region > WatchpointAlgorithms::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 
)
staticprotected

Convert a user's watchpoint request into an array of Regions, each of which can be watched by a single hardware watchpoint that can watch power-of-2 size & aligned memory regions.

Convert a user's watchpoint request (user_addr and user_size) into hardware watchpoints, for a target that can watch a power-of-2 region of memory (1, 2, 4, 8, etc), aligned to that same power-of-2 memory address.

This is the default algorithm if we have no further information; most watchpoint implementations can be assumed to be able to watch up to sizeof(void*) regions of memory, in power-of-2 sizes and alignments. e.g. on a 64-bit target: 1, 2, 4, 8 or bytes with a single hardware watchpoint register.

Parameters
[in]user_addrThe user's start address.
[in]user_sizeThe user's specified byte length.
[in]min_byte_sizeThe minimum byte size of the range of memory that can be watched with one watchpoint register. In most cases, this will be 1. AArch64 MASK watchpoints can watch a minimum of 8 bytes (although Byte Address Select watchpoints can watch 1 to pointer-size bytes in a pointer-size aligned granule).
[in]max_byte_sizeThe maximum byte size supported for one watchpoint on this target.
[in]address_byte_sizeThe address byte size on this target.

If a user asks to watch 4 bytes at address 0x1002 (0x1002-0x1005 inclusive) we can implement this with two 2-byte watchpoints (0x1002 and 0x1004) or with an 8-byte watchpoint at 0x1000. A 4-byte watchpoint at 0x1002 would not be properly 4 byte aligned.

If a user asks to watch 16 bytes at 0x1000, and this target supports 8-byte watchpoints, we can implement this with two 8-byte watchpoints at 0x1000 and 0x1008.

Round up user_size to the next power-of-2 size user_size == 8 -> aligned_size == 8 user_size == 9 -> aligned_size == 16

Definition at line 85 of file WatchpointAlgorithms.cpp.

References bit_ceil(), lldb_private::GetLog(), LLDB_LOGV, and lldb_private::Watchpoints.

Referenced by AtomizeWatchpointRequest().


The documentation for this class was generated from the following files: