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