Skip to content

Commit 7dd790d

Browse files
committed
[lldb] NFC fixes addressing David's feedback
David Spickett had several suggestions for #79962 after I'd already merged it. Address those.
1 parent e270ec4 commit 7dd790d

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

lldb/include/lldb/Breakpoint/WatchpointAlgorithms.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class WatchpointAlgorithms {
2121

2222
public:
2323
/// Convert a user's watchpoint request into an array of memory
24-
/// regions that can be watched by one hardware watchpoint register
25-
/// on the current target.
24+
/// regions, each region watched by one hardware watchpoint register.
2625
///
2726
/// \param[in] addr
2827
/// The start address specified by the user.
@@ -61,18 +60,21 @@ class WatchpointAlgorithms {
6160
lldb::addr_t addr, size_t size, bool read, bool write,
6261
lldb::WatchpointHardwareFeature supported_features, ArchSpec &arch);
6362

63+
protected:
6464
struct Region {
6565
lldb::addr_t addr;
6666
size_t size;
6767
};
6868

69-
protected:
70-
/// Convert a user's watchpoint request into an array of addr+size that
71-
/// can be watched with power-of-2 style hardware watchpoints.
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.
7272
///
7373
/// This is the default algorithm if we have no further information;
7474
/// most watchpoint implementations can be assumed to be able to watch up
75-
/// to pointer-size regions of memory in power-of-2 sizes and alingments.
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.
7678
///
7779
/// \param[in] user_addr
7880
/// The user's start address.
@@ -81,7 +83,8 @@ class WatchpointAlgorithms {
8183
/// The user's specified byte length.
8284
///
8385
/// \param[in] min_byte_size
84-
/// The minimum byte size supported on this target.
86+
/// The minimum byte size of the range of memory that can be watched
87+
/// with one watchpoint register.
8588
/// In most cases, this will be 1. AArch64 MASK watchpoints can
8689
/// watch a minimum of 8 bytes (although Byte Address Select watchpoints
8790
/// can watch 1 to pointer-size bytes in a pointer-size aligned granule).

lldb/source/Breakpoint/WatchpointResource.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ bool WatchpointResource::ShouldStop(StoppointCallbackContext *context) {
115115

116116
void WatchpointResource::Dump(Stream *s) const {
117117
s->Printf("addr = 0x%8.8" PRIx64 " size = %zu", m_addr, m_size);
118-
return;
119118
}
120119

121120
wp_resource_id_t WatchpointResource::GetNextID() {

lldb/test/API/functionalities/watchpoint/unaligned-large-watchpoint/TestUnalignedLargeWatchpoint.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_unaligned_large_watchpoint(self):
3535
"""Test watching an unaligned region of memory that requires multiple watchpoints."""
3636
self.build()
3737
self.main_source_file = lldb.SBFileSpec("main.c")
38-
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
38+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
3939
self, "break here", self.main_source_file
4040
)
4141
self.runCmd("break set -p done")
@@ -79,7 +79,6 @@ def test_unaligned_large_watchpoint(self):
7979

8080
# Now try watching a 16 byte variable
8181
# (not unaligned, but a good check to do anyway)
82-
#
8382
frame = thread.GetFrameAtIndex(0)
8483
err = lldb.SBError()
8584
wp = frame.locals["variable"][0].Watch(True, False, True, err)

lldb/unittests/Breakpoint/WatchpointAlgorithmsTests.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@
1616
using namespace lldb;
1717
using namespace lldb_private;
1818

19-
struct testcase {
20-
WatchpointAlgorithms::Region user; // What the user requested
21-
std::vector<WatchpointAlgorithms::Region>
22-
hw; // The hardware watchpoints we'll use
23-
};
24-
2519
class WatchpointAlgorithmsTest : public WatchpointAlgorithms {
2620
public:
2721
using WatchpointAlgorithms::PowerOf2Watchpoints;
22+
using WatchpointAlgorithms::Region;
23+
};
24+
25+
struct testcase {
26+
WatchpointAlgorithmsTest::Region user; // What the user requested
27+
std::vector<WatchpointAlgorithmsTest::Region>
28+
hw; // The hardware watchpoints we'll use
2829
};
2930

3031
void check_testcase(testcase test,
31-
std::vector<WatchpointAlgorithms::Region> result,
32+
std::vector<WatchpointAlgorithmsTest::Region> result,
3233
size_t min_byte_size, size_t max_byte_size,
3334
uint32_t address_byte_size) {
3435

0 commit comments

Comments
 (0)