1 //===-- BreakpointResolver.h ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_BreakpointResolver_h_
11 #define liblldb_BreakpointResolver_h_
15 // Other libraries and framework 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"
26 namespace lldb_private {
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 //----------------------------------------------------------------------
34 //----------------------------------------------------------------------
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 //----------------------------------------------------------------------
44 class BreakpointResolver :
47 friend class Breakpoint;
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.
56 /// The breakpoint that owns this resolver.
57 /// @param[in] resolverType
58 /// The concrete breakpoint resolver type for this breakpoint.
61 /// Returns breakpoint location id.
62 //------------------------------------------------------------------
63 BreakpointResolver (Breakpoint *bkpt, unsigned char resolverType);
65 //------------------------------------------------------------------
66 /// The Destructor is virtual, all significant breakpoint resolvers derive
68 //------------------------------------------------------------------
70 ~BreakpointResolver ();
72 //------------------------------------------------------------------
73 /// This sets the breakpoint for this resolver.
76 /// The breakpoint that owns this resolver.
77 //------------------------------------------------------------------
79 SetBreakpoint (Breakpoint *bkpt);
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.
86 /// The filter that will manage the search for this resolver.
87 //------------------------------------------------------------------
89 ResolveBreakpoint (SearchFilter &filter);
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.
96 /// The filter that will manage the search for this resolver.
97 //------------------------------------------------------------------
99 ResolveBreakpointInModules (SearchFilter &filter,
100 ModuleList &modules);
102 //------------------------------------------------------------------
103 /// Prints a canonical description for the breakpoint to the stream \a s.
106 /// Stream to which the output is copied.
107 //------------------------------------------------------------------
109 GetDescription (Stream *s) = 0;
111 //------------------------------------------------------------------
112 /// Standard "Dump" method. At present it does nothing.
113 //------------------------------------------------------------------
115 Dump (Stream *s) const = 0;
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
123 FileLineResolver, // This is an instance of BreakpointResolverFileLine
124 AddressResolver, // This is an instance of BreakpointResolverAddress
125 NameResolver, // This is an instance of BreakpointResolverName
128 LastKnownResolverType = ExceptionResolver
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 {
139 virtual lldb::BreakpointResolverSP
140 CopyForBreakpoint (Breakpoint &breakpoint) = 0;
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);
150 Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
153 // Subclass identifier (for llvm isa/dyn_cast)
154 const unsigned char SubclassID;
155 DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
158 } // namespace lldb_private
160 #endif // liblldb_BreakpointResolver_h_