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
18namespace 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
24class BreakpointResolverName : public BreakpointResolver {
25public:
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                         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 BreakpointResolver *
54  CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
55                           const StructuredData::Dictionary &data_dict,
56                           Status &error);
57
58  StructuredData::ObjectSP SerializeToStructuredData() override;
59
60  ~BreakpointResolverName() override = default;
61
62  Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
63                                          SymbolContext &context,
64                                          Address *addr) override;
65
66  lldb::SearchDepth GetDepth() override;
67
68  void GetDescription(Stream *s) override;
69
70  void Dump(Stream *s) const override;
71
72  /// Methods for support type inquiry through isa, cast, and dyn_cast:
73  static inline bool classof(const BreakpointResolverName *) { return true; }
74  static inline bool classof(const BreakpointResolver *V) {
75    return V->getResolverID() == BreakpointResolver::NameResolver;
76  }
77
78  lldb::BreakpointResolverSP
79  CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
80
81protected:
82  BreakpointResolverName(const BreakpointResolverName &rhs);
83
84  std::vector<Module::LookupInfo> m_lookups;
85  ConstString m_class_name;
86  RegularExpression m_regex;
87  Breakpoint::MatchType m_match_type;
88  lldb::LanguageType m_language;
89  bool m_skip_prologue;
90
91  void AddNameLookup(ConstString name,
92                     lldb::FunctionNameType name_type_mask);
93};
94
95} // namespace lldb_private
96
97#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H
98