]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Breakpoint/BreakpointResolver.h
Update ELF Tool Chain to upstream rev 3400
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Breakpoint / BreakpointResolver.h
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 friend class Breakpoint;
48
49 public:
50     //------------------------------------------------------------------
51     /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint
52     /// to make sense.  It can be constructed without a breakpoint, but you have to
53     /// call SetBreakpoint before ResolveBreakpoint.
54     ///
55     /// @param[in] bkpt
56     ///   The breakpoint that owns this resolver.
57     /// @param[in] resolverType
58     ///   The concrete breakpoint resolver type for this breakpoint.
59     ///
60     /// @result
61     ///   Returns breakpoint location id.
62     //------------------------------------------------------------------
63     BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType);
64
65     //------------------------------------------------------------------
66     /// The Destructor is virtual, all significant breakpoint resolvers derive
67     /// from this class.
68     //------------------------------------------------------------------
69     virtual
70     ~BreakpointResolver ();
71
72     //------------------------------------------------------------------
73     /// This sets the breakpoint for this resolver.
74     ///
75     /// @param[in] bkpt
76     ///   The breakpoint that owns this resolver.
77     //------------------------------------------------------------------
78     void
79     SetBreakpoint (Breakpoint *bkpt);
80
81     //------------------------------------------------------------------
82     /// In response to this method the resolver scans all the modules in the breakpoint's
83     /// target, and adds any new locations it finds.
84     ///
85     /// @param[in] filter
86     ///   The filter that will manage the search for this resolver.
87     //------------------------------------------------------------------
88     virtual void
89     ResolveBreakpoint (SearchFilter &filter);
90
91     //------------------------------------------------------------------
92     /// In response to this method the resolver scans the modules in the module list
93     /// \a modules, and adds any new locations it finds.
94     ///
95     /// @param[in] filter
96     ///   The filter that will manage the search for this resolver.
97     //------------------------------------------------------------------
98     virtual void
99     ResolveBreakpointInModules (SearchFilter &filter,
100                                 ModuleList &modules);
101
102     //------------------------------------------------------------------
103     /// Prints a canonical description for the breakpoint to the stream \a s.
104     ///
105     /// @param[in] s
106     ///   Stream to which the output is copied.
107     //------------------------------------------------------------------
108     virtual void
109     GetDescription (Stream *s) = 0;
110
111     //------------------------------------------------------------------
112     /// Standard "Dump" method.  At present it does nothing.
113     //------------------------------------------------------------------
114     virtual void
115     Dump (Stream *s) const = 0;
116
117     //------------------------------------------------------------------
118     /// An enumeration for keeping track of the concrete subclass that
119     /// is actually instantiated. Values of this enumeration are kept in the 
120     /// BreakpointResolver's SubclassID field. They are used for concrete type
121     /// identification.
122     enum ResolverTy {
123         FileLineResolver, // This is an instance of BreakpointResolverFileLine
124         AddressResolver,  // This is an instance of BreakpointResolverAddress
125         NameResolver,      // This is an instance of BreakpointResolverName
126         FileRegexResolver,
127         ExceptionResolver,
128         LastKnownResolverType = ExceptionResolver
129     };
130
131     //------------------------------------------------------------------
132     /// getResolverID - Return an ID for the concrete type of this object.  This
133     /// is used to implement the LLVM classof checks.  This should not be used
134     /// for any other purpose, as the values may change as LLDB evolves.
135     unsigned getResolverID() const {
136         return SubclassID;
137     }
138
139     virtual lldb::BreakpointResolverSP
140     CopyForBreakpoint (Breakpoint &breakpoint) = 0;
141
142 protected:
143     //------------------------------------------------------------------
144     /// SetSCMatchesByLine - Takes a symbol context list of matches which supposedly represent the same file and
145     /// line number in a CU, and find the nearest actual line number that matches, and then filter down the
146     /// matching addresses to unique entries, and skip the prologue if asked to do so, and then set
147     /// breakpoint locations in this breakpoint for all the resultant addresses.
148     void SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident);
149     
150     Breakpoint *m_breakpoint;  // This is the breakpoint we add locations to.
151
152 private:
153     // Subclass identifier (for llvm isa/dyn_cast)
154     const unsigned char SubclassID;
155     DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
156 };
157
158 } // namespace lldb_private
159
160 #endif  // liblldb_BreakpointResolver_h_