| 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 lldb::BreakpointResolverSP |
| 31 | CreateFromStructuredData(const StructuredData::Dictionary &options_dict, |
| 32 | Status &error); |
| 33 | |
| 34 | StructuredData::ObjectSP SerializeToStructuredData() override; |
| 35 | |
| 36 | ~BreakpointResolverFileRegex() override = default; |
| 37 | |
| 38 | Searcher::CallbackReturn SearchCallback(SearchFilter &filter, |
| 39 | SymbolContext &context, |
| 40 | Address *addr) override; |
| 41 | |
| 42 | lldb::SearchDepth GetDepth() override; |
| 43 | |
| 44 | void GetDescription(Stream *s) override; |
| 45 | |
| 46 | void Dump(Stream *s) const override; |
| 47 | |
| 48 | void AddFunctionName(const char *func_name); |
| 49 | |
| 50 | /// Methods for support type inquiry through isa, cast, and dyn_cast: |
| 51 | static inline bool classof(const BreakpointResolverFileRegex *) { |
| 52 | return true; |
| 53 | } |
| 54 | static inline bool classof(const BreakpointResolver *V) { |
| 55 | return V->getResolverID() == BreakpointResolver::FileRegexResolver; |
| 56 | } |
| 57 | |
| 58 | lldb::BreakpointResolverSP |
| 59 | CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; |
| 60 | |
| 61 | protected: |
| 62 | friend class Breakpoint; |
| 63 | RegularExpression |
| 64 | m_regex; // This is the line expression that we are looking for. |
| 65 | bool m_exact_match; // If true, then if the source we match is in a comment, |
| 66 | // we won't set a location there. |
| 67 | std::unordered_set<std::string> m_function_names; // Limit the search to |
| 68 | // functions in the |
| 69 | // comp_unit passed in. |
| 70 | |
| 71 | private: |
| 72 | BreakpointResolverFileRegex(const BreakpointResolverFileRegex &) = delete; |
| 73 | const BreakpointResolverFileRegex & |
| 74 | operator=(const BreakpointResolverFileRegex &) = delete; |
| 75 | }; |
| 76 | |
| 77 | } // namespace lldb_private |
| 78 | |
| 79 | #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H |
| 80 | |