Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1 | //===-- Watchpoint.cpp ------------------------------------------*- C++ -*-===// |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 10 | #include "lldb/Breakpoint/Watchpoint.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 16 | #include "lldb/Breakpoint/StoppointCallbackContext.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/Core/Stream.h" |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 18 | #include "lldb/Target/Process.h" |
| 19 | #include "lldb/Target/Target.h" |
| 20 | #include "lldb/Target/ThreadSpec.h" |
Jim Ingham | 14f17cf | 2012-05-02 00:30:53 +0000 | [diff] [blame] | 21 | #include "lldb/Expression/ClangUserExpression.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | |
| 23 | using namespace lldb; |
| 24 | using namespace lldb_private; |
| 25 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 26 | Watchpoint::Watchpoint (lldb::addr_t addr, size_t size, bool hardware) : |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 27 | StoppointLocation (0, addr, size, hardware), |
Johnny Chen | 096c293 | 2011-09-26 22:40:50 +0000 | [diff] [blame] | 28 | m_target(NULL), |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 29 | m_enabled(false), |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 30 | m_is_hardware(hardware), |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 31 | m_is_watch_variable(false), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 32 | m_watch_read(0), |
| 33 | m_watch_write(0), |
| 34 | m_watch_was_read(0), |
| 35 | m_watch_was_written(0), |
| 36 | m_ignore_count(0), |
Johnny Chen | 0b09366 | 2012-08-14 20:56:37 +0000 | [diff] [blame^] | 37 | m_false_alarms(0), |
Johnny Chen | 41a55ef | 2011-10-14 19:15:48 +0000 | [diff] [blame] | 38 | m_decl_str(), |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 39 | m_watch_spec_str(), |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 40 | m_snapshot_old_str(), |
| 41 | m_snapshot_new_str(), |
| 42 | m_snapshot_old_val(0), |
| 43 | m_snapshot_new_val(0), |
Johnny Chen | f3ec461 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 44 | m_error(), |
| 45 | m_options () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 49 | Watchpoint::~Watchpoint() |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 50 | { |
| 51 | } |
| 52 | |
Johnny Chen | f3ec461 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 53 | // This function is used when "baton" doesn't need to be freed |
| 54 | void |
| 55 | Watchpoint::SetCallback (WatchpointHitCallback callback, void *baton, bool is_synchronous) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | { |
Johnny Chen | f3ec461 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 57 | // The default "Baton" class will keep a copy of "baton" and won't free |
| 58 | // or delete it when it goes goes out of scope. |
| 59 | m_options.SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous); |
| 60 | |
| 61 | //SendWatchpointChangedEvent (eWatchpointEventTypeCommandChanged); |
| 62 | } |
| 63 | |
| 64 | // This function is used when a baton needs to be freed and therefore is |
| 65 | // contained in a "Baton" subclass. |
| 66 | void |
| 67 | Watchpoint::SetCallback (WatchpointHitCallback callback, const BatonSP &callback_baton_sp, bool is_synchronous) |
| 68 | { |
| 69 | m_options.SetCallback(callback, callback_baton_sp, is_synchronous); |
| 70 | } |
| 71 | |
| 72 | void |
| 73 | Watchpoint::ClearCallback () |
| 74 | { |
| 75 | m_options.ClearCallback (); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 78 | void |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 79 | Watchpoint::SetDeclInfo (const std::string &str) |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 80 | { |
| 81 | m_decl_str = str; |
| 82 | return; |
| 83 | } |
| 84 | |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 85 | std::string |
| 86 | Watchpoint::GetWatchSpec() |
| 87 | { |
| 88 | return m_watch_spec_str; |
| 89 | } |
| 90 | |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 91 | void |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 92 | Watchpoint::SetWatchSpec (const std::string &str) |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 93 | { |
| 94 | m_watch_spec_str = str; |
| 95 | return; |
| 96 | } |
| 97 | |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 98 | std::string |
| 99 | Watchpoint::GetOldSnapshot() const |
| 100 | { |
| 101 | return m_snapshot_old_str; |
| 102 | } |
| 103 | |
| 104 | void |
| 105 | Watchpoint::SetOldSnapshot (const std::string &str) |
| 106 | { |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 107 | size_t len = str.length(); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 108 | m_snapshot_old_str = str; |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 109 | if (len && str.at(len - 1) == '\n') |
| 110 | m_snapshot_old_str.resize(len - 1); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 111 | return; |
| 112 | } |
| 113 | |
| 114 | std::string |
| 115 | Watchpoint::GetNewSnapshot() const |
| 116 | { |
| 117 | return m_snapshot_new_str; |
| 118 | } |
| 119 | |
| 120 | void |
| 121 | Watchpoint::SetNewSnapshot (const std::string &str) |
| 122 | { |
| 123 | m_snapshot_old_str = m_snapshot_new_str; |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 124 | size_t len = str.length(); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 125 | m_snapshot_new_str = str; |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 126 | if (len && str.at(len - 1) == '\n') |
| 127 | m_snapshot_new_str.resize(len - 1); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 128 | return; |
| 129 | } |
| 130 | |
| 131 | uint64_t |
| 132 | Watchpoint::GetOldSnapshotVal() const |
| 133 | { |
| 134 | return m_snapshot_old_val; |
| 135 | } |
| 136 | |
| 137 | void |
| 138 | Watchpoint::SetOldSnapshotVal (uint64_t val) |
| 139 | { |
| 140 | m_snapshot_old_val = val; |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | uint64_t |
| 145 | Watchpoint::GetNewSnapshotVal() const |
| 146 | { |
| 147 | return m_snapshot_new_val; |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | Watchpoint::SetNewSnapshotVal (uint64_t val) |
| 152 | { |
| 153 | m_snapshot_old_val = m_snapshot_new_val; |
| 154 | m_snapshot_new_val = val; |
| 155 | return; |
| 156 | } |
| 157 | |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 158 | void |
| 159 | Watchpoint::ClearSnapshots() |
| 160 | { |
| 161 | m_snapshot_old_str.clear(); |
| 162 | m_snapshot_new_str.clear(); |
| 163 | m_snapshot_old_val = 0; |
| 164 | m_snapshot_new_val = 0; |
| 165 | } |
| 166 | |
Johnny Chen | 51b7c5f | 2012-01-23 23:03:59 +0000 | [diff] [blame] | 167 | // Override default impl of StoppointLocation::IsHardware() since m_is_hardware |
| 168 | // member field is more accurate. |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 169 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 170 | Watchpoint::IsHardware () const |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 171 | { |
| 172 | return m_is_hardware; |
| 173 | } |
| 174 | |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 175 | bool |
| 176 | Watchpoint::IsWatchVariable() const |
| 177 | { |
| 178 | return m_is_watch_variable; |
| 179 | } |
| 180 | |
| 181 | void |
| 182 | Watchpoint::SetWatchVariable(bool val) |
| 183 | { |
| 184 | m_is_watch_variable = val; |
| 185 | } |
| 186 | |
Johnny Chen | 0b09366 | 2012-08-14 20:56:37 +0000 | [diff] [blame^] | 187 | void |
| 188 | Watchpoint::IncrementFalseAlarmsAndReviseHitCount() |
| 189 | { |
| 190 | ++m_false_alarms; |
| 191 | if (m_false_alarms) |
| 192 | { |
| 193 | if (m_hit_count >= m_false_alarms) |
| 194 | { |
| 195 | m_hit_count -= m_false_alarms; |
| 196 | m_false_alarms = 0; |
| 197 | } |
| 198 | else |
| 199 | { |
| 200 | m_false_alarms -= m_hit_count; |
| 201 | m_hit_count = 0; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | // RETURNS - true if we should stop at this breakpoint, false if we |
| 207 | // should continue. |
| 208 | |
| 209 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 210 | Watchpoint::ShouldStop (StoppointCallbackContext *context) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 211 | { |
Johnny Chen | 51b7c5f | 2012-01-23 23:03:59 +0000 | [diff] [blame] | 212 | IncrementHitCount(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 213 | |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 214 | if (!IsEnabled()) |
| 215 | return false; |
Johnny Chen | 043f8c2 | 2011-09-21 22:47:15 +0000 | [diff] [blame] | 216 | |
Johnny Chen | 51b7c5f | 2012-01-23 23:03:59 +0000 | [diff] [blame] | 217 | if (GetHitCount() <= GetIgnoreCount()) |
Johnny Chen | 01acfa7 | 2011-09-22 18:04:58 +0000 | [diff] [blame] | 218 | return false; |
| 219 | |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 220 | return true; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | void |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 224 | Watchpoint::GetDescription (Stream *s, lldb::DescriptionLevel level) |
Johnny Chen | 34bbf85 | 2011-09-12 23:38:44 +0000 | [diff] [blame] | 225 | { |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 226 | DumpWithLevel(s, level); |
Johnny Chen | 34bbf85 | 2011-09-12 23:38:44 +0000 | [diff] [blame] | 227 | return; |
| 228 | } |
| 229 | |
| 230 | void |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 231 | Watchpoint::Dump(Stream *s) const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 232 | { |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 233 | DumpWithLevel(s, lldb::eDescriptionLevelBrief); |
| 234 | } |
| 235 | |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 236 | // If prefix is NULL, we display the watch id and ignore the prefix altogether. |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 237 | void |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 238 | Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 239 | { |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 240 | if (!prefix) |
| 241 | { |
| 242 | s->Printf("\nWatchpoint %u hit:", GetID()); |
| 243 | prefix = ""; |
| 244 | } |
| 245 | |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 246 | if (IsWatchVariable()) |
| 247 | { |
| 248 | if (!m_snapshot_old_str.empty()) |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 249 | s->Printf("\n%sold value: %s", prefix, m_snapshot_old_str.c_str()); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 250 | if (!m_snapshot_new_str.empty()) |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 251 | s->Printf("\n%snew value: %s", prefix, m_snapshot_new_str.c_str()); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 252 | } |
| 253 | else |
| 254 | { |
| 255 | uint32_t num_hex_digits = GetByteSize() * 2; |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 256 | s->Printf("\n%sold value: 0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_old_val); |
| 257 | s->Printf("\n%snew value: 0x%0*.*llx", prefix, num_hex_digits, num_hex_digits, m_snapshot_new_val); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
| 261 | void |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 262 | Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 263 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 264 | if (s == NULL) |
| 265 | return; |
| 266 | |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 267 | assert(description_level >= lldb::eDescriptionLevelBrief && |
| 268 | description_level <= lldb::eDescriptionLevelVerbose); |
| 269 | |
Greg Clayton | bae39c5 | 2011-12-03 00:46:21 +0000 | [diff] [blame] | 270 | s->Printf("Watchpoint %u: addr = 0x%8.8llx size = %u state = %s type = %s%s", |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 271 | GetID(), |
Johnny Chen | 1c2d941 | 2012-01-24 00:11:02 +0000 | [diff] [blame] | 272 | GetLoadAddress(), |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 273 | m_byte_size, |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 274 | IsEnabled() ? "enabled" : "disabled", |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 275 | m_watch_read ? "r" : "", |
| 276 | m_watch_write ? "w" : ""); |
| 277 | |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 278 | if (description_level >= lldb::eDescriptionLevelFull) { |
Johnny Chen | 55a2d5a | 2012-01-30 21:46:17 +0000 | [diff] [blame] | 279 | if (!m_decl_str.empty()) |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 280 | s->Printf("\n declare @ '%s'", m_decl_str.c_str()); |
Johnny Chen | 116a5cd | 2012-02-25 06:44:30 +0000 | [diff] [blame] | 281 | if (!m_watch_spec_str.empty()) |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 282 | s->Printf("\n watchpoint spec = '%s'", m_watch_spec_str.c_str()); |
| 283 | |
| 284 | // Dump the snapshots we have taken. |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 285 | DumpSnapshots(s, " "); |
Johnny Chen | 9e98559 | 2012-08-13 21:09:54 +0000 | [diff] [blame] | 286 | |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 287 | if (GetConditionText()) |
| 288 | s->Printf("\n condition = '%s'", GetConditionText()); |
Johnny Chen | f3ec461 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 289 | m_options.GetCallbackDescription(s, description_level); |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 290 | } |
Johnny Chen | 10b12b3 | 2011-09-16 21:41:42 +0000 | [diff] [blame] | 291 | |
| 292 | if (description_level >= lldb::eDescriptionLevelVerbose) |
Jason Molenda | a4a1587 | 2012-02-23 22:32:13 +0000 | [diff] [blame] | 293 | { |
Johnny Chen | f3ec461 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 294 | s->Printf("\n hw_index = %i hit_count = %-4u ignore_count = %-4u", |
| 295 | GetHardwareIndex(), |
| 296 | GetHitCount(), |
| 297 | GetIgnoreCount()); |
Jason Molenda | a4a1587 | 2012-02-23 22:32:13 +0000 | [diff] [blame] | 298 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 302 | Watchpoint::IsEnabled() const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 303 | { |
| 304 | return m_enabled; |
| 305 | } |
| 306 | |
| 307 | void |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 308 | Watchpoint::SetEnabled(bool enabled) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 309 | { |
| 310 | if (!enabled) |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 311 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | SetHardwareIndex(LLDB_INVALID_INDEX32); |
Johnny Chen | c9c2a9b | 2012-08-13 23:27:50 +0000 | [diff] [blame] | 313 | ClearSnapshots(); |
| 314 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 315 | m_enabled = enabled; |
| 316 | } |
| 317 | |
| 318 | void |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 319 | Watchpoint::SetWatchpointType (uint32_t type) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 320 | { |
| 321 | m_watch_read = (type & LLDB_WATCH_TYPE_READ) != 0; |
| 322 | m_watch_write = (type & LLDB_WATCH_TYPE_WRITE) != 0; |
| 323 | } |
| 324 | |
| 325 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 326 | Watchpoint::WatchpointRead () const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 327 | { |
| 328 | return m_watch_read != 0; |
| 329 | } |
| 330 | bool |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 331 | Watchpoint::WatchpointWrite () const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 332 | { |
| 333 | return m_watch_write != 0; |
| 334 | } |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 335 | uint32_t |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 336 | Watchpoint::GetIgnoreCount () const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 337 | { |
| 338 | return m_ignore_count; |
| 339 | } |
| 340 | |
| 341 | void |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 342 | Watchpoint::SetIgnoreCount (uint32_t n) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 343 | { |
| 344 | m_ignore_count = n; |
| 345 | } |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 346 | |
| 347 | bool |
| 348 | Watchpoint::InvokeCallback (StoppointCallbackContext *context) |
| 349 | { |
Johnny Chen | f3ec461 | 2012-08-09 23:09:42 +0000 | [diff] [blame] | 350 | return m_options.InvokeCallback (context, GetID()); |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | void |
| 354 | Watchpoint::SetCondition (const char *condition) |
| 355 | { |
| 356 | if (condition == NULL || condition[0] == '\0') |
| 357 | { |
| 358 | if (m_condition_ap.get()) |
| 359 | m_condition_ap.reset(); |
| 360 | } |
| 361 | else |
| 362 | { |
| 363 | // Pass NULL for expr_prefix (no translation-unit level definitions). |
Sean Callanan | daa6efe | 2011-12-21 22:22:58 +0000 | [diff] [blame] | 364 | m_condition_ap.reset(new ClangUserExpression (condition, NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny)); |
Johnny Chen | 712a628 | 2011-10-17 18:58:00 +0000 | [diff] [blame] | 365 | } |
| 366 | } |
| 367 | |
| 368 | const char * |
| 369 | Watchpoint::GetConditionText () const |
| 370 | { |
| 371 | if (m_condition_ap.get()) |
| 372 | return m_condition_ap->GetUserText(); |
| 373 | else |
| 374 | return NULL; |
| 375 | } |
| 376 | |