[Lldb-commits] [lldb] [lldb] Add 'modify' type watchpoints, make it default (PR #66308)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 15 21:44:23 PDT 2023


================
@@ -0,0 +1,44 @@
+//===-- SBWatchpointOptions.h -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBWATCHPOINTOPTIONS_H
+#define LLDB_API_SBWATCHPOINTOPTIONS_H
+
+#include "lldb/API/SBDefines.h"
+
+class WatchpointOptionsImpl;
+
+namespace lldb {
+
+class LLDB_API SBWatchpointOptions {
+public:
+  SBWatchpointOptions();
+
+  SBWatchpointOptions(const lldb::SBWatchpointOptions &rhs);
+
+  ~SBWatchpointOptions();
+
+  const SBWatchpointOptions &operator=(const lldb::SBWatchpointOptions &rhs);
+
+  void SetWatchpointTypeRead(bool read);
+  bool GetWatchpointTypeRead() const;
+
+  void SetWatchpointTypeWrite(bool write);
+  bool GetWatchpointTypeWrite() const;
+
+  void SetWatchpointTypeModify(bool modify);
+  bool GetWatchpointTypeModify() const;
----------------
clayborg wrote:

Since we are changing the API, would it be more clear to just have an enum and accessor to make it clear when we still stop will happen during writes? We can keep the SetWatchpointTypeRead(bool), but for the write maybe something like:
```
// Put this into lldb-enumerations.h
namespace lldb { 
enum class WatchpointWriteType {
  Disabled, // Don't stop when the data being watched is written to
  Always, // Stop on any write access to the the value being watched even if value doesn't change
  OnModify // Stop only on write access that modifies the value being watched
};
} // namespace lldb
```
The we have just one accessor for the write control like:
```
lldb::WatchpointWriteType GetWatchpointWriteType();
void SetWathpointWriteType(lldb::WatchpointWriteType watch_type);
```
The current API in this class might be confusing to the user as to what needs to be set:
- If I want to stop when the value is modfied, do I just set "modify" or also need to set "write"?
- Can I set "read" and "modify"? (we said no on this, but it might still be confusing to users as they might think they can)
- what does setting "read", "write" and "modify" do?


https://github.com/llvm/llvm-project/pull/66308


More information about the lldb-commits mailing list