• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- BreakpointResolverName.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_BreakpointResolverName_h_
11 #define liblldb_BreakpointResolverName_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <vector>
16 #include <string>
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Breakpoint/BreakpointResolver.h"
20 
21 namespace lldb_private {
22 
23 //----------------------------------------------------------------------
24 /// @class BreakpointResolverName BreakpointResolverName.h "lldb/Breakpoint/BreakpointResolverName.h"
25 /// @brief This class sets breakpoints on a given function name, either by exact match
26 /// or by regular expression.
27 //----------------------------------------------------------------------
28 
29 class BreakpointResolverName:
30     public BreakpointResolver
31 {
32 public:
33 
34     BreakpointResolverName (Breakpoint *bkpt,
35                             const char *name,
36                             uint32_t name_type_mask,
37                             Breakpoint::MatchType type,
38                             bool skip_prologue);
39 
40     // This one takes an array of names.  It is always MatchType = Exact.
41     BreakpointResolverName (Breakpoint *bkpt,
42                             const char *names[],
43                             size_t num_names,
44                             uint32_t name_type_mask,
45                             bool skip_prologue);
46 
47     // This one takes a C++ array of names.  It is always MatchType = Exact.
48     BreakpointResolverName (Breakpoint *bkpt,
49                             std::vector<std::string> names,
50                             uint32_t name_type_mask,
51                             bool skip_prologue);
52 
53     // Creates a function breakpoint by regular expression.  Takes over control of the lifespan of func_regex.
54     BreakpointResolverName (Breakpoint *bkpt,
55                             RegularExpression &func_regex,
56                             bool skip_prologue);
57 
58     BreakpointResolverName (Breakpoint *bkpt,
59                             const char *class_name,
60                             const char *method,
61                             Breakpoint::MatchType type,
62                             bool skip_prologue);
63 
64     virtual
65     ~BreakpointResolverName ();
66 
67     virtual Searcher::CallbackReturn
68     SearchCallback (SearchFilter &filter,
69                     SymbolContext &context,
70                     Address *addr,
71                     bool containing);
72 
73     virtual Searcher::Depth
74     GetDepth ();
75 
76     virtual void
77     GetDescription (Stream *s);
78 
79     virtual void
80     Dump (Stream *s) const;
81 
82     /// Methods for support type inquiry through isa, cast, and dyn_cast:
classof(const BreakpointResolverName *)83     static inline bool classof(const BreakpointResolverName *) { return true; }
classof(const BreakpointResolver * V)84     static inline bool classof(const BreakpointResolver *V) {
85         return V->getResolverID() == BreakpointResolver::NameResolver;
86     }
87 
88 protected:
89     struct LookupInfo
90     {
91         ConstString name;
92         ConstString lookup_name;
93         uint32_t name_type_mask; // See FunctionNameType
94         bool match_name_after_lookup;
95 
LookupInfoLookupInfo96         LookupInfo () :
97             name(),
98             lookup_name(),
99             name_type_mask (0),
100             match_name_after_lookup (false)
101         {
102         }
103 
104         void
105         Prune (SymbolContextList &sc_list,
106                size_t start_idx) const;
107     };
108     std::vector<LookupInfo> m_lookups;
109     ConstString m_class_name;
110     RegularExpression m_regex;
111     Breakpoint::MatchType m_match_type;
112     bool m_skip_prologue;
113 
114     void
115     AddNameLookup (const ConstString &name, uint32_t name_type_mask);
116 private:
117     DISALLOW_COPY_AND_ASSIGN(BreakpointResolverName);
118 };
119 
120 } // namespace lldb_private
121 
122 #endif  // liblldb_BreakpointResolverName_h_
123