• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- BreakpointResolver.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_BreakpointResolver_h_
11 #define liblldb_BreakpointResolver_h_
12 
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/lldb-private.h"
18 #include "lldb/Core/Address.h"
19 #include "lldb/Breakpoint/Breakpoint.h"
20 #include "lldb/Breakpoint/BreakpointResolver.h"
21 #include "lldb/Host/FileSpec.h"
22 #include "lldb/Core/RegularExpression.h"
23 #include "lldb/Core/SearchFilter.h"
24 #include "lldb/Core/ConstString.h"
25 
26 namespace lldb_private {
27 
28 //----------------------------------------------------------------------
29 /// @class BreakpointResolver BreakpointResolver.h "lldb/Breakpoint/BreakpointResolver.h"
30 /// @brief This class works with SearchFilter to resolve logical breakpoints to their
31 /// of concrete breakpoint locations.
32 //----------------------------------------------------------------------
33 
34 //----------------------------------------------------------------------
35 /// General Outline:
36 /// The BreakpointResolver is a Searcher.  In that protocol,
37 /// the SearchFilter asks the question "At what depth of the symbol context
38 /// descent do you want your callback to get called?" of the filter.  The resolver
39 /// answers this question (in the GetDepth method) and provides the resolution callback.
40 /// Each Breakpoint has a BreakpointResolver, and it calls either ResolveBreakpoint
41 /// or ResolveBreakpointInModules to tell it to look for new breakpoint locations.
42 //----------------------------------------------------------------------
43 
44 class BreakpointResolver :
45    public Searcher
46 {
47 public:
48     //------------------------------------------------------------------
49     /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
50     /// to make sense.  It can be constructed without a breakpoint, but you have to
51     /// call SetBreakpoint before ResolveBreakpoint.
52     ///
53     /// @param[in] bkpt
54     ///   The breakpoint that owns this resolver.
55     /// @param[in] resolverType
56     ///   The concrete breakpoint resolver type for this breakpoint.
57     ///
58     /// @result
59     ///   Returns breakpoint location id.
60     //------------------------------------------------------------------
61     BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType);
62 
63     //------------------------------------------------------------------
64     /// The Destructor is virtual, all significant breakpoint resolvers derive
65     /// from this class.
66     //------------------------------------------------------------------
67     virtual
68     ~BreakpointResolver ();
69 
70     //------------------------------------------------------------------
71     /// This sets the breakpoint for this resolver.
72     ///
73     /// @param[in] bkpt
74     ///   The breakpoint that owns this resolver.
75     //------------------------------------------------------------------
76     void
77     SetBreakpoint (Breakpoint *bkpt);
78 
79     //------------------------------------------------------------------
80     /// In response to this method the resolver scans all the modules in the breakpoint's
81     /// target, and adds any new locations it finds.
82     ///
83     /// @param[in] filter
84     ///   The filter that will manage the search for this resolver.
85     //------------------------------------------------------------------
86     virtual void
87     ResolveBreakpoint (SearchFilter &filter);
88 
89     //------------------------------------------------------------------
90     /// In response to this method the resolver scans the modules in the module list
91     /// \a modules, and adds any new locations it finds.
92     ///
93     /// @param[in] filter
94     ///   The filter that will manage the search for this resolver.
95     //------------------------------------------------------------------
96     virtual void
97     ResolveBreakpointInModules (SearchFilter &filter,
98                                 ModuleList &modules);
99 
100     //------------------------------------------------------------------
101     /// Prints a canonical description for the breakpoint to the stream \a s.
102     ///
103     /// @param[in] s
104     ///   Stream to which the output is copied.
105     //------------------------------------------------------------------
106     virtual void
107     GetDescription (Stream *s) = 0;
108 
109     //------------------------------------------------------------------
110     /// Standard "Dump" method.  At present it does nothing.
111     //------------------------------------------------------------------
112     virtual void
113     Dump (Stream *s) const = 0;
114 
115     //------------------------------------------------------------------
116     /// An enumeration for keeping track of the concrete subclass that
117     /// is actually instantiated. Values of this enumeration are kept in the
118     /// BreakpointResolver's SubclassID field. They are used for concrete type
119     /// identification.
120     enum ResolverTy {
121         FileLineResolver, // This is an instance of BreakpointResolverFileLine
122         AddressResolver,  // This is an instance of BreakpointResolverAddress
123         NameResolver,      // This is an instance of BreakpointResolverName
124         FileRegexResolver,
125         ExceptionResolver
126     };
127 
128     //------------------------------------------------------------------
129     /// getResolverID - Return an ID for the concrete type of this object.  This
130     /// is used to implement the LLVM classof checks.  This should not be used
131     /// for any other purpose, as the values may change as LLDB evolves.
getResolverID()132     unsigned getResolverID() const {
133         return SubclassID;
134     }
135 
136 protected:
137     Breakpoint *m_breakpoint;  // This is the breakpoint we add locations to.
138 
139 private:
140     // Subclass identifier (for llvm isa/dyn_cast)
141     const unsigned char SubclassID;
142     DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
143 };
144 
145 } // namespace lldb_private
146 
147 #endif  // liblldb_BreakpointResolver_h_
148