• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- ThreadPlanShouldStopHere.h ------------------------------*- 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 #ifndef liblldb_ThreadPlanShouldStopHere_h_
11 #define liblldb_ThreadPlanShouldStopHere_h_
12 
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Target/ThreadPlan.h"
18 
19 namespace lldb_private {
20 
21 // This is an interface that ThreadPlans can adopt to allow flexible modifications of the behavior
22 // when a thread plan comes to a place where it would ordinarily stop.  If such modification makes
23 // sense for your plan, inherit from this class, and when you would be about to stop (in your ShouldStop
24 // method), call InvokeShouldStopHereCallback, and if that returns a non-NULL plan, execute that
25 // plan instead of stopping.
26 //
27 // The classic example of the use of this is ThreadPlanStepInRange not stopping in frames that have
28 // no debug information.
29 //
30 // This class also defines a set of flags to control general aspects of this "ShouldStop" behavior.
31 // A class implementing this protocol needs to define a default set of flags, and can provide access to
32 // changing that default flag set if it wishes.
33 
34 class ThreadPlanShouldStopHere
35 {
36 public:
37     enum
38     {
39         eNone = 0,
40         eAvoidInlines = (1 << 0),
41         eAvoidNoDebug = (1 << 1)
42     };
43 
44     //------------------------------------------------------------------
45     // Constructors and Destructors
46     //------------------------------------------------------------------
47     ThreadPlanShouldStopHere (ThreadPlan *owner,
48                               ThreadPlanShouldStopHereCallback callback = NULL,
49                               void *baton = NULL);
50     virtual
51     ~ThreadPlanShouldStopHere();
52 
53     void
54     SetShouldStopHereCallback (ThreadPlanShouldStopHereCallback callback, void *baton);
55 
56     lldb::ThreadPlanSP
57     InvokeShouldStopHereCallback ();
58 
59     lldb_private::Flags &
GetFlags()60     GetFlags ()
61     {
62         return m_flags;
63     }
64 
65     const lldb_private::Flags &
GetFlags()66     GetFlags () const
67     {
68         return m_flags;
69     }
70 
71 protected:
72     // Implement this, and call it in the plan's constructor to set the default flags.
73     virtual void SetFlagsToDefault () = 0;
74 
75     //------------------------------------------------------------------
76     // Classes that inherit from ThreadPlanShouldStopHere can see and modify these
77     //------------------------------------------------------------------
78     ThreadPlanShouldStopHereCallback m_callback;
79     void * m_baton;
80     ThreadPlan *m_owner;
81     lldb_private::Flags m_flags;
82 
83 private:
84     //------------------------------------------------------------------
85     // For ThreadPlanShouldStopHere only
86     //------------------------------------------------------------------
87 
88     DISALLOW_COPY_AND_ASSIGN (ThreadPlanShouldStopHere);
89 
90 };
91 
92 } // namespace lldb_private
93 
94 #endif  // liblldb_ThreadPlanShouldStopHere_h_
95