1 | //===-- BreakpointResolverName.h --------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H |
10 | #define LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H |
11 | |
12 | #include <string> |
13 | #include <vector> |
14 | |
15 | #include "lldb/Breakpoint/BreakpointResolver.h" |
16 | #include "lldb/Core/Module.h" |
17 | |
18 | namespace lldb_private { |
19 | |
20 | /// \class BreakpointResolverName BreakpointResolverName.h |
21 | /// "lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on |
22 | /// a given function name, either by exact match or by regular expression. |
23 | |
24 | class BreakpointResolverName : public BreakpointResolver { |
25 | public: |
26 | BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *name, |
27 | lldb::FunctionNameType name_type_mask, |
28 | lldb::LanguageType language, |
29 | Breakpoint::MatchType type, lldb::addr_t offset, |
30 | bool skip_prologue); |
31 | |
32 | // This one takes an array of names. It is always MatchType = Exact. |
33 | BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *names[], |
34 | size_t num_names, |
35 | lldb::FunctionNameType name_type_mask, |
36 | lldb::LanguageType language, lldb::addr_t offset, |
37 | bool skip_prologue); |
38 | |
39 | // This one takes a C++ array of names. It is always MatchType = Exact. |
40 | BreakpointResolverName(const lldb::BreakpointSP &bkpt, |
41 | const std::vector<std::string> &names, |
42 | lldb::FunctionNameType name_type_mask, |
43 | lldb::LanguageType language, lldb::addr_t offset, |
44 | bool skip_prologue); |
45 | |
46 | // Creates a function breakpoint by regular expression. Takes over control |
47 | // of the lifespan of func_regex. |
48 | BreakpointResolverName(const lldb::BreakpointSP &bkpt, |
49 | RegularExpression func_regex, |
50 | lldb::LanguageType language, lldb::addr_t offset, |
51 | bool skip_prologue); |
52 | |
53 | static lldb::BreakpointResolverSP |
54 | CreateFromStructuredData(const StructuredData::Dictionary &data_dict, |
55 | Status &error); |
56 | |
57 | StructuredData::ObjectSP SerializeToStructuredData() override; |
58 | |
59 | ~BreakpointResolverName() override = default; |
60 | |
61 | Searcher::CallbackReturn SearchCallback(SearchFilter &filter, |
62 | SymbolContext &context, |
63 | Address *addr) override; |
64 | |
65 | lldb::SearchDepth GetDepth() override; |
66 | |
67 | void GetDescription(Stream *s) override; |
68 | |
69 | void Dump(Stream *s) const override; |
70 | |
71 | /// Methods for support type inquiry through isa, cast, and dyn_cast: |
72 | static inline bool classof(const BreakpointResolverName *) { return true; } |
73 | static inline bool classof(const BreakpointResolver *V) { |
74 | return V->getResolverID() == BreakpointResolver::NameResolver; |
75 | } |
76 | |
77 | lldb::BreakpointResolverSP |
78 | CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override; |
79 | |
80 | protected: |
81 | BreakpointResolverName(const BreakpointResolverName &rhs); |
82 | |
83 | std::vector<Module::LookupInfo> m_lookups; |
84 | ConstString m_class_name; |
85 | RegularExpression m_regex; |
86 | Breakpoint::MatchType m_match_type; |
87 | lldb::LanguageType m_language; |
88 | bool m_skip_prologue; |
89 | |
90 | void AddNameLookup(ConstString name, |
91 | lldb::FunctionNameType name_type_mask); |
92 | }; |
93 | |
94 | } // namespace lldb_private |
95 | |
96 | #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H |
97 | |