We were getting an assert because somebody was making a watchpoint that was
neither read nor write. Tighten up the checking so this isn't possible.
<rdar://problem/14111167>
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184245 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 4e4290c..75c555d 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -564,6 +564,7 @@
error.SetErrorString("process is not alive");
return wp_sp;
}
+
if (addr == LLDB_INVALID_ADDRESS || size == 0)
{
if (size == 0)
@@ -572,6 +573,11 @@
error.SetErrorStringWithFormat("invalid watch address: %" PRIu64, addr);
return wp_sp;
}
+
+ if (!LLDB_WATCH_TYPE_IS_VALID(kind))
+ {
+ error.SetErrorStringWithFormat ("invalid watchpoint type: %d", kind);
+ }
// Currently we only support one watchpoint per address, with total number
// of watchpoints limited by the hardware which the inferior is running on.
@@ -588,10 +594,13 @@
(matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
(matched_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
// Return the existing watchpoint if both size and type match.
- if (size == old_size && kind == old_type) {
+ if (size == old_size && kind == old_type)
+ {
wp_sp = matched_sp;
wp_sp->SetEnabled(false, notify);
- } else {
+ }
+ else
+ {
// Nil the matched watchpoint; we will be creating a new one.
m_process_sp->DisableWatchpoint(matched_sp.get(), notify);
m_watchpoint_list.Remove(matched_sp->GetID(), true);