1 //===-- 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"
19 #include "lldb/Breakpoint/Breakpoint.h"
20 #include "lldb/Breakpoint/BreakpointLocation.h"
21 #include "lldb/Breakpoint/StoppointCallbackContext.h"
22 #include "lldb/Breakpoint/Watchpoint.h"
23 #include "lldb/Core/Debugger.h"
24 #include "lldb/Core/StreamString.h"
25 #include "lldb/Expression/ClangUserExpression.h"
26 #include "lldb/Target/Target.h"
27 #include "lldb/Target/Thread.h"
28 #include "lldb/Target/ThreadPlan.h"
29 #include "lldb/Target/Process.h"
30 #include "lldb/Target/UnixSignals.h"
31 
32 using namespace lldb;
33 using namespace lldb_private;
34 
35 StopInfo::StopInfo (Thread &thread, uint64_t value) :
36     m_thread (thread),
37     m_stop_id (thread.GetProcess().GetStopID()),
38     m_resume_id (thread.GetProcess().GetResumeID()),
39     m_value (value)
40 {
41 }
42 
43 bool
44 StopInfo::IsValid () const
45 {
46     return m_thread.GetProcess().GetStopID() == m_stop_id;
47 }
48 
49 void
50 StopInfo::MakeStopInfoValid ()
51 {
52     m_stop_id = m_thread.GetProcess().GetStopID();
53     m_resume_id = m_thread.GetProcess().GetResumeID();
54 }
55 
56 bool
57 StopInfo::HasTargetRunSinceMe ()
58 {
59     lldb::StateType ret_type = m_thread.GetProcess().GetPrivateState();
60     if (ret_type == eStateRunning)
61     {
62         return true;
63     }
64     else if (ret_type == eStateStopped)
65     {
66         // This is a little tricky.  We want to count "run and stopped again before you could
67         // ask this question as a "TRUE" answer to HasTargetRunSinceMe.  But we don't want to
68         // include any running of the target done for expressions.  So we track both resumes,
69         // and resumes caused by expressions, and check if there are any resumes NOT caused
70         // by expressions.
71 
72         uint32_t curr_resume_id = m_thread.GetProcess().GetResumeID();
73         uint32_t last_user_expression_id = m_thread.GetProcess().GetLastUserExpressionResumeID ();
74         if (curr_resume_id == m_resume_id)
75         {
76             return false;
77         }
78         else if (curr_resume_id > last_user_expression_id)
79         {
80             return true;
81         }
82     }
83     return false;
84 }
85 
86 //----------------------------------------------------------------------
87 // StopInfoBreakpoint
88 //----------------------------------------------------------------------
89 
90 namespace lldb_private
91 {
92 class StopInfoBreakpoint : public StopInfo
93 {
94 public:
95 
96     StopInfoBreakpoint (Thread &thread, break_id_t break_id) :
97         StopInfo (thread, break_id),
98         m_description(),
99         m_should_stop (false),
100         m_should_stop_is_valid (false),
101         m_should_perform_action (true),
102         m_address (LLDB_INVALID_ADDRESS)
103     {
104         BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
105         if (bp_site_sp)
106         {
107           m_address = bp_site_sp->GetLoadAddress();
108         }
109     }
110 
111     StopInfoBreakpoint (Thread &thread, break_id_t break_id, bool should_stop) :
112         StopInfo (thread, break_id),
113         m_description(),
114         m_should_stop (should_stop),
115         m_should_stop_is_valid (true),
116         m_should_perform_action (true),
117         m_address (LLDB_INVALID_ADDRESS)
118     {
119         BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
120         if (bp_site_sp)
121         {
122           m_address = bp_site_sp->GetLoadAddress();
123         }
124     }
125 
126     virtual ~StopInfoBreakpoint ()
127     {
128     }
129 
130     virtual StopReason
131     GetStopReason () const
132     {
133         return eStopReasonBreakpoint;
134     }
135 
136     virtual bool
137     ShouldStop (Event *event_ptr)
138     {
139         if (!m_should_stop_is_valid)
140         {
141             // Only check once if we should stop at a breakpoint
142             BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
143             if (bp_site_sp)
144             {
145                 StoppointCallbackContext context (event_ptr,
146                                                   &m_thread.GetProcess(),
147                                                   &m_thread,
148                                                   m_thread.GetStackFrameAtIndex(0).get(),
149                                                   true);
150 
151                 m_should_stop = bp_site_sp->ShouldStop (&context);
152             }
153             else
154             {
155                 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
156 
157                 if (log)
158                     log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
159 
160                 m_should_stop = true;
161             }
162             m_should_stop_is_valid = true;
163         }
164         return m_should_stop;
165     }
166 
167     virtual void
168     PerformAction (Event *event_ptr)
169     {
170         if (!m_should_perform_action)
171             return;
172         m_should_perform_action = false;
173 
174         LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
175 
176         BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
177 
178         if (bp_site_sp)
179         {
180             size_t num_owners = bp_site_sp->GetNumberOfOwners();
181 
182             if (num_owners == 0)
183             {
184                 m_should_stop = true;
185             }
186             else
187             {
188                 // We go through each location, and test first its condition.  If the condition says to stop,
189                 // then we run the callback for that location.  If that callback says to stop as well, then
190                 // we set m_should_stop to true; we are going to stop.
191                 // But we still want to give all the breakpoints whose conditions say we are going to stop a
192                 // chance to run their callbacks.
193                 // Of course if any callback restarts the target by putting "continue" in the callback, then
194                 // we're going to restart, without running the rest of the callbacks.  And in this case we will
195                 // end up not stopping even if another location said we should stop.  But that's better than not
196                 // running all the callbacks.
197 
198                 m_should_stop = false;
199 
200                 StoppointCallbackContext context (event_ptr,
201                                                   &m_thread.GetProcess(),
202                                                   &m_thread,
203                                                   m_thread.GetStackFrameAtIndex(0).get(),
204                                                   false);
205 
206                 for (size_t j = 0; j < num_owners; j++)
207                 {
208                     lldb::BreakpointLocationSP bp_loc_sp = bp_site_sp->GetOwnerAtIndex(j);
209 
210                     // First run the condition for the breakpoint.  If that says we should stop, then we'll run
211                     // the callback for the breakpoint.  If the callback says we shouldn't stop that will win.
212 
213                     bool condition_says_stop = true;
214                     if (bp_loc_sp->GetConditionText() != NULL)
215                     {
216                         // We need to make sure the user sees any parse errors in their condition, so we'll hook the
217                         // constructor errors up to the debugger's Async I/O.
218 
219                         ValueObjectSP result_valobj_sp;
220 
221                         ExecutionResults result_code;
222                         ValueObjectSP result_value_sp;
223                         const bool discard_on_error = true;
224                         Error error;
225                         result_code = ClangUserExpression::EvaluateWithError (context.exe_ctx,
226                                                                               eExecutionPolicyAlways,
227                                                                               lldb::eLanguageTypeUnknown,
228                                                                               discard_on_error,
229                                                                               bp_loc_sp->GetConditionText(),
230                                                                               NULL,
231                                                                               result_value_sp,
232                                                                               error);
233                         if (result_code == eExecutionCompleted)
234                         {
235                             if (result_value_sp)
236                             {
237                                 Scalar scalar_value;
238                                 if (result_value_sp->ResolveValue (scalar_value))
239                                 {
240                                     if (scalar_value.ULongLong(1) == 0)
241                                         condition_says_stop = false;
242                                     else
243                                         condition_says_stop = true;
244                                     if (log)
245                                         log->Printf("Condition successfully evaluated, result is %s.\n",
246                                                     m_should_stop ? "true" : "false");
247                                 }
248                                 else
249                                 {
250                                     condition_says_stop = true;
251                                     if (log)
252                                         log->Printf("Failed to get an integer result from the expression.");
253                                 }
254                             }
255                         }
256                         else
257                         {
258                             Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger();
259                             StreamSP error_sp = debugger.GetAsyncErrorStream ();
260                             error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint ");
261                             bp_loc_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
262                             error_sp->Printf (": \"%s\"",
263                                               bp_loc_sp->GetConditionText());
264                             error_sp->EOL();
265                             const char *err_str = error.AsCString("<Unknown Error>");
266                             if (log)
267                                 log->Printf("Error evaluating condition: \"%s\"\n", err_str);
268 
269                             error_sp->PutCString (err_str);
270                             error_sp->EOL();
271                             error_sp->Flush();
272                             // If the condition fails to be parsed or run, we should stop.
273                             condition_says_stop = true;
274                         }
275                     }
276 
277                     // If this location's condition says we should aren't going to stop,
278                     // then don't run the callback for this location.
279                     if (!condition_says_stop)
280                         continue;
281 
282                     bool callback_says_stop;
283 
284                     // FIXME: For now the callbacks have to run in async mode - the first time we restart we need
285                     // to get out of there.  So set it here.
286                     // When we figure out how to nest breakpoint hits then this will change.
287 
288                     Debugger &debugger = m_thread.GetProcess().GetTarget().GetDebugger();
289                     bool old_async = debugger.GetAsyncExecution();
290                     debugger.SetAsyncExecution (true);
291 
292                     callback_says_stop = bp_loc_sp->InvokeCallback (&context);
293 
294                     debugger.SetAsyncExecution (old_async);
295 
296                     if (callback_says_stop)
297                         m_should_stop = true;
298 
299                     // Also make sure that the callback hasn't continued the target.
300                     // If it did, when we'll set m_should_start to false and get out of here.
301                     if (HasTargetRunSinceMe ())
302                     {
303                         m_should_stop = false;
304                         break;
305                     }
306                 }
307             }
308             // We've figured out what this stop wants to do, so mark it as valid so we don't compute it again.
309             m_should_stop_is_valid = true;
310 
311         }
312         else
313         {
314             m_should_stop = true;
315             m_should_stop_is_valid = true;
316             LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
317 
318             if (log)
319                 log->Printf ("Process::%s could not find breakpoint site id: %lld...", __FUNCTION__, m_value);
320         }
321         if (log)
322             log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
323     }
324 
325     virtual bool
326     ShouldNotify (Event *event_ptr)
327     {
328         BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
329         if (bp_site_sp)
330         {
331             bool all_internal = true;
332 
333             for (uint32_t i = 0; i < bp_site_sp->GetNumberOfOwners(); i++)
334             {
335                 if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal())
336                 {
337                     all_internal = false;
338                     break;
339                 }
340             }
341             return all_internal == false;
342         }
343         return true;
344     }
345 
346     virtual const char *
347     GetDescription ()
348     {
349         if (m_description.empty())
350         {
351             BreakpointSiteSP bp_site_sp (m_thread.GetProcess().GetBreakpointSiteList().FindByID (m_value));
352             if (bp_site_sp)
353             {
354                 StreamString strm;
355                 strm.Printf("breakpoint ");
356                 bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
357                 m_description.swap (strm.GetString());
358             }
359             else
360             {
361                 StreamString strm;
362                 if (m_address == LLDB_INVALID_ADDRESS)
363                     strm.Printf("breakpoint site %lli which has been deleted - unknown address", m_value);
364                 else
365                     strm.Printf("breakpoint site %lli which has been deleted - was at 0x%llx", m_value, m_address);
366                 m_description.swap (strm.GetString());
367             }
368         }
369         return m_description.c_str();
370     }
371 
372 private:
373     std::string m_description;
374     bool m_should_stop;
375     bool m_should_stop_is_valid;
376     bool m_should_perform_action; // Since we are trying to preserve the "state" of the system even if we run functions
377                                   // etc. behind the users backs, we need to make sure we only REALLY perform the action once.
378     lldb::addr_t m_address;       // We use this to capture the breakpoint site address when we create the StopInfo,
379                                   // in case somebody deletes it between the time the StopInfo is made and the
380                                   // description is asked for.
381 };
382 
383 
384 //----------------------------------------------------------------------
385 // StopInfoWatchpoint
386 //----------------------------------------------------------------------
387 
388 class StopInfoWatchpoint : public StopInfo
389 {
390 public:
391 
392     StopInfoWatchpoint (Thread &thread, break_id_t watch_id) :
393         StopInfo(thread, watch_id),
394         m_description(),
395         m_should_stop(false),
396         m_should_stop_is_valid(false)
397     {
398     }
399 
400     virtual ~StopInfoWatchpoint ()
401     {
402     }
403 
404     virtual StopReason
405     GetStopReason () const
406     {
407         return eStopReasonWatchpoint;
408     }
409 
410     virtual bool
411     ShouldStop (Event *event_ptr)
412     {
413         // ShouldStop() method is idempotent and should not affect hit count.
414         // See Process::RunPrivateStateThread()->Process()->HandlePrivateEvent()
415         // -->Process()::ShouldBroadcastEvent()->ThreadList::ShouldStop()->
416         // Thread::ShouldStop()->ThreadPlanBase::ShouldStop()->
417         // StopInfoWatchpoint::ShouldStop() and
418         // Event::DoOnRemoval()->Process::ProcessEventData::DoOnRemoval()->
419         // StopInfoWatchpoint::PerformAction().
420         if (m_should_stop_is_valid)
421             return m_should_stop;
422 
423         WatchpointSP wp_sp =
424             m_thread.GetProcess().GetTarget().GetWatchpointList().FindByID(GetValue());
425         if (wp_sp)
426         {
427             // Check if we should stop at a watchpoint.
428             StoppointCallbackContext context (event_ptr,
429                                               &m_thread.GetProcess(),
430                                               &m_thread,
431                                               m_thread.GetStackFrameAtIndex(0).get(),
432                                               true);
433 
434             m_should_stop = wp_sp->ShouldStop (&context);
435         }
436         else
437         {
438             LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
439 
440             if (log)
441                 log->Printf ("Process::%s could not find watchpoint location id: %lld...",
442                              __FUNCTION__, GetValue());
443 
444             m_should_stop = true;
445         }
446         m_should_stop_is_valid = true;
447         return m_should_stop;
448     }
449 
450     // Perform any action that is associated with this stop.  This is done as the
451     // Event is removed from the event queue.
452     virtual void
453     PerformAction (Event *event_ptr)
454     {
455         LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS);
456         // We're going to calculate if we should stop or not in some way during the course of
457         // this code.  Also by default we're going to stop, so set that here.
458         m_should_stop = true;
459 
460         WatchpointSP wp_sp =
461             m_thread.GetProcess().GetTarget().GetWatchpointList().FindByID(GetValue());
462         if (wp_sp)
463         {
464             StoppointCallbackContext context (event_ptr,
465                                               &m_thread.GetProcess(),
466                                               &m_thread,
467                                               m_thread.GetStackFrameAtIndex(0).get(),
468                                               false);
469             bool stop_requested = wp_sp->InvokeCallback (&context);
470             // Also make sure that the callback hasn't continued the target.
471             // If it did, when we'll set m_should_start to false and get out of here.
472             if (HasTargetRunSinceMe ())
473                 m_should_stop = false;
474 
475             if (m_should_stop && !stop_requested)
476             {
477                 // We have been vetoed.
478                 m_should_stop = false;
479             }
480 
481             if (m_should_stop && wp_sp->GetConditionText() != NULL)
482             {
483                 // We need to make sure the user sees any parse errors in their condition, so we'll hook the
484                 // constructor errors up to the debugger's Async I/O.
485                 StoppointCallbackContext context (event_ptr,
486                                                   &m_thread.GetProcess(),
487                                                   &m_thread,
488                                                   m_thread.GetStackFrameAtIndex(0).get(),
489                                                   false);
490                 ExecutionResults result_code;
491                 ValueObjectSP result_value_sp;
492                 const bool discard_on_error = true;
493                 Error error;
494                 result_code = ClangUserExpression::EvaluateWithError (context.exe_ctx,
495                                                                       eExecutionPolicyAlways,
496                                                                       lldb::eLanguageTypeUnknown,
497                                                                       discard_on_error,
498                                                                       wp_sp->GetConditionText(),
499                                                                       NULL,
500                                                                       result_value_sp,
501                                                                       error);
502                 if (result_code == eExecutionCompleted)
503                 {
504                     if (result_value_sp)
505                     {
506                         Scalar scalar_value;
507                         if (result_value_sp->ResolveValue (scalar_value))
508                         {
509                             if (scalar_value.ULongLong(1) == 0)
510                             {
511                                 // We have been vetoed.  This takes precedence over querying
512                                 // the watchpoint whether it should stop (aka ignore count and
513                                 // friends).  See also StopInfoWatchpoint::ShouldStop() as well
514                                 // as Process::ProcessEventData::DoOnRemoval().
515                                 m_should_stop = false;
516                             }
517                             else
518                                 m_should_stop = true;
519                             if (log)
520                                 log->Printf("Condition successfully evaluated, result is %s.\n",
521                                             m_should_stop ? "true" : "false");
522                         }
523                         else
524                         {
525                             m_should_stop = true;
526                             if (log)
527                                 log->Printf("Failed to get an integer result from the expression.");
528                         }
529                     }
530                 }
531                 else
532                 {
533                     Debugger &debugger = context.exe_ctx.GetTargetRef().GetDebugger();
534                     StreamSP error_sp = debugger.GetAsyncErrorStream ();
535                     error_sp->Printf ("Stopped due to an error evaluating condition of breakpoint ");
536                     wp_sp->GetDescription (error_sp.get(), eDescriptionLevelBrief);
537                     error_sp->Printf (": \"%s\"",
538                                       wp_sp->GetConditionText());
539                     error_sp->EOL();
540                     const char *err_str = error.AsCString("<Unknown Error>");
541                     if (log)
542                         log->Printf("Error evaluating condition: \"%s\"\n", err_str);
543 
544                     error_sp->PutCString (err_str);
545                     error_sp->EOL();
546                     error_sp->Flush();
547                     // If the condition fails to be parsed or run, we should stop.
548                     m_should_stop = true;
549                 }
550             }
551         }
552         else
553         {
554             LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
555 
556             if (log)
557                 log->Printf ("Process::%s could not find watchpoint id: %lld...", __FUNCTION__, m_value);
558         }
559         if (log)
560             log->Printf ("Process::%s returning from action with m_should_stop: %d.", __FUNCTION__, m_should_stop);
561     }
562 
563     virtual const char *
564     GetDescription ()
565     {
566         if (m_description.empty())
567         {
568             StreamString strm;
569             strm.Printf("watchpoint %lli", m_value);
570             m_description.swap (strm.GetString());
571         }
572         return m_description.c_str();
573     }
574 
575 private:
576     std::string m_description;
577     bool m_should_stop;
578     bool m_should_stop_is_valid;
579 };
580 
581 
582 
583 //----------------------------------------------------------------------
584 // StopInfoUnixSignal
585 //----------------------------------------------------------------------
586 
587 class StopInfoUnixSignal : public StopInfo
588 {
589 public:
590 
591     StopInfoUnixSignal (Thread &thread, int signo) :
592         StopInfo (thread, signo)
593     {
594     }
595 
596     virtual ~StopInfoUnixSignal ()
597     {
598     }
599 
600 
601     virtual StopReason
602     GetStopReason () const
603     {
604         return eStopReasonSignal;
605     }
606 
607     virtual bool
608     ShouldStop (Event *event_ptr)
609     {
610         return m_thread.GetProcess().GetUnixSignals().GetShouldStop (m_value);
611     }
612 
613 
614     // If should stop returns false, check if we should notify of this event
615     virtual bool
616     ShouldNotify (Event *event_ptr)
617     {
618         return m_thread.GetProcess().GetUnixSignals().GetShouldNotify (m_value);
619     }
620 
621 
622     virtual void
623     WillResume (lldb::StateType resume_state)
624     {
625         if (m_thread.GetProcess().GetUnixSignals().GetShouldSuppress(m_value) == false)
626             m_thread.SetResumeSignal(m_value);
627     }
628 
629     virtual const char *
630     GetDescription ()
631     {
632         if (m_description.empty())
633         {
634             StreamString strm;
635             const char *signal_name = m_thread.GetProcess().GetUnixSignals().GetSignalAsCString (m_value);
636             if (signal_name)
637                 strm.Printf("signal %s", signal_name);
638             else
639                 strm.Printf("signal %lli", m_value);
640             m_description.swap (strm.GetString());
641         }
642         return m_description.c_str();
643     }
644 };
645 
646 //----------------------------------------------------------------------
647 // StopInfoTrace
648 //----------------------------------------------------------------------
649 
650 class StopInfoTrace : public StopInfo
651 {
652 public:
653 
654     StopInfoTrace (Thread &thread) :
655         StopInfo (thread, LLDB_INVALID_UID)
656     {
657     }
658 
659     virtual ~StopInfoTrace ()
660     {
661     }
662 
663     virtual StopReason
664     GetStopReason () const
665     {
666         return eStopReasonTrace;
667     }
668 
669     virtual const char *
670     GetDescription ()
671     {
672         if (m_description.empty())
673         return "trace";
674         else
675             return m_description.c_str();
676     }
677 };
678 
679 
680 //----------------------------------------------------------------------
681 // StopInfoException
682 //----------------------------------------------------------------------
683 
684 class StopInfoException : public StopInfo
685 {
686 public:
687 
688     StopInfoException (Thread &thread, const char *description) :
689         StopInfo (thread, LLDB_INVALID_UID)
690     {
691         if (description)
692             SetDescription (description);
693     }
694 
695     virtual
696     ~StopInfoException ()
697     {
698     }
699 
700     virtual StopReason
701     GetStopReason () const
702     {
703         return eStopReasonException;
704     }
705 
706     virtual const char *
707     GetDescription ()
708     {
709         if (m_description.empty())
710             return "exception";
711         else
712             return m_description.c_str();
713     }
714 };
715 
716 
717 //----------------------------------------------------------------------
718 // StopInfoThreadPlan
719 //----------------------------------------------------------------------
720 
721 class StopInfoThreadPlan : public StopInfo
722 {
723 public:
724 
725     StopInfoThreadPlan (ThreadPlanSP &plan_sp) :
726         StopInfo (plan_sp->GetThread(), LLDB_INVALID_UID),
727         m_plan_sp (plan_sp)
728     {
729     }
730 
731     virtual ~StopInfoThreadPlan ()
732     {
733     }
734 
735     virtual StopReason
736     GetStopReason () const
737     {
738         return eStopReasonPlanComplete;
739     }
740 
741     virtual const char *
742     GetDescription ()
743     {
744         if (m_description.empty())
745         {
746             StreamString strm;
747             m_plan_sp->GetDescription (&strm, eDescriptionLevelBrief);
748             m_description.swap (strm.GetString());
749         }
750         return m_description.c_str();
751     }
752 
753 private:
754     ThreadPlanSP m_plan_sp;
755 };
756 } // namespace lldb_private
757 
758 StopInfoSP
759 StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id)
760 {
761     return StopInfoSP (new StopInfoBreakpoint (thread, break_id));
762 }
763 
764 StopInfoSP
765 StopInfo::CreateStopReasonWithBreakpointSiteID (Thread &thread, break_id_t break_id, bool should_stop)
766 {
767     return StopInfoSP (new StopInfoBreakpoint (thread, break_id, should_stop));
768 }
769 
770 StopInfoSP
771 StopInfo::CreateStopReasonWithWatchpointID (Thread &thread, break_id_t watch_id)
772 {
773     return StopInfoSP (new StopInfoWatchpoint (thread, watch_id));
774 }
775 
776 StopInfoSP
777 StopInfo::CreateStopReasonWithSignal (Thread &thread, int signo)
778 {
779     return StopInfoSP (new StopInfoUnixSignal (thread, signo));
780 }
781 
782 StopInfoSP
783 StopInfo::CreateStopReasonToTrace (Thread &thread)
784 {
785     return StopInfoSP (new StopInfoTrace (thread));
786 }
787 
788 StopInfoSP
789 StopInfo::CreateStopReasonWithPlan (ThreadPlanSP &plan_sp)
790 {
791     return StopInfoSP (new StopInfoThreadPlan (plan_sp));
792 }
793 
794 StopInfoSP
795 StopInfo::CreateStopReasonWithException (Thread &thread, const char *description)
796 {
797     return StopInfoSP (new StopInfoException (thread, description));
798 }
799