Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- Breakpoint.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 | |
| 11 | // C Includes |
| 12 | // C++ Includes |
| 13 | // Other libraries and framework includes |
| 14 | // Project includes |
| 15 | |
| 16 | #include "lldb/Core/Address.h" |
| 17 | #include "lldb/Breakpoint/Breakpoint.h" |
| 18 | #include "lldb/Breakpoint/BreakpointLocation.h" |
| 19 | #include "lldb/Breakpoint/BreakpointResolver.h" |
| 20 | #include "lldb/Core/Log.h" |
| 21 | #include "lldb/Core/ModuleList.h" |
| 22 | #include "lldb/Core/SearchFilter.h" |
| 23 | #include "lldb/Core/Stream.h" |
| 24 | #include "lldb/Core/StreamString.h" |
| 25 | #include "lldb/Symbol/SymbolContext.h" |
| 26 | #include "lldb/Target/Target.h" |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 27 | #include "lldb/Target/ThreadSpec.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | #include "lldb/lldb-private-log.h" |
| 29 | |
| 30 | using namespace lldb; |
| 31 | using namespace lldb_private; |
| 32 | |
| 33 | const ConstString & |
| 34 | Breakpoint::GetEventIdentifier () |
| 35 | { |
| 36 | static ConstString g_identifier("event-identifier.breakpoint.changed"); |
| 37 | return g_identifier; |
| 38 | } |
| 39 | |
| 40 | //---------------------------------------------------------------------- |
| 41 | // Breakpoint constructor |
| 42 | //---------------------------------------------------------------------- |
| 43 | Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp, BreakpointResolverSP &resolver_sp) : |
| 44 | m_target (target), |
| 45 | m_filter_sp (filter_sp), |
| 46 | m_resolver_sp (resolver_sp), |
| 47 | m_options (), |
| 48 | m_locations () |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | //---------------------------------------------------------------------- |
| 53 | // Destructor |
| 54 | //---------------------------------------------------------------------- |
| 55 | Breakpoint::~Breakpoint() |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | bool |
| 60 | Breakpoint::IsInternal () const |
| 61 | { |
| 62 | return LLDB_BREAK_ID_IS_INTERNAL(m_bid); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | |
| 67 | Target& |
| 68 | Breakpoint::GetTarget () |
| 69 | { |
| 70 | return m_target; |
| 71 | } |
| 72 | |
| 73 | const Target& |
| 74 | Breakpoint::GetTarget () const |
| 75 | { |
| 76 | return m_target; |
| 77 | } |
| 78 | |
| 79 | BreakpointLocationSP |
| 80 | Breakpoint::AddLocation (Address &addr, bool *new_location) |
| 81 | { |
| 82 | BreakpointLocationSP bp_loc_sp (m_locations.FindByAddress(addr)); |
| 83 | if (bp_loc_sp) |
| 84 | { |
| 85 | if (new_location) |
| 86 | *new_location = false; |
| 87 | return bp_loc_sp; |
| 88 | } |
| 89 | |
| 90 | bp_loc_sp.reset (new BreakpointLocation (m_locations.GetNextID(), *this, addr)); |
| 91 | m_locations.Add (bp_loc_sp); |
| 92 | bp_loc_sp->ResolveBreakpointSite(); |
| 93 | |
| 94 | if (new_location) |
| 95 | *new_location = true; |
| 96 | return bp_loc_sp; |
| 97 | } |
| 98 | |
| 99 | BreakpointLocationSP |
| 100 | Breakpoint::FindLocationByAddress (Address &addr) |
| 101 | { |
| 102 | return m_locations.FindByAddress(addr); |
| 103 | } |
| 104 | |
| 105 | break_id_t |
| 106 | Breakpoint::FindLocationIDByAddress (Address &addr) |
| 107 | { |
| 108 | return m_locations.FindIDByAddress(addr); |
| 109 | } |
| 110 | |
| 111 | BreakpointLocationSP |
| 112 | Breakpoint::FindLocationByID (break_id_t bp_loc_id) |
| 113 | { |
| 114 | return m_locations.FindByID(bp_loc_id); |
| 115 | } |
| 116 | |
| 117 | BreakpointLocationSP |
| 118 | Breakpoint::GetLocationAtIndex (uint32_t index) |
| 119 | { |
| 120 | return m_locations.GetByIndex(index); |
| 121 | } |
| 122 | |
| 123 | BreakpointLocationSP |
| 124 | Breakpoint::GetLocationSP (BreakpointLocation *bp_loc_ptr) |
| 125 | { |
| 126 | assert (bp_loc_ptr->GetBreakpoint().GetID() == GetID()); |
| 127 | return m_locations.FindByID(bp_loc_ptr->GetID()); |
| 128 | } |
| 129 | |
| 130 | |
| 131 | // For each of the overall options we need to decide how they propagate to |
| 132 | // the location options. This will determine the precedence of options on |
| 133 | // the breakpoint vrs. its locations. |
| 134 | |
| 135 | // Disable at the breakpoint level should override the location settings. |
| 136 | // That way you can conveniently turn off a whole breakpoint without messing |
| 137 | // up the individual settings. |
| 138 | |
| 139 | void |
| 140 | Breakpoint::SetEnabled (bool enable) |
| 141 | { |
| 142 | m_options.SetEnabled(enable); |
| 143 | if (enable) |
| 144 | m_locations.ResolveAllBreakpointSites(); |
| 145 | else |
| 146 | m_locations.ClearAllBreakpointSites(); |
| 147 | } |
| 148 | |
| 149 | bool |
| 150 | Breakpoint::IsEnabled () |
| 151 | { |
| 152 | return m_options.IsEnabled(); |
| 153 | } |
| 154 | |
| 155 | void |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 156 | Breakpoint::SetIgnoreCount (uint32_t n) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 157 | { |
| 158 | m_options.SetIgnoreCount(n); |
| 159 | } |
| 160 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 161 | uint32_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 162 | Breakpoint::GetIgnoreCount () const |
| 163 | { |
| 164 | return m_options.GetIgnoreCount(); |
| 165 | } |
| 166 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 167 | uint32_t |
| 168 | Breakpoint::GetHitCount () const |
| 169 | { |
| 170 | return m_locations.GetHitCount(); |
| 171 | } |
| 172 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 173 | void |
| 174 | Breakpoint::SetThreadID (lldb::tid_t thread_id) |
| 175 | { |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 176 | m_options.GetThreadSpec()->SetTID(thread_id); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | lldb::tid_t |
| 180 | Breakpoint::GetThreadID () |
| 181 | { |
Jim Ingham | 3c7b5b9 | 2010-06-16 02:00:15 +0000 | [diff] [blame] | 182 | if (m_options.GetThreadSpec() == NULL) |
| 183 | return LLDB_INVALID_THREAD_ID; |
| 184 | else |
| 185 | return m_options.GetThreadSpec()->GetTID(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Jim Ingham | d168690 | 2010-10-14 23:45:03 +0000 | [diff] [blame] | 188 | void |
| 189 | Breakpoint::SetCondition (const char *condition) |
| 190 | { |
| 191 | m_options.SetCondition (condition); |
| 192 | } |
| 193 | |
| 194 | ThreadPlan * |
| 195 | Breakpoint::GetThreadPlanToTestCondition (ExecutionContext &exe_ctx, lldb::BreakpointLocationSP loc_sp, Stream &error) |
| 196 | { |
| 197 | return m_options.GetThreadPlanToTestCondition (exe_ctx, loc_sp, error); |
| 198 | } |
| 199 | |
| 200 | const char * |
| 201 | Breakpoint::GetConditionText () |
| 202 | { |
| 203 | return m_options.GetConditionText(); |
| 204 | } |
| 205 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 206 | // This function is used when "baton" doesn't need to be freed |
| 207 | void |
| 208 | Breakpoint::SetCallback (BreakpointHitCallback callback, void *baton, bool is_synchronous) |
| 209 | { |
| 210 | // The default "Baton" class will keep a copy of "baton" and won't free |
| 211 | // or delete it when it goes goes out of scope. |
| 212 | m_options.SetCallback(callback, BatonSP (new Baton(baton)), is_synchronous); |
| 213 | } |
| 214 | |
| 215 | // This function is used when a baton needs to be freed and therefore is |
| 216 | // contained in a "Baton" subclass. |
| 217 | void |
| 218 | Breakpoint::SetCallback (BreakpointHitCallback callback, const BatonSP &callback_baton_sp, bool is_synchronous) |
| 219 | { |
| 220 | m_options.SetCallback(callback, callback_baton_sp, is_synchronous); |
| 221 | } |
| 222 | |
| 223 | void |
| 224 | Breakpoint::ClearCallback () |
| 225 | { |
| 226 | m_options.ClearCallback (); |
| 227 | } |
| 228 | |
| 229 | bool |
| 230 | Breakpoint::InvokeCallback (StoppointCallbackContext *context, break_id_t bp_loc_id) |
| 231 | { |
| 232 | return m_options.InvokeCallback (context, GetID(), bp_loc_id); |
| 233 | } |
| 234 | |
| 235 | BreakpointOptions * |
| 236 | Breakpoint::GetOptions () |
| 237 | { |
| 238 | return &m_options; |
| 239 | } |
| 240 | |
| 241 | void |
| 242 | Breakpoint::ResolveBreakpoint () |
| 243 | { |
| 244 | if (m_resolver_sp) |
| 245 | m_resolver_sp->ResolveBreakpoint(*m_filter_sp); |
| 246 | } |
| 247 | |
| 248 | void |
| 249 | Breakpoint::ResolveBreakpointInModules (ModuleList &module_list) |
| 250 | { |
| 251 | if (m_resolver_sp) |
| 252 | m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list); |
| 253 | } |
| 254 | |
| 255 | void |
| 256 | Breakpoint::ClearAllBreakpointSites () |
| 257 | { |
| 258 | m_locations.ClearAllBreakpointSites(); |
| 259 | } |
| 260 | |
| 261 | //---------------------------------------------------------------------- |
| 262 | // ModulesChanged: Pass in a list of new modules, and |
| 263 | //---------------------------------------------------------------------- |
| 264 | |
| 265 | void |
| 266 | Breakpoint::ModulesChanged (ModuleList &module_list, bool load) |
| 267 | { |
| 268 | if (load) |
| 269 | { |
| 270 | // The logic for handling new modules is: |
| 271 | // 1) If the filter rejects this module, then skip it. |
| 272 | // 2) Run through the current location list and if there are any locations |
| 273 | // for that module, we mark the module as "seen" and we don't try to re-resolve |
| 274 | // breakpoint locations for that module. |
| 275 | // However, we do add breakpoint sites to these locations if needed. |
| 276 | // 3) If we don't see this module in our breakpoint location list, call ResolveInModules. |
| 277 | |
| 278 | ModuleList new_modules; // We'll stuff the "unseen" modules in this list, and then resolve |
| 279 | // them after the locations pass. Have to do it this way because |
| 280 | // resolving breakpoints will add new locations potentially. |
| 281 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 282 | for (size_t i = 0; i < module_list.GetSize(); i++) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 283 | { |
| 284 | bool seen = false; |
| 285 | ModuleSP module_sp (module_list.GetModuleAtIndex (i)); |
| 286 | Module *module = module_sp.get(); |
| 287 | if (!m_filter_sp->ModulePasses (module_sp)) |
| 288 | continue; |
| 289 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 290 | for (size_t j = 0; j < m_locations.GetSize(); j++) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 291 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 292 | BreakpointLocationSP break_loc = m_locations.GetByIndex(j); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 293 | const Section *section = break_loc->GetAddress().GetSection(); |
| 294 | if (section == NULL || section->GetModule() == module) |
| 295 | { |
| 296 | if (!seen) |
| 297 | seen = true; |
| 298 | |
| 299 | if (!break_loc->ResolveBreakpointSite()) |
| 300 | { |
| 301 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); |
| 302 | if (log) |
| 303 | log->Printf ("Warning: could not set breakpoint site for breakpoint location %d of breakpoint %d.\n", |
| 304 | break_loc->GetID(), GetID()); |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | if (!seen) |
| 310 | new_modules.AppendInNeeded (module_sp); |
| 311 | |
| 312 | } |
| 313 | if (new_modules.GetSize() > 0) |
| 314 | { |
| 315 | ResolveBreakpointInModules(new_modules); |
| 316 | } |
| 317 | } |
| 318 | else |
| 319 | { |
| 320 | // Go through the currently set locations and if any have breakpoints in |
| 321 | // the module list, then remove their breakpoint sites. |
| 322 | // FIXME: Think about this... Maybe it's better to delete the locations? |
| 323 | // Are we sure that on load-unload-reload the module pointer will remain |
| 324 | // the same? Or do we need to do an equality on modules that is an |
| 325 | // "equivalence"??? |
| 326 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 327 | for (size_t i = 0; i < module_list.GetSize(); i++) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 328 | { |
| 329 | ModuleSP module_sp (module_list.GetModuleAtIndex (i)); |
| 330 | if (!m_filter_sp->ModulePasses (module_sp)) |
| 331 | continue; |
| 332 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 333 | for (size_t j = 0; j < m_locations.GetSize(); j++) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 334 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 335 | BreakpointLocationSP break_loc = m_locations.GetByIndex(j); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 336 | const Section *section = break_loc->GetAddress().GetSection(); |
| 337 | if (section) |
| 338 | { |
| 339 | if (section->GetModule() == module_sp.get()) |
| 340 | break_loc->ClearBreakpointSite(); |
| 341 | } |
| 342 | // else |
| 343 | // { |
| 344 | // Address temp_addr; |
| 345 | // if (module->ResolveLoadAddress(break_loc->GetLoadAddress(), m_target->GetProcess(), temp_addr)) |
| 346 | // break_loc->ClearBreakpointSite(); |
| 347 | // } |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | void |
| 354 | Breakpoint::Dump (Stream *) |
| 355 | { |
| 356 | } |
| 357 | |
| 358 | size_t |
| 359 | Breakpoint::GetNumResolvedLocations() const |
| 360 | { |
| 361 | // Return the number of breakpoints that are actually resolved and set |
| 362 | // down in the inferior process. |
| 363 | return m_locations.GetNumResolvedLocations(); |
| 364 | } |
| 365 | |
| 366 | size_t |
| 367 | Breakpoint::GetNumLocations() const |
| 368 | { |
| 369 | return m_locations.GetSize(); |
| 370 | } |
| 371 | |
| 372 | void |
| 373 | Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations) |
| 374 | { |
| 375 | assert (s != NULL); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 376 | s->Printf("%i: ", GetID()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 377 | GetResolverDescription (s); |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 378 | GetFilterDescription (s); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 379 | |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 380 | const size_t num_locations = GetNumLocations (); |
| 381 | const size_t num_resolved_locations = GetNumResolvedLocations (); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 382 | |
| 383 | switch (level) |
| 384 | { |
| 385 | case lldb::eDescriptionLevelBrief: |
| 386 | case lldb::eDescriptionLevelFull: |
| 387 | if (num_locations > 0) |
| 388 | { |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 389 | s->Printf(", locations = %zu", num_locations); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 390 | if (num_resolved_locations > 0) |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 391 | s->Printf(", resolved = %zu", num_resolved_locations); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 392 | } |
| 393 | else |
| 394 | { |
Greg Clayton | 12bec71 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 395 | s->Printf(", locations = 0 (pending)"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Jim Ingham | 649492b | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 398 | GetOptions()->GetDescription(s, level); |
| 399 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 400 | if (level == lldb::eDescriptionLevelFull) |
| 401 | { |
Jim Ingham | 649492b | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 402 | s->IndentLess(); |
| 403 | s->EOL(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 404 | } |
| 405 | break; |
| 406 | |
| 407 | case lldb::eDescriptionLevelVerbose: |
| 408 | // Verbose mode does a debug dump of the breakpoint |
| 409 | Dump (s); |
Jim Ingham | 649492b | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 410 | s->EOL (); |
| 411 | s->Indent(); |
| 412 | GetOptions()->GetDescription(s, level); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 413 | break; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 414 | |
| 415 | default: |
| 416 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | if (show_locations) |
| 420 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 421 | s->IndentMore(); |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 422 | for (size_t i = 0; i < num_locations; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 423 | { |
| 424 | BreakpointLocation *loc = GetLocationAtIndex(i).get(); |
| 425 | loc->GetDescription(s, level); |
| 426 | s->EOL(); |
| 427 | } |
| 428 | s->IndentLess(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 429 | } |
| 430 | } |
| 431 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 432 | Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_type, |
Jim Ingham | 649492b | 2010-06-18 01:00:58 +0000 | [diff] [blame] | 433 | BreakpointSP &new_breakpoint_sp) : |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 434 | EventData (), |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 435 | m_breakpoint_event (sub_type), |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 436 | m_new_breakpoint_sp (new_breakpoint_sp) |
| 437 | { |
| 438 | } |
| 439 | |
| 440 | Breakpoint::BreakpointEventData::~BreakpointEventData () |
| 441 | { |
| 442 | } |
| 443 | |
| 444 | const ConstString & |
| 445 | Breakpoint::BreakpointEventData::GetFlavorString () |
| 446 | { |
| 447 | static ConstString g_flavor ("Breakpoint::BreakpointEventData"); |
| 448 | return g_flavor; |
| 449 | } |
| 450 | |
| 451 | const ConstString & |
| 452 | Breakpoint::BreakpointEventData::GetFlavor () const |
| 453 | { |
| 454 | return BreakpointEventData::GetFlavorString (); |
| 455 | } |
| 456 | |
| 457 | |
| 458 | BreakpointSP & |
| 459 | Breakpoint::BreakpointEventData::GetBreakpoint () |
| 460 | { |
| 461 | return m_new_breakpoint_sp; |
| 462 | } |
| 463 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 464 | BreakpointEventType |
| 465 | Breakpoint::BreakpointEventData::GetBreakpointEventType () const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 466 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 467 | return m_breakpoint_event; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | void |
| 471 | Breakpoint::BreakpointEventData::Dump (Stream *s) const |
| 472 | { |
| 473 | } |
| 474 | |
| 475 | Breakpoint::BreakpointEventData * |
| 476 | Breakpoint::BreakpointEventData::GetEventDataFromEvent (const EventSP &event_sp) |
| 477 | { |
| 478 | if (event_sp) |
| 479 | { |
| 480 | EventData *event_data = event_sp->GetData(); |
| 481 | if (event_data && event_data->GetFlavor() == BreakpointEventData::GetFlavorString()) |
| 482 | return static_cast <BreakpointEventData *> (event_sp->GetData()); |
| 483 | } |
| 484 | return NULL; |
| 485 | } |
| 486 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 487 | BreakpointEventType |
| 488 | Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP &event_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 489 | { |
| 490 | BreakpointEventData *data = GetEventDataFromEvent (event_sp); |
| 491 | |
| 492 | if (data == NULL) |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 493 | return eBreakpointEventTypeInvalidType; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 494 | else |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 495 | return data->GetBreakpointEventType(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | BreakpointSP |
| 499 | Breakpoint::BreakpointEventData::GetBreakpointFromEvent (const EventSP &event_sp) |
| 500 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 501 | BreakpointSP bp_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 502 | |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 503 | BreakpointEventData *data = GetEventDataFromEvent (event_sp); |
| 504 | if (data) |
| 505 | bp_sp = data->GetBreakpoint(); |
| 506 | |
| 507 | return bp_sp; |
| 508 | } |
| 509 | |
| 510 | lldb::BreakpointLocationSP |
| 511 | Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t bp_loc_idx) |
| 512 | { |
| 513 | lldb::BreakpointLocationSP bp_loc_sp; |
| 514 | |
| 515 | BreakpointEventData *data = GetEventDataFromEvent (event_sp); |
| 516 | if (data) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 517 | { |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 518 | Breakpoint *bp = data->GetBreakpoint().get(); |
| 519 | if (bp) |
| 520 | bp_loc_sp = bp->GetLocationAtIndex(bp_loc_idx); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 521 | } |
Greg Clayton | c7f5d5c | 2010-07-23 23:33:17 +0000 | [diff] [blame] | 522 | |
| 523 | return bp_loc_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | |
| 527 | void |
| 528 | Breakpoint::GetResolverDescription (Stream *s) |
| 529 | { |
| 530 | if (m_resolver_sp) |
| 531 | m_resolver_sp->GetDescription (s); |
| 532 | } |
| 533 | |
| 534 | void |
| 535 | Breakpoint::GetFilterDescription (Stream *s) |
| 536 | { |
| 537 | m_filter_sp->GetDescription (s); |
| 538 | } |
| 539 | |
| 540 | const BreakpointSP |
| 541 | Breakpoint::GetSP () |
| 542 | { |
| 543 | return m_target.GetBreakpointList().FindBreakpointByID (GetID()); |
| 544 | } |