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

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 13 20:45:59 PDT 2023


================
@@ -211,6 +212,35 @@ bool Watchpoint::CaptureWatchedValue(const ExecutionContext &exe_ctx) {
   return (m_new_value_sp && m_new_value_sp->GetError().Success());
 }
 
+bool Watchpoint::WatchedValueReportable(const ExecutionContext &exe_ctx) {
+  if (!m_watch_modify)
+    return true;
+  if (!m_type.IsValid())
+    return true;
+
+  ConstString watch_name("$__lldb__watch_value");
+  Address watch_address(GetLoadAddress());
+  ValueObjectSP newest_valueobj_sp = ValueObjectMemory::Create(
+      exe_ctx.GetBestExecutionContextScope(), watch_name.GetStringRef(),
+      watch_address, m_type);
+  newest_valueobj_sp = newest_valueobj_sp->CreateConstantValue(watch_name);
+  DataExtractor new_data;
+  DataExtractor old_data;
+  Status error;
+  newest_valueobj_sp->GetData(new_data, error);
+  m_new_value_sp->GetData(old_data, error);
+
----------------
jasonmolenda wrote:

Should add, because I'm sure someone will wonder about this:  Yes, I'm creating a constant ValueObject with the watched memory here, and then throwing that ValueObject away.  And if we decide to stop, we'll create the constant ValueObject again with the same memory, to show it to the user.  I'm relying on the memory read cache to only read that memory from the inferior process once at a single stop, otherwise this double-creation of a ValueObject would be a real perf hit to watchpoints.

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


More information about the lldb-commits mailing list