• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- BreakpointResolverFileRegex.h ----------------------------*- C++
2 //-*-===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H
11 #define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H
12 
13 #include <set>
14 #include "lldb/Breakpoint/BreakpointResolver.h"
15 #include "lldb/Utility/ConstString.h"
16 
17 namespace lldb_private {
18 
19 /// \class BreakpointResolverFileRegex BreakpointResolverFileRegex.h
20 /// "lldb/Breakpoint/BreakpointResolverFileRegex.h" This class sets
21 /// breakpoints by file and line.  Optionally, it will look for inlined
22 /// instances of the file and line specification.
23 
24 class BreakpointResolverFileRegex : public BreakpointResolver {
25 public:
26   BreakpointResolverFileRegex(
27       const lldb::BreakpointSP &bkpt, RegularExpression regex,
28       const std::unordered_set<std::string> &func_name_set, bool exact_match);
29 
30   static BreakpointResolver *
31   CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
32                            const StructuredData::Dictionary &options_dict,
33                            Status &error);
34 
35   StructuredData::ObjectSP SerializeToStructuredData() override;
36 
37   ~BreakpointResolverFileRegex() override = default;
38 
39   Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
40                                           SymbolContext &context,
41                                           Address *addr) override;
42 
43   lldb::SearchDepth GetDepth() override;
44 
45   void GetDescription(Stream *s) override;
46 
47   void Dump(Stream *s) const override;
48 
49   void AddFunctionName(const char *func_name);
50 
51   /// Methods for support type inquiry through isa, cast, and dyn_cast:
classof(const BreakpointResolverFileRegex *)52   static inline bool classof(const BreakpointResolverFileRegex *) {
53     return true;
54   }
classof(const BreakpointResolver * V)55   static inline bool classof(const BreakpointResolver *V) {
56     return V->getResolverID() == BreakpointResolver::FileRegexResolver;
57   }
58 
59   lldb::BreakpointResolverSP
60   CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
61 
62 protected:
63   friend class Breakpoint;
64   RegularExpression
65       m_regex;        // This is the line expression that we are looking for.
66   bool m_exact_match; // If true, then if the source we match is in a comment,
67                       // we won't set a location there.
68   std::unordered_set<std::string> m_function_names; // Limit the search to
69                                                     // functions in the
70                                                     // comp_unit passed in.
71 
72 private:
73   BreakpointResolverFileRegex(const BreakpointResolverFileRegex &) = delete;
74   const BreakpointResolverFileRegex &
75   operator=(const BreakpointResolverFileRegex &) = delete;
76 };
77 
78 } // namespace lldb_private
79 
80 #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H
81