Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- BreakpointLocation.cpp ----------------------------------*- C++ -*-===// |
| 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 | |
| 10 | // C Includes |
| 11 | // C++ Includes |
| 12 | #include <string> |
| 13 | |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 17 | #include "lldb/Breakpoint/BreakpointID.h" |
| 18 | #include "lldb/Breakpoint/StoppointCallbackContext.h" |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Debugger.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Log.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 21 | #include "lldb/Core/Module.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 22 | #include "lldb/Core/StreamString.h" |
Zachary Turner | a78bd7f | 2015-03-03 23:11:11 +0000 | [diff] [blame] | 23 | #include "lldb/Core/ValueObject.h" |
Bruce Mitchener | 937e396 | 2015-09-21 16:56:08 +0000 | [diff] [blame^] | 24 | #include "lldb/Expression/ExpressionVariable.h" |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame] | 25 | #include "lldb/Expression/UserExpression.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 26 | #include "lldb/Symbol/CompileUnit.h" |
| 27 | #include "lldb/Symbol/Symbol.h" |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame] | 28 | #include "lldb/Symbol/TypeSystem.h" |
Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 29 | #include "lldb/Target/Target.h" |
| 30 | #include "lldb/Target/Process.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | #include "lldb/Target/Thread.h" |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 32 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | |
| 34 | using namespace lldb; |
| 35 | using namespace lldb_private; |
| 36 | |
| 37 | BreakpointLocation::BreakpointLocation |
| 38 | ( |
| 39 | break_id_t loc_id, |
| 40 | Breakpoint &owner, |
Greg Clayton | c0d3446 | 2011-02-05 00:38:04 +0000 | [diff] [blame] | 41 | const Address &addr, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 42 | lldb::tid_t tid, |
Jim Ingham | 1460e4b | 2014-01-10 23:46:59 +0000 | [diff] [blame] | 43 | bool hardware, |
| 44 | bool check_for_resolver |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 45 | ) : |
Greg Clayton | f3ef3d2 | 2011-05-22 22:46:53 +0000 | [diff] [blame] | 46 | StoppointLocation (loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware), |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 47 | m_being_created(true), |
Jim Ingham | 1460e4b | 2014-01-10 23:46:59 +0000 | [diff] [blame] | 48 | m_should_resolve_indirect_functions (false), |
| 49 | m_is_reexported (false), |
| 50 | m_is_indirect (false), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 51 | m_address (addr), |
| 52 | m_owner (owner), |
| 53 | m_options_ap (), |
Sean Callanan | b4987e3 | 2013-06-06 20:18:50 +0000 | [diff] [blame] | 54 | m_bp_site_sp (), |
| 55 | m_condition_mutex () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 56 | { |
Jim Ingham | 1460e4b | 2014-01-10 23:46:59 +0000 | [diff] [blame] | 57 | if (check_for_resolver) |
| 58 | { |
| 59 | Symbol *symbol = m_address.CalculateSymbolContextSymbol(); |
| 60 | if (symbol && symbol->IsIndirect()) |
| 61 | { |
| 62 | SetShouldResolveIndirectFunctions (true); |
| 63 | } |
| 64 | } |
| 65 | |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 66 | SetThreadID (tid); |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 67 | m_being_created = false; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | BreakpointLocation::~BreakpointLocation() |
| 71 | { |
| 72 | ClearBreakpointSite(); |
| 73 | } |
| 74 | |
| 75 | lldb::addr_t |
Greg Clayton | 13238c4 | 2010-06-14 04:18:27 +0000 | [diff] [blame] | 76 | BreakpointLocation::GetLoadAddress () const |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 77 | { |
Greg Clayton | f3ef3d2 | 2011-05-22 22:46:53 +0000 | [diff] [blame] | 78 | return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | Address & |
| 82 | BreakpointLocation::GetAddress () |
| 83 | { |
| 84 | return m_address; |
| 85 | } |
| 86 | |
| 87 | Breakpoint & |
| 88 | BreakpointLocation::GetBreakpoint () |
| 89 | { |
| 90 | return m_owner; |
| 91 | } |
| 92 | |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame] | 93 | Target & |
| 94 | BreakpointLocation::GetTarget() |
| 95 | { |
| 96 | return m_owner.GetTarget(); |
| 97 | } |
| 98 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 99 | bool |
Johnny Chen | fdad679 | 2012-02-01 19:05:20 +0000 | [diff] [blame] | 100 | BreakpointLocation::IsEnabled () const |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 101 | { |
Johnny Chen | 50df1f9 | 2012-01-30 22:48:10 +0000 | [diff] [blame] | 102 | if (!m_owner.IsEnabled()) |
| 103 | return false; |
| 104 | else if (m_options_ap.get() != NULL) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 105 | return m_options_ap->IsEnabled(); |
| 106 | else |
Johnny Chen | 50df1f9 | 2012-01-30 22:48:10 +0000 | [diff] [blame] | 107 | return true; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | void |
| 111 | BreakpointLocation::SetEnabled (bool enabled) |
| 112 | { |
| 113 | GetLocationOptions()->SetEnabled(enabled); |
| 114 | if (enabled) |
| 115 | { |
| 116 | ResolveBreakpointSite(); |
| 117 | } |
| 118 | else |
| 119 | { |
| 120 | ClearBreakpointSite(); |
| 121 | } |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 122 | SendBreakpointLocationChangedEvent (enabled ? eBreakpointEventTypeEnabled : eBreakpointEventTypeDisabled); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | void |
| 126 | BreakpointLocation::SetThreadID (lldb::tid_t thread_id) |
| 127 | { |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 128 | if (thread_id != LLDB_INVALID_THREAD_ID) |
| 129 | GetLocationOptions()->SetThreadID(thread_id); |
| 130 | else |
| 131 | { |
| 132 | // If we're resetting this to an invalid thread id, then |
| 133 | // don't make an options pointer just to do that. |
| 134 | if (m_options_ap.get() != NULL) |
| 135 | m_options_ap->SetThreadID (thread_id); |
| 136 | } |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 137 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); |
| 138 | } |
| 139 | |
| 140 | lldb::tid_t |
| 141 | BreakpointLocation::GetThreadID () |
| 142 | { |
| 143 | if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) |
| 144 | return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(); |
| 145 | else |
| 146 | return LLDB_INVALID_THREAD_ID; |
| 147 | } |
| 148 | |
| 149 | void |
| 150 | BreakpointLocation::SetThreadIndex (uint32_t index) |
| 151 | { |
| 152 | if (index != 0) |
| 153 | GetLocationOptions()->GetThreadSpec()->SetIndex(index); |
| 154 | else |
| 155 | { |
| 156 | // If we're resetting this to an invalid thread id, then |
| 157 | // don't make an options pointer just to do that. |
| 158 | if (m_options_ap.get() != NULL) |
| 159 | m_options_ap->GetThreadSpec()->SetIndex(index); |
| 160 | } |
| 161 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | uint32_t |
| 166 | BreakpointLocation::GetThreadIndex() const |
| 167 | { |
| 168 | if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) |
| 169 | return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetIndex(); |
| 170 | else |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | void |
| 175 | BreakpointLocation::SetThreadName (const char *thread_name) |
| 176 | { |
| 177 | if (thread_name != NULL) |
| 178 | GetLocationOptions()->GetThreadSpec()->SetName(thread_name); |
| 179 | else |
| 180 | { |
| 181 | // If we're resetting this to an invalid thread id, then |
| 182 | // don't make an options pointer just to do that. |
| 183 | if (m_options_ap.get() != NULL) |
| 184 | m_options_ap->GetThreadSpec()->SetName(thread_name); |
| 185 | } |
| 186 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); |
| 187 | } |
| 188 | |
| 189 | const char * |
| 190 | BreakpointLocation::GetThreadName () const |
| 191 | { |
| 192 | if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) |
| 193 | return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName(); |
| 194 | else |
| 195 | return NULL; |
| 196 | } |
| 197 | |
| 198 | void |
| 199 | BreakpointLocation::SetQueueName (const char *queue_name) |
| 200 | { |
| 201 | if (queue_name != NULL) |
| 202 | GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name); |
| 203 | else |
| 204 | { |
| 205 | // If we're resetting this to an invalid thread id, then |
| 206 | // don't make an options pointer just to do that. |
| 207 | if (m_options_ap.get() != NULL) |
| 208 | m_options_ap->GetThreadSpec()->SetQueueName(queue_name); |
| 209 | } |
| 210 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); |
| 211 | } |
| 212 | |
| 213 | const char * |
| 214 | BreakpointLocation::GetQueueName () const |
| 215 | { |
| 216 | if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) |
| 217 | return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName(); |
| 218 | else |
| 219 | return NULL; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | bool |
| 223 | BreakpointLocation::InvokeCallback (StoppointCallbackContext *context) |
| 224 | { |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 225 | if (m_options_ap.get() != NULL && m_options_ap->HasCallback()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 226 | return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID()); |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 227 | else |
| 228 | return m_owner.InvokeCallback (context, GetID()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | void |
| 232 | BreakpointLocation::SetCallback (BreakpointHitCallback callback, void *baton, |
| 233 | bool is_synchronous) |
| 234 | { |
| 235 | // The default "Baton" class will keep a copy of "baton" and won't free |
| 236 | // or delete it when it goes goes out of scope. |
| 237 | GetLocationOptions()->SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous); |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 238 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | void |
| 242 | BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP &baton_sp, |
| 243 | bool is_synchronous) |
| 244 | { |
| 245 | GetLocationOptions()->SetCallback (callback, baton_sp, is_synchronous); |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 246 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 247 | } |
| 248 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 249 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 250 | void |
| 251 | BreakpointLocation::ClearCallback () |
| 252 | { |
| 253 | GetLocationOptions()->ClearCallback(); |
| 254 | } |
| 255 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 256 | void |
| 257 | BreakpointLocation::SetCondition (const char *condition) |
| 258 | { |
| 259 | GetLocationOptions()->SetCondition (condition); |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 260 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeConditionChanged); |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 261 | } |
| 262 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 263 | const char * |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 264 | BreakpointLocation::GetConditionText (size_t *hash) const |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 265 | { |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 266 | return GetOptionsNoCreate()->GetConditionText(hash); |
| 267 | } |
| 268 | |
| 269 | bool |
| 270 | BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) |
| 271 | { |
| 272 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
Sean Callanan | b4987e3 | 2013-06-06 20:18:50 +0000 | [diff] [blame] | 273 | |
| 274 | Mutex::Locker evaluation_locker(m_condition_mutex); |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 275 | |
| 276 | size_t condition_hash; |
| 277 | const char *condition_text = GetConditionText(&condition_hash); |
| 278 | |
| 279 | if (!condition_text) |
Sean Callanan | ec537a2 | 2013-05-10 21:58:45 +0000 | [diff] [blame] | 280 | { |
| 281 | m_user_expression_sp.reset(); |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 282 | return false; |
Sean Callanan | ec537a2 | 2013-05-10 21:58:45 +0000 | [diff] [blame] | 283 | } |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 284 | |
| 285 | if (condition_hash != m_condition_hash || |
| 286 | !m_user_expression_sp || |
| 287 | !m_user_expression_sp->MatchesContext(exe_ctx)) |
| 288 | { |
Jim Ingham | 151c032 | 2015-09-15 21:13:50 +0000 | [diff] [blame] | 289 | LanguageType language = eLanguageTypeUnknown; |
| 290 | // See if we can figure out the language from the frame, otherwise use the default language: |
| 291 | CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit(); |
| 292 | if (comp_unit) |
| 293 | language = comp_unit->GetLanguage(); |
| 294 | |
| 295 | Error error; |
| 296 | m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text, |
| 297 | NULL, |
| 298 | language, |
| 299 | Expression::eResultTypeAny, |
| 300 | error)); |
| 301 | if (error.Fail()) |
| 302 | { |
| 303 | if (log) |
| 304 | log->Printf("Error getting condition expression: %s.", error.AsCString()); |
| 305 | m_user_expression_sp.reset(); |
| 306 | return true; |
| 307 | } |
| 308 | |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 309 | |
| 310 | StreamString errors; |
| 311 | |
| 312 | if (!m_user_expression_sp->Parse(errors, |
| 313 | exe_ctx, |
| 314 | eExecutionPolicyOnlyWhenNeeded, |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 315 | true, |
| 316 | false)) |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 317 | { |
| 318 | error.SetErrorStringWithFormat("Couldn't parse conditional expression:\n%s", |
| 319 | errors.GetData()); |
| 320 | m_user_expression_sp.reset(); |
| 321 | return false; |
| 322 | } |
| 323 | |
| 324 | m_condition_hash = condition_hash; |
| 325 | } |
| 326 | |
| 327 | // We need to make sure the user sees any parse errors in their condition, so we'll hook the |
| 328 | // constructor errors up to the debugger's Async I/O. |
| 329 | |
| 330 | ValueObjectSP result_value_sp; |
Greg Clayton | 62afb9f | 2013-11-04 19:35:17 +0000 | [diff] [blame] | 331 | |
| 332 | EvaluateExpressionOptions options; |
| 333 | options.SetUnwindOnError(true); |
| 334 | options.SetIgnoreBreakpoints(true); |
Jim Ingham | 6fbc48b | 2013-11-07 00:11:47 +0000 | [diff] [blame] | 335 | options.SetTryAllThreads(true); |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 336 | |
| 337 | Error expr_error; |
| 338 | |
| 339 | StreamString execution_errors; |
| 340 | |
Sean Callanan | bc8ac34 | 2015-09-04 20:49:51 +0000 | [diff] [blame] | 341 | ExpressionVariableSP result_variable_sp; |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 342 | |
Jim Ingham | 1624a2d | 2014-05-05 02:26:40 +0000 | [diff] [blame] | 343 | ExpressionResults result_code = |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 344 | m_user_expression_sp->Execute(execution_errors, |
| 345 | exe_ctx, |
Greg Clayton | 62afb9f | 2013-11-04 19:35:17 +0000 | [diff] [blame] | 346 | options, |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 347 | m_user_expression_sp, |
Greg Clayton | 62afb9f | 2013-11-04 19:35:17 +0000 | [diff] [blame] | 348 | result_variable_sp); |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 349 | |
| 350 | bool ret; |
| 351 | |
Jim Ingham | 8646d3c | 2014-05-05 02:47:44 +0000 | [diff] [blame] | 352 | if (result_code == eExpressionCompleted) |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 353 | { |
Sean Callanan | 467441d5 | 2013-05-29 20:22:18 +0000 | [diff] [blame] | 354 | if (!result_variable_sp) |
| 355 | { |
Sean Callanan | 467441d5 | 2013-05-29 20:22:18 +0000 | [diff] [blame] | 356 | error.SetErrorString("Expression did not return a result"); |
Sean Callanan | 879425f | 2013-06-24 17:58:46 +0000 | [diff] [blame] | 357 | return false; |
Sean Callanan | 467441d5 | 2013-05-29 20:22:18 +0000 | [diff] [blame] | 358 | } |
| 359 | |
Sean Callanan | 3dbf346 | 2013-04-19 07:09:15 +0000 | [diff] [blame] | 360 | result_value_sp = result_variable_sp->GetValueObject(); |
| 361 | |
| 362 | if (result_value_sp) |
| 363 | { |
| 364 | Scalar scalar_value; |
| 365 | if (result_value_sp->ResolveValue (scalar_value)) |
| 366 | { |
| 367 | if (scalar_value.ULongLong(1) == 0) |
| 368 | ret = false; |
| 369 | else |
| 370 | ret = true; |
| 371 | if (log) |
| 372 | log->Printf("Condition successfully evaluated, result is %s.\n", |
| 373 | ret ? "true" : "false"); |
| 374 | } |
| 375 | else |
| 376 | { |
| 377 | ret = false; |
| 378 | error.SetErrorString("Failed to get an integer result from the expression"); |
| 379 | } |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | ret = false; |
| 384 | error.SetErrorString("Failed to get any result from the expression"); |
| 385 | } |
| 386 | } |
| 387 | else |
| 388 | { |
| 389 | ret = false; |
| 390 | error.SetErrorStringWithFormat("Couldn't execute expression:\n%s", execution_errors.GetData()); |
| 391 | } |
| 392 | |
| 393 | return ret; |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 394 | } |
| 395 | |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 396 | uint32_t |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 397 | BreakpointLocation::GetIgnoreCount () |
| 398 | { |
Jim Ingham | 05407f6 | 2010-06-22 21:12:54 +0000 | [diff] [blame] | 399 | return GetOptionsNoCreate()->GetIgnoreCount(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | void |
Greg Clayton | c982c76 | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 403 | BreakpointLocation::SetIgnoreCount (uint32_t n) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 404 | { |
| 405 | GetLocationOptions()->SetIgnoreCount(n); |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 406 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeIgnoreChanged); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Jim Ingham | 0fd1b75 | 2012-06-26 22:27:55 +0000 | [diff] [blame] | 409 | void |
| 410 | BreakpointLocation::DecrementIgnoreCount() |
| 411 | { |
| 412 | if (m_options_ap.get() != NULL) |
| 413 | { |
| 414 | uint32_t loc_ignore = m_options_ap->GetIgnoreCount(); |
| 415 | if (loc_ignore != 0) |
| 416 | m_options_ap->SetIgnoreCount(loc_ignore - 1); |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | bool |
| 421 | BreakpointLocation::IgnoreCountShouldStop() |
| 422 | { |
| 423 | if (m_options_ap.get() != NULL) |
| 424 | { |
| 425 | uint32_t loc_ignore = m_options_ap->GetIgnoreCount(); |
| 426 | if (loc_ignore != 0) |
| 427 | { |
| 428 | m_owner.DecrementIgnoreCount(); |
| 429 | DecrementIgnoreCount(); // Have to decrement our owners' ignore count, since it won't get a |
| 430 | // chance to. |
| 431 | return false; |
| 432 | } |
| 433 | } |
| 434 | return true; |
| 435 | } |
| 436 | |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 437 | const BreakpointOptions * |
Jim Ingham | 05407f6 | 2010-06-22 21:12:54 +0000 | [diff] [blame] | 438 | BreakpointLocation::GetOptionsNoCreate () const |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 439 | { |
| 440 | if (m_options_ap.get() != NULL) |
| 441 | return m_options_ap.get(); |
| 442 | else |
| 443 | return m_owner.GetOptions (); |
| 444 | } |
| 445 | |
| 446 | BreakpointOptions * |
| 447 | BreakpointLocation::GetLocationOptions () |
| 448 | { |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 449 | // If we make the copy we don't copy the callbacks because that is potentially |
| 450 | // expensive and we don't want to do that for the simple case where someone is |
| 451 | // just disabling the location. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 452 | if (m_options_ap.get() == NULL) |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 453 | m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ())); |
| 454 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 455 | return m_options_ap.get(); |
| 456 | } |
| 457 | |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 458 | bool |
| 459 | BreakpointLocation::ValidForThisThread (Thread *thread) |
| 460 | { |
Jim Ingham | 05407f6 | 2010-06-22 21:12:54 +0000 | [diff] [blame] | 461 | return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate()); |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 464 | // RETURNS - true if we should stop at this breakpoint, false if we |
Jim Ingham | 1b54c88 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 465 | // should continue. Note, we don't check the thread spec for the breakpoint |
| 466 | // here, since if the breakpoint is not for this thread, then the event won't |
| 467 | // even get reported, so the check is redundant. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 468 | |
| 469 | bool |
| 470 | BreakpointLocation::ShouldStop (StoppointCallbackContext *context) |
| 471 | { |
| 472 | bool should_stop = true; |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 473 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 474 | |
Jim Ingham | a672ece | 2014-10-22 01:54:17 +0000 | [diff] [blame] | 475 | // Do this first, if a location is disabled, it shouldn't increment its hit count. |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 476 | if (!IsEnabled()) |
| 477 | return false; |
| 478 | |
Jim Ingham | 0fd1b75 | 2012-06-26 22:27:55 +0000 | [diff] [blame] | 479 | if (!IgnoreCountShouldStop()) |
| 480 | return false; |
| 481 | |
| 482 | if (!m_owner.IgnoreCountShouldStop()) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 483 | return false; |
| 484 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 485 | // We only run synchronous callbacks in ShouldStop: |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 486 | context->is_synchronous = true; |
| 487 | should_stop = InvokeCallback (context); |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 488 | |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 489 | if (log) |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 490 | { |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 491 | StreamString s; |
| 492 | GetDescription (&s, lldb::eDescriptionLevelVerbose); |
| 493 | log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing"); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 494 | } |
Jim Ingham | 5b52f0c | 2011-06-02 23:58:26 +0000 | [diff] [blame] | 495 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 496 | return should_stop; |
| 497 | } |
| 498 | |
Jim Ingham | a672ece | 2014-10-22 01:54:17 +0000 | [diff] [blame] | 499 | void |
| 500 | BreakpointLocation::BumpHitCount() |
| 501 | { |
| 502 | if (IsEnabled()) |
Jim Ingham | d762df8 | 2015-01-15 01:41:04 +0000 | [diff] [blame] | 503 | { |
| 504 | // Step our hit count, and also step the hit count of the owner. |
Jim Ingham | a672ece | 2014-10-22 01:54:17 +0000 | [diff] [blame] | 505 | IncrementHitCount(); |
Jim Ingham | d762df8 | 2015-01-15 01:41:04 +0000 | [diff] [blame] | 506 | m_owner.IncrementHitCount(); |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | void |
| 511 | BreakpointLocation::UndoBumpHitCount() |
| 512 | { |
| 513 | if (IsEnabled()) |
| 514 | { |
| 515 | // Step our hit count, and also step the hit count of the owner. |
| 516 | DecrementHitCount(); |
| 517 | m_owner.DecrementHitCount(); |
| 518 | } |
Jim Ingham | a672ece | 2014-10-22 01:54:17 +0000 | [diff] [blame] | 519 | } |
| 520 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 521 | bool |
| 522 | BreakpointLocation::IsResolved () const |
| 523 | { |
| 524 | return m_bp_site_sp.get() != NULL; |
| 525 | } |
| 526 | |
Jim Ingham | 36f3b36 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 527 | lldb::BreakpointSiteSP |
| 528 | BreakpointLocation::GetBreakpointSite() const |
| 529 | { |
| 530 | return m_bp_site_sp; |
| 531 | } |
| 532 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 533 | bool |
| 534 | BreakpointLocation::ResolveBreakpointSite () |
| 535 | { |
| 536 | if (m_bp_site_sp) |
| 537 | return true; |
| 538 | |
Greg Clayton | f5e56de | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 539 | Process *process = m_owner.GetTarget().GetProcessSP().get(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 540 | if (process == NULL) |
| 541 | return false; |
| 542 | |
Greg Clayton | eb023e7 | 2013-10-11 19:48:25 +0000 | [diff] [blame] | 543 | lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 544 | |
Stephen Wilson | 50bd94f | 2010-07-17 00:56:13 +0000 | [diff] [blame] | 545 | if (new_id == LLDB_INVALID_BREAK_ID) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 546 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 547 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 548 | if (log) |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 549 | log->Warning ("Tried to add breakpoint site at 0x%" PRIx64 " but it was already present.\n", |
Greg Clayton | f3ef3d2 | 2011-05-22 22:46:53 +0000 | [diff] [blame] | 550 | m_address.GetOpcodeLoadAddress (&m_owner.GetTarget())); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 551 | return false; |
| 552 | } |
| 553 | |
| 554 | return true; |
| 555 | } |
| 556 | |
| 557 | bool |
| 558 | BreakpointLocation::SetBreakpointSite (BreakpointSiteSP& bp_site_sp) |
| 559 | { |
| 560 | m_bp_site_sp = bp_site_sp; |
Ilia K | 9b618d2 | 2015-04-09 12:55:13 +0000 | [diff] [blame] | 561 | SendBreakpointLocationChangedEvent (eBreakpointEventTypeLocationsResolved); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 562 | return true; |
| 563 | } |
| 564 | |
| 565 | bool |
| 566 | BreakpointLocation::ClearBreakpointSite () |
| 567 | { |
| 568 | if (m_bp_site_sp.get()) |
| 569 | { |
Jim Ingham | 1578313 | 2014-03-12 22:03:13 +0000 | [diff] [blame] | 570 | ProcessSP process_sp(m_owner.GetTarget().GetProcessSP()); |
| 571 | // If the process exists, get it to remove the owner, it will remove the physical implementation |
| 572 | // of the breakpoint as well if there are no more owners. Otherwise just remove this owner. |
| 573 | if (process_sp) |
| 574 | process_sp->RemoveOwnerFromBreakpointSite (GetBreakpoint().GetID(), |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 575 | GetID(), m_bp_site_sp); |
Jim Ingham | 1578313 | 2014-03-12 22:03:13 +0000 | [diff] [blame] | 576 | else |
| 577 | m_bp_site_sp->RemoveOwner(GetBreakpoint().GetID(), GetID()); |
| 578 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 579 | m_bp_site_sp.reset(); |
| 580 | return true; |
| 581 | } |
| 582 | return false; |
| 583 | } |
| 584 | |
| 585 | void |
| 586 | BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) |
| 587 | { |
| 588 | SymbolContext sc; |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 589 | |
| 590 | // If the description level is "initial" then the breakpoint is printing out our initial state, |
| 591 | // and we should let it decide how it wants to print our label. |
| 592 | if (level != eDescriptionLevelInitial) |
| 593 | { |
| 594 | s->Indent(); |
| 595 | BreakpointID::GetCanonicalReference(s, m_owner.GetID(), GetID()); |
| 596 | } |
| 597 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 598 | if (level == lldb::eDescriptionLevelBrief) |
| 599 | return; |
| 600 | |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 601 | if (level != eDescriptionLevelInitial) |
| 602 | s->PutCString(": "); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 603 | |
| 604 | if (level == lldb::eDescriptionLevelVerbose) |
| 605 | s->IndentMore(); |
| 606 | |
| 607 | if (m_address.IsSectionOffset()) |
| 608 | { |
| 609 | m_address.CalculateSymbolContext(&sc); |
| 610 | |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 611 | if (level == lldb::eDescriptionLevelFull || level == eDescriptionLevelInitial) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 612 | { |
Jim Ingham | 1460e4b | 2014-01-10 23:46:59 +0000 | [diff] [blame] | 613 | if (IsReExported()) |
| 614 | s->PutCString ("re-exported target = "); |
| 615 | else |
| 616 | s->PutCString("where = "); |
Jason Molenda | c980fa9 | 2015-02-13 23:24:21 +0000 | [diff] [blame] | 617 | sc.DumpStopContext (s, m_owner.GetTarget().GetProcessSP().get(), m_address, false, true, false, true, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 618 | } |
| 619 | else |
| 620 | { |
| 621 | if (sc.module_sp) |
| 622 | { |
| 623 | s->EOL(); |
| 624 | s->Indent("module = "); |
| 625 | sc.module_sp->GetFileSpec().Dump (s); |
| 626 | } |
| 627 | |
| 628 | if (sc.comp_unit != NULL) |
| 629 | { |
| 630 | s->EOL(); |
| 631 | s->Indent("compile unit = "); |
Jim Ingham | 517b3b2 | 2010-10-27 22:58:34 +0000 | [diff] [blame] | 632 | static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 633 | |
| 634 | if (sc.function != NULL) |
| 635 | { |
| 636 | s->EOL(); |
| 637 | s->Indent("function = "); |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 638 | s->PutCString (sc.function->GetName().AsCString("<unknown>")); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | if (sc.line_entry.line > 0) |
| 642 | { |
| 643 | s->EOL(); |
| 644 | s->Indent("location = "); |
Greg Clayton | 6dadd50 | 2010-09-02 21:44:10 +0000 | [diff] [blame] | 645 | sc.line_entry.DumpStopContext (s, true); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 646 | } |
| 647 | |
| 648 | } |
| 649 | else |
| 650 | { |
| 651 | // If we don't have a comp unit, see if we have a symbol we can print. |
| 652 | if (sc.symbol) |
| 653 | { |
| 654 | s->EOL(); |
Jim Ingham | 1460e4b | 2014-01-10 23:46:59 +0000 | [diff] [blame] | 655 | if (IsReExported()) |
| 656 | s->Indent ("re-exported target = "); |
| 657 | else |
| 658 | s->Indent("symbol = "); |
Greg Clayton | ddaf6a7 | 2015-07-08 22:32:23 +0000 | [diff] [blame] | 659 | s->PutCString(sc.symbol->GetName().AsCString("<unknown>")); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 660 | } |
| 661 | } |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | if (level == lldb::eDescriptionLevelVerbose) |
| 666 | { |
| 667 | s->EOL(); |
| 668 | s->Indent(); |
| 669 | } |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 670 | |
| 671 | if (m_address.IsSectionOffset() && (level == eDescriptionLevelFull || level == eDescriptionLevelInitial)) |
| 672 | s->Printf (", "); |
| 673 | s->Printf ("address = "); |
| 674 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 675 | ExecutionContextScope *exe_scope = NULL; |
| 676 | Target *target = &m_owner.GetTarget(); |
| 677 | if (target) |
| 678 | exe_scope = target->GetProcessSP().get(); |
| 679 | if (exe_scope == NULL) |
| 680 | exe_scope = target; |
| 681 | |
Jim Ingham | 8f63266 | 2014-03-04 03:09:00 +0000 | [diff] [blame] | 682 | if (level == eDescriptionLevelInitial) |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 683 | m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); |
| 684 | else |
| 685 | m_address.Dump(s, exe_scope, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); |
Jim Ingham | 1460e4b | 2014-01-10 23:46:59 +0000 | [diff] [blame] | 686 | |
| 687 | if (IsIndirect() && m_bp_site_sp) |
| 688 | { |
| 689 | Address resolved_address; |
| 690 | resolved_address.SetLoadAddress(m_bp_site_sp->GetLoadAddress(), target); |
| 691 | Symbol *resolved_symbol = resolved_address.CalculateSymbolContextSymbol(); |
| 692 | if (resolved_symbol) |
| 693 | { |
| 694 | if (level == eDescriptionLevelFull || level == eDescriptionLevelInitial) |
| 695 | s->Printf (", "); |
| 696 | else if (level == lldb::eDescriptionLevelVerbose) |
| 697 | { |
| 698 | s->EOL(); |
| 699 | s->Indent(); |
| 700 | } |
| 701 | s->Printf ("indirect target = %s", resolved_symbol->GetName().GetCString()); |
| 702 | } |
| 703 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 704 | |
| 705 | if (level == lldb::eDescriptionLevelVerbose) |
| 706 | { |
| 707 | s->EOL(); |
| 708 | s->Indent(); |
| 709 | s->Printf("resolved = %s\n", IsResolved() ? "true" : "false"); |
| 710 | |
| 711 | s->Indent(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 712 | s->Printf ("hit count = %-4u\n", GetHitCount()); |
| 713 | |
| 714 | if (m_options_ap.get()) |
| 715 | { |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 716 | s->Indent(); |
| 717 | m_options_ap->GetDescription (s, level); |
| 718 | s->EOL(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 719 | } |
| 720 | s->IndentLess(); |
| 721 | } |
Jim Ingham | 1391cc7 | 2012-09-22 00:04:04 +0000 | [diff] [blame] | 722 | else if (level != eDescriptionLevelInitial) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 723 | { |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 724 | s->Printf(", %sresolved, hit count = %u ", |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 725 | (IsResolved() ? "" : "un"), |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 726 | GetHitCount()); |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 727 | if (m_options_ap.get()) |
| 728 | { |
| 729 | m_options_ap->GetDescription (s, level); |
| 730 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 731 | } |
| 732 | } |
| 733 | |
| 734 | void |
| 735 | BreakpointLocation::Dump(Stream *s) const |
| 736 | { |
| 737 | if (s == NULL) |
| 738 | return; |
| 739 | |
Daniel Malea | d01b295 | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 740 | s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint " |
Jim Ingham | 0136309 | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 741 | "hw_index = %i hit_count = %-4u ignore_count = %-4u", |
Johnny Chen | 9ec3c4f | 2012-01-26 00:08:14 +0000 | [diff] [blame] | 742 | GetID(), |
| 743 | GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(), |
| 744 | (uint64_t) m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()), |
Johnny Chen | 50df1f9 | 2012-01-30 22:48:10 +0000 | [diff] [blame] | 745 | (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", |
Johnny Chen | 9ec3c4f | 2012-01-26 00:08:14 +0000 | [diff] [blame] | 746 | IsHardware() ? "hardware" : "software", |
| 747 | GetHardwareIndex(), |
| 748 | GetHitCount(), |
| 749 | GetOptionsNoCreate()->GetIgnoreCount()); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 750 | } |
Jim Ingham | e6bc6cb | 2012-02-08 05:23:15 +0000 | [diff] [blame] | 751 | |
| 752 | void |
| 753 | BreakpointLocation::SendBreakpointLocationChangedEvent (lldb::BreakpointEventType eventKind) |
| 754 | { |
| 755 | if (!m_being_created |
| 756 | && !m_owner.IsInternal() |
| 757 | && m_owner.GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) |
| 758 | { |
| 759 | Breakpoint::BreakpointEventData *data = new Breakpoint::BreakpointEventData (eventKind, |
| 760 | m_owner.shared_from_this()); |
| 761 | data->GetBreakpointLocationCollection().Add (shared_from_this()); |
| 762 | m_owner.GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, data); |
| 763 | } |
| 764 | } |
Jim Ingham | 77fd738 | 2014-09-10 21:40:47 +0000 | [diff] [blame] | 765 | |
| 766 | void |
| 767 | BreakpointLocation::SwapLocation (BreakpointLocationSP swap_from) |
| 768 | { |
| 769 | m_address = swap_from->m_address; |
| 770 | m_should_resolve_indirect_functions = swap_from->m_should_resolve_indirect_functions; |
| 771 | m_is_reexported = swap_from->m_is_reexported; |
| 772 | m_is_indirect = swap_from->m_is_indirect; |
| 773 | m_user_expression_sp.reset(); |
| 774 | } |