blob: c422a1d290bc5c299e0b6c9ef1853d92154c36e9 [file] [log] [blame]
Greg Clayton643ee732010-08-04 01:40:35 +00001//===-- StopInfo.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#include "lldb/Target/StopInfo.h"
11
12// C Includes
13// C++ Includes
14#include <string>
15
16// Other libraries and framework includes
17// Project includes
18#include "lldb/Core/Log.h"
Greg Clayton640dc6b2010-11-18 18:52:36 +000019#include "lldb/Breakpoint/Breakpoint.h"
Greg Clayton643ee732010-08-04 01:40:35 +000020#include "lldb/Breakpoint/BreakpointLocation.h"
21#include "lldb/Breakpoint/StoppointCallbackContext.h"
Johnny Chenecd4feb2011-10-14 00:42:25 +000022#include "lldb/Breakpoint/Watchpoint.h"
Jim Ingham21f37ad2011-08-09 02:12:22 +000023#include "lldb/Core/Debugger.h"
Greg Clayton643ee732010-08-04 01:40:35 +000024#include "lldb/Core/StreamString.h"
Jim Ingham21f37ad2011-08-09 02:12:22 +000025#include "lldb/Expression/ClangUserExpression.h"
26#include "lldb/Target/Target.h"
Greg Clayton643ee732010-08-04 01:40:35 +000027#include "lldb/Target/Thread.h"
28#include "lldb/Target/ThreadPlan.h"
29#include "lldb/Target/Process.h"
30#include "lldb/Target/UnixSignals.h"
31
32using namespace lldb;
33using namespace lldb_private;
34
35StopInfo::StopInfo (Thread &thread, uint64_t value) :
36 m_thread (thread),
37 m_stop_id (thread.GetProcess().GetStopID()),
38 m_value (value)
39{
40}
41
42bool
43StopInfo::IsValid () const
44{
45 return m_thread.GetProcess().GetStopID() == m_stop_id;
46}
47
Jim Ingham15dcb7c2011-01-20 02:03:18 +000048void
49StopInfo::MakeStopInfoValid ()
50{
51 m_stop_id = m_thread.GetProcess().GetStopID();
52}
53
Jim Ingham21f37ad2011-08-09 02:12:22 +000054lldb::StateType
55StopInfo::GetPrivateState ()
56{
57 return m_thread.GetProcess().GetPrivateState();
58}
59
Greg Clayton643ee732010-08-04 01:40:35 +000060//----------------------------------------------------------------------
61// StopInfoBreakpoint
62//----------------------------------------------------------------------
63
Jim Ingham21f37ad2011-08-09 02:12:22 +000064namespace lldb_private
65{
Greg Clayton643ee732010-08-04 01:40:35 +000066class StopInfoBreakpoint : public StopInfo
67{
68public:
69
70 StopInfoBreakpoint (Thread &thread, break_id_t break_id) :
71 StopInfo (thread, break_id),
72 m_description(),
73 m_should_stop (false),
Jim Inghamf9f40c22011-02-08 05:20:59 +000074 m_should_stop_is_valid (false),
75 m_should_perform_action (true)
Greg Clayton643ee732010-08-04 01:40:35 +000076 {
77 }
78
Jim Inghamd1686902010-10-14 23:45:03 +000079 StopInfoBreakpoint (Thread &thread, break_id_t break_id, bool should_stop) :
80 StopInfo (thread, break_id),
81 m_description(),
82 m_should_stop (should_stop),
Jim Inghamf9f40c22011-02-08 05:20:59 +000083 m_should_stop_is_valid (true),
84 m_should_perform_action (true)
Jim Inghamd1686902010-10-14 23:45:03 +000085 {
86 }
87
Greg Clayton643ee732010-08-04 01:40:35 +000088 virtual ~StopInfoBreakpoint ()
89 {
90 }
91
92 virtual StopReason
93 GetStopReason () const
94 {
95 return eStopReasonBreakpoint;
96 }
97
98 virtual bool
99 ShouldStop (Event *event_ptr)
100 {
101 if (!m_should_stop_is_valid)
102 {
103 // Only check once if we should stop at a breakpoint
104 BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
105 if (bp_site_sp)
106 {
107 StoppointCallbackContext context (event_ptr,
108 &m_thread.GetProcess(),
109 &m_thread,
110 m_thread.GetStackFrameAtIndex(0).get(),
Jim Ingham7508e732010-08-09 23:31:02 +0000111 true);
Greg Clayton643ee732010-08-04 01:40:35 +0000112
113 m_should_stop = bp_site_sp->ShouldStop (&context);
114 }
115 else
116 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000117 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
Greg Clayton643ee732010-08-04 01:40:35 +0000118
119 if (log)
120 log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
121
122 m_should_stop = true;
123 }
124 m_should_stop_is_valid = true;
125 }
126 return m_should_stop;
127 }
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000128
129 virtual void
130 PerformAction (Event *event_ptr)
131 {
Jim Inghamf9f40c22011-02-08 05:20:59 +0000132 if (!m_should_perform_action)
133 return;
134 m_should_perform_action = false;
135
Jim Ingham21f37ad2011-08-09 02:12:22 +0000136 LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
137 // We're going to calculate whether we should stop or not in some way during the course of
138 // this code. So set the valid flag here. Also by default we're going to stop, so
139 // set that here too.
140 // m_should_stop_is_valid = true;
141 m_should_stop = true;
142
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000143 BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
144 if (bp_site_sp)
145 {
146 size_t num_owners = bp_site_sp->GetNumberOfOwners();
Jim Ingham21f37ad2011-08-09 02:12:22 +0000147
148 // We only continue from the callbacks if ALL the callbacks want us to continue.
149 // However we want to run all the callbacks, except of course if one of them actually
150 // resumes the target.
151 // So we use stop_requested to track what we're were asked to do.
152 bool stop_requested = true;
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000153 for (size_t j = 0; j < num_owners; j++)
154 {
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000155 lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
156 StoppointCallbackContext context (event_ptr,
157 &m_thread.GetProcess(),
158 &m_thread,
159 m_thread.GetStackFrameAtIndex(0).get(),
160 false);
Jim Ingham21f37ad2011-08-09 02:12:22 +0000161 stop_requested = bp_loc_sp->InvokeCallback (&context);
162 // Also make sure that the callback hasn't continued the target.
163 // If it did, when we'll set m_should_start to false and get out of here.
164 if (GetPrivateState() == eStateRunning)
165 m_should_stop = false;
166 }
167
168 if (m_should_stop && !stop_requested)
169 {
170 m_should_stop_is_valid = true;
171 m_should_stop = false;
172 }
173
174 // Okay, so now if all the callbacks say we should stop, let's try the Conditions:
175 if (m_should_stop)
176 {
177 size_t num_owners = bp_site_sp->GetNumberOfOwners();
178 for (size_t j = 0; j < num_owners; j++)
179 {
180 lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
181 if (bp_loc_sp->GetConditionText() != NULL)
182 {
183 // We need to make sure the user sees any parse errors in their condition, so we'll hook the
184 // constructor errors up to the debugger's Async I/O.
185
186 StoppointCallbackContext context (event_ptr,
187 &m_thread.GetProcess(),
188 &m_thread,
189 m_thread.GetStackFrameAtIndex(0).get(),
190 false);
191 ValueObjectSP result_valobj_sp;
192
193 ExecutionResults result_code;
194 ValueObjectSP result_value_sp;
195 const bool discard_on_error = true;
196 Error error;
197 result_code = ClangUserExpression::EvaluateWithError (context.exe_ctx,
Sean Callanan47dc4572011-09-15 02:13:07 +0000198 eExecutionPolicyAlways,
199 discard_on_error,
200 bp_loc_sp->GetConditionText(),
201 NULL,
202 result_value_sp,
203 error);
Jim Ingham21f37ad2011-08-09 02:12:22 +0000204 if (result_code == eExecutionCompleted)
205 {
206 if (result_value_sp)
207 {
208 Scalar scalar_value;
209 if (result_value_sp->ResolveValue (scalar_value))
210 {
211 if (scalar_value.ULongLong(1) == 0)
212 m_should_stop = false;
213 else
214 m_should_stop = true;
215 if (log)
216 log->Printf("Condition successfully evaluated, result is %s.\n",
217 m_should_stop ? "true" : "false");
218 }
219 else
220 {
221 m_should_stop = true;
222 if (log)
223 log->Printf("Failed to get an integer result from the expression.");
224 }
225 }
226 }
227 else
228 {
Greg Clayton567e7f32011-09-22 04:58:26 +0000229 Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger();
Jim Ingham21f37ad2011-08-09 02:12:22 +0000230 StreamSP error_sp = debugger.GetAsyncErrorStream ();
231 error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint ");
232 bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
233 error_sp->Printf (": \"%s\"",
234 bp_loc_sp->GetConditionText());
235 error_sp->EOL();
236 const char *err_str = error.AsCString("<Unknown Error>");
237 if (log)
238 log->Printf("Error evaluating condition: \"%s\"\n", err_str);
239
240 error_sp->PutCString (err_str);
241 error_sp->EOL();
242 error_sp->Flush();
243 // If the condition fails to be parsed or run, we should stop.
244 m_should_stop = true;
245 }
246 }
247
248 // If any condition says we should stop, then we're going to stop, so we don't need
249 // to evaluate the others.
250 if (m_should_stop)
251 break;
252 }
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000253 }
254 }
255 else
256 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000257 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000258
259 if (log)
260 log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
261 }
Jim Ingham21f37ad2011-08-09 02:12:22 +0000262 if (log)
263 log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000264 }
Greg Clayton643ee732010-08-04 01:40:35 +0000265
266 virtual bool
267 ShouldNotify (Event *event_ptr)
268 {
269 BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
270 if (bp_site_sp)
271 {
272 bool all_internal = true;
273
274 for (uint32_t i = 0; i < bp_site_sp->GetNumberOfOwners(); i++)
275 {
276 if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal())
277 {
278 all_internal = false;
279 break;
280 }
281 }
282 return all_internal == false;
283 }
284 return true;
285 }
286
287 virtual const char *
288 GetDescription ()
289 {
290 if (m_description.empty())
291 {
Jim Ingham6fb8baa2010-08-10 00:59:59 +0000292 BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
293 if (bp_site_sp)
294 {
295 StreamString strm;
296 strm.Printf("breakpoint ");
297 bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
298 m_description.swap (strm.GetString());
299 }
300 else
301 {
302 StreamString strm;
303 strm.Printf("breakpoint site %lli", m_value);
304 m_description.swap (strm.GetString());
305 }
Greg Clayton643ee732010-08-04 01:40:35 +0000306 }
307 return m_description.c_str();
308 }
309
310private:
311 std::string m_description;
312 bool m_should_stop;
313 bool m_should_stop_is_valid;
Jim Inghamf9f40c22011-02-08 05:20:59 +0000314 bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions
315 // etc. behind the users backs, we need to make sure we only REALLY perform the action once.
Greg Clayton643ee732010-08-04 01:40:35 +0000316};
317
318
319//----------------------------------------------------------------------
320// StopInfoWatchpoint
321//----------------------------------------------------------------------
322
323class StopInfoWatchpoint : public StopInfo
324{
325public:
326
327 StopInfoWatchpoint (Thread &thread, break_id_t watch_id) :
Johnny Chen043f8c22011-09-21 22:47:15 +0000328 StopInfo(thread, watch_id),
329 m_description(),
330 m_should_stop(false),
331 m_should_stop_is_valid(false)
Greg Clayton643ee732010-08-04 01:40:35 +0000332 {
333 }
334
335 virtual ~StopInfoWatchpoint ()
336 {
337 }
338
339 virtual StopReason
340 GetStopReason () const
341 {
342 return eStopReasonWatchpoint;
343 }
344
Johnny Chen043f8c22011-09-21 22:47:15 +0000345 virtual bool
346 ShouldStop (Event *event_ptr)
347 {
348 // ShouldStop() method is idempotent and should not affect hit count.
Johnny Chen712a6282011-10-17 18:58:00 +0000349 // See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent()
350 // -->Process()::ShouldBroadcastEvent()->ThreadList::ShouldStop()->
351 // Thread::ShouldStop()->ThreadPlanBase::ShouldStop()->
352 // StopInfoWatchpoint::ShouldStop() and
353 // Event::DoOnRemoval()->Process::ProcessEventData::DoOnRemoval()->
354 // StopInfoWatchpoint::PerformAction().
Johnny Chen043f8c22011-09-21 22:47:15 +0000355 if (m_should_stop_is_valid)
356 return m_should_stop;
357
Johnny Chenecd4feb2011-10-14 00:42:25 +0000358 WatchpointSP wp_sp =
359 m_thread.GetProcess().GetTarget().GetWatchpointList().FindByID(GetValue());
360 if (wp_sp)
Johnny Chen043f8c22011-09-21 22:47:15 +0000361 {
362 // Check if we should stop at a watchpoint.
363 StoppointCallbackContext context (event_ptr,
364 &m_thread.GetProcess(),
365 &m_thread,
366 m_thread.GetStackFrameAtIndex(0).get(),
367 true);
368
Johnny Chenecd4feb2011-10-14 00:42:25 +0000369 m_should_stop = wp_sp->ShouldStop (&context);
Johnny Chen043f8c22011-09-21 22:47:15 +0000370 }
371 else
372 {
373 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
374
375 if (log)
376 log->Printf ("Process::%s could not find watchpoint location id: %lld...",
377 __FUNCTION__, GetValue());
378
379 m_should_stop = true;
380 }
381 m_should_stop_is_valid = true;
382 return m_should_stop;
383 }
384
Johnny Chen712a6282011-10-17 18:58:00 +0000385 // Perform any action that is associated with this stop. This is done as the
386 // Event is removed from the event queue.
387 virtual void
388 PerformAction (Event *event_ptr)
389 {
390 LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
391 // We're going to calculate if we should stop or not in some way during the course of
392 // this code. Also by default we're going to stop, so set that here.
393 m_should_stop = true;
394
395 WatchpointSP wp_sp =
396 m_thread.GetProcess().GetTarget().GetWatchpointList().FindByID(GetValue());
397 if (wp_sp)
398 {
399 StoppointCallbackContext context (event_ptr,
400 &m_thread.GetProcess(),
401 &m_thread,
402 m_thread.GetStackFrameAtIndex(0).get(),
403 false);
404 bool stop_requested = wp_sp->InvokeCallback (&context);
405 // Also make sure that the callback hasn't continued the target.
406 // If it did, when we'll set m_should_start to false and get out of here.
407 if (GetPrivateState() == eStateRunning)
408 m_should_stop = false;
409
410 if (m_should_stop && !stop_requested)
411 {
412 // We have been vetoed.
413 m_should_stop = false;
414 }
415
416 if (m_should_stop && wp_sp->GetConditionText() != NULL)
417 {
418 // We need to make sure the user sees any parse errors in their condition, so we'll hook the
419 // constructor errors up to the debugger's Async I/O.
420 StoppointCallbackContext context (event_ptr,
421 &m_thread.GetProcess(),
422 &m_thread,
423 m_thread.GetStackFrameAtIndex(0).get(),
424 false);
425 ExecutionResults result_code;
426 ValueObjectSP result_value_sp;
427 const bool discard_on_error = true;
428 Error error;
429 result_code = ClangUserExpression::EvaluateWithError (context.exe_ctx,
430 eExecutionPolicyAlways,
431 discard_on_error,
432 wp_sp->GetConditionText(),
433 NULL,
434 result_value_sp,
435 error);
436 if (result_code == eExecutionCompleted)
437 {
438 if (result_value_sp)
439 {
440 Scalar scalar_value;
441 if (result_value_sp->ResolveValue (scalar_value))
442 {
443 if (scalar_value.ULongLong(1) == 0)
444 {
445 // We have been vetoed. This takes precedence over querying
446 // the watchpoint whether it should stop (aka ignore count and
447 // friends). See also StopInfoWatchpoint::ShouldStop() as well
448 // as Process::ProcessEventData::DoOnRemoval().
449 m_should_stop = false;
450 }
451 else
452 m_should_stop = true;
453 if (log)
454 log->Printf("Condition successfully evaluated, result is %s.\n",
455 m_should_stop ? "true" : "false");
456 }
457 else
458 {
459 m_should_stop = true;
460 if (log)
461 log->Printf("Failed to get an integer result from the expression.");
462 }
463 }
464 }
465 else
466 {
467 Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger();
468 StreamSP error_sp = debugger.GetAsyncErrorStream ();
469 error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint ");
470 wp_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
471 error_sp->Printf (": \"%s\"",
472 wp_sp->GetConditionText());
473 error_sp->EOL();
474 const char *err_str = error.AsCString("<Unknown Error>");
475 if (log)
476 log->Printf("Error evaluating condition: \"%s\"\n", err_str);
477
478 error_sp->PutCString (err_str);
479 error_sp->EOL();
480 error_sp->Flush();
481 // If the condition fails to be parsed or run, we should stop.
482 m_should_stop = true;
483 }
484 }
485 }
486 else
487 {
488 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
489
490 if (log)
491 log->Printf ("Process::%s could not find watchpoint id: %lld...", __FUNCTION__, m_value);
492 }
493 if (log)
494 log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
495 }
496
Greg Clayton643ee732010-08-04 01:40:35 +0000497 virtual const char *
498 GetDescription ()
499 {
500 if (m_description.empty())
501 {
502 StreamString strm;
503 strm.Printf("watchpoint %lli", m_value);
504 m_description.swap (strm.GetString());
505 }
506 return m_description.c_str();
507 }
508
Greg Clayton643ee732010-08-04 01:40:35 +0000509private:
510 std::string m_description;
Johnny Chen043f8c22011-09-21 22:47:15 +0000511 bool m_should_stop;
512 bool m_should_stop_is_valid;
Greg Clayton643ee732010-08-04 01:40:35 +0000513};
514
515
516
517//----------------------------------------------------------------------
518// StopInfoUnixSignal
519//----------------------------------------------------------------------
520
521class StopInfoUnixSignal : public StopInfo
522{
523public:
524
525 StopInfoUnixSignal (Thread &thread, int signo) :
Greg Clayton65611552011-06-04 01:26:29 +0000526 StopInfo (thread, signo)
Greg Clayton643ee732010-08-04 01:40:35 +0000527 {
528 }
529
530 virtual ~StopInfoUnixSignal ()
531 {
532 }
533
534
535 virtual StopReason
536 GetStopReason () const
537 {
538 return eStopReasonSignal;
539 }
540
541 virtual bool
542 ShouldStop (Event *event_ptr)
543 {
544 return m_thread.GetProcess().GetUnixSignals().GetShouldStop (m_value);
545 }
546
547
548 // If should stop returns false, check if we should notify of this event
549 virtual bool
550 ShouldNotify (Event *event_ptr)
551 {
552 return m_thread.GetProcess().GetUnixSignals().GetShouldNotify (m_value);
553 }
554
555
556 virtual void
557 WillResume (lldb::StateType resume_state)
558 {
559 if (m_thread.GetProcess().GetUnixSignals().GetShouldSuppress(m_value) == false)
560 m_thread.SetResumeSignal(m_value);
561 }
562
563 virtual const char *
564 GetDescription ()
565 {
566 if (m_description.empty())
567 {
568 StreamString strm;
569 const char *signal_name = m_thread.GetProcess().GetUnixSignals().GetSignalAsCString (m_value);
570 if (signal_name)
Greg Claytona830adb2010-10-04 01:05:56 +0000571 strm.Printf("signal %s", signal_name);
Greg Clayton643ee732010-08-04 01:40:35 +0000572 else
Greg Claytona830adb2010-10-04 01:05:56 +0000573 strm.Printf("signal %lli", m_value);
Greg Clayton643ee732010-08-04 01:40:35 +0000574 m_description.swap (strm.GetString());
575 }
576 return m_description.c_str();
577 }
Greg Clayton643ee732010-08-04 01:40:35 +0000578};
579
580//----------------------------------------------------------------------
581// StopInfoTrace
582//----------------------------------------------------------------------
583
584class StopInfoTrace : public StopInfo
585{
586public:
587
588 StopInfoTrace (Thread &thread) :
589 StopInfo (thread, LLDB_INVALID_UID)
590 {
591 }
592
593 virtual ~StopInfoTrace ()
594 {
595 }
596
597 virtual StopReason
598 GetStopReason () const
599 {
600 return eStopReasonTrace;
601 }
602
603 virtual const char *
604 GetDescription ()
605 {
Greg Clayton65611552011-06-04 01:26:29 +0000606 if (m_description.empty())
Greg Clayton643ee732010-08-04 01:40:35 +0000607 return "trace";
Greg Clayton65611552011-06-04 01:26:29 +0000608 else
609 return m_description.c_str();
610 }
611};
612
613
614//----------------------------------------------------------------------
615// StopInfoException
616//----------------------------------------------------------------------
617
618class StopInfoException : public StopInfo
619{
620public:
621
622 StopInfoException (Thread &thread, const char *description) :
623 StopInfo (thread, LLDB_INVALID_UID)
624 {
625 if (description)
626 SetDescription (description);
627 }
628
629 virtual
630 ~StopInfoException ()
631 {
632 }
633
634 virtual StopReason
635 GetStopReason () const
636 {
637 return eStopReasonException;
638 }
639
640 virtual const char *
641 GetDescription ()
642 {
643 if (m_description.empty())
644 return "exception";
645 else
646 return m_description.c_str();
Greg Clayton643ee732010-08-04 01:40:35 +0000647 }
648};
649
650
651//----------------------------------------------------------------------
652// StopInfoThreadPlan
653//----------------------------------------------------------------------
654
655class StopInfoThreadPlan : public StopInfo
656{
657public:
658
659 StopInfoThreadPlan (ThreadPlanSP &plan_sp) :
660 StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
661 m_plan_sp (plan_sp)
662 {
663 }
664
665 virtual ~StopInfoThreadPlan ()
666 {
667 }
668
669 virtual StopReason
670 GetStopReason () const
671 {
672 return eStopReasonPlanComplete;
673 }
674
675 virtual const char *
676 GetDescription ()
677 {
678 if (m_description.empty())
679 {
680 StreamString strm;
681 m_plan_sp->GetDescription (&strm, eDescriptionLevelBrief);
682 m_description.swap (strm.GetString());
683 }
684 return m_description.c_str();
685 }
686
687private:
688 ThreadPlanSP m_plan_sp;
Greg Clayton643ee732010-08-04 01:40:35 +0000689};
Jim Ingham21f37ad2011-08-09 02:12:22 +0000690} // namespace lldb_private
Greg Clayton643ee732010-08-04 01:40:35 +0000691
692StopInfoSP
693StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id)
694{
695 return StopInfoSP (new StopInfoBreakpoint (thread, break_id));
696}
697
698StopInfoSP
Jim Inghamd1686902010-10-14 23:45:03 +0000699StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id, bool should_stop)
700{
701 return StopInfoSP (new StopInfoBreakpoint (thread, break_id, should_stop));
702}
703
704StopInfoSP
Greg Clayton643ee732010-08-04 01:40:35 +0000705StopInfo::CreateStopReasonWithWatchpointID (Thread &thread, break_id_t watch_id)
706{
707 return StopInfoSP (new StopInfoWatchpoint (thread, watch_id));
708}
709
710StopInfoSP
711StopInfo::CreateStopReasonWithSignal (Thread &thread, int signo)
712{
713 return StopInfoSP (new StopInfoUnixSignal (thread, signo));
714}
715
716StopInfoSP
717StopInfo::CreateStopReasonToTrace (Thread &thread)
718{
719 return StopInfoSP (new StopInfoTrace (thread));
720}
721
722StopInfoSP
723StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp)
724{
725 return StopInfoSP (new StopInfoThreadPlan (plan_sp));
726}
Greg Clayton65611552011-06-04 01:26:29 +0000727
728StopInfoSP
729StopInfo::CreateStopReasonWithException (Thread &thread, const char *description)
730{
731 return StopInfoSP (new StopInfoException (thread, description));
732}