BreakpointResolverName.h revision 360784
1104476Ssam//===-- BreakpointResolverName.h --------------------------------*- C++ -*-===//
2104476Ssam//
3104476Ssam// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4104476Ssam// See https://llvm.org/LICENSE.txt for license information.
5104476Ssam// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6104476Ssam//
7104476Ssam//===----------------------------------------------------------------------===//
8104476Ssam
9104476Ssam#ifndef liblldb_BreakpointResolverName_h_
10104476Ssam#define liblldb_BreakpointResolverName_h_
11104476Ssam
12104476Ssam#include <string>
13104476Ssam#include <vector>
14104476Ssam
15104476Ssam#include "lldb/Breakpoint/BreakpointResolver.h"
16104476Ssam#include "lldb/Core/Module.h"
17104476Ssam
18104476Ssamnamespace lldb_private {
19104476Ssam
20104476Ssam/// \class BreakpointResolverName BreakpointResolverName.h
21104476Ssam/// "lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on
22116191Sobrien/// a given function name, either by exact match or by regular expression.
23116191Sobrien
24116191Sobrienclass BreakpointResolverName : public BreakpointResolver {
25116191Sobrienpublic:
26108587Ssam  BreakpointResolverName(Breakpoint *bkpt, const char *name,
27104476Ssam                         lldb::FunctionNameType name_type_mask,
28104476Ssam                         lldb::LanguageType language,
29104476Ssam                         Breakpoint::MatchType type, lldb::addr_t offset,
30104476Ssam                         bool skip_prologue);
31104476Ssam
32104476Ssam  // This one takes an array of names.  It is always MatchType = Exact.
33104476Ssam  BreakpointResolverName(Breakpoint *bkpt, const char *names[],
34129880Sphk                         size_t num_names,
35104476Ssam                         lldb::FunctionNameType name_type_mask,
36104476Ssam                         lldb::LanguageType language, lldb::addr_t offset,
37104476Ssam                         bool skip_prologue);
38104476Ssam
39104476Ssam  // This one takes a C++ array of names.  It is always MatchType = Exact.
40104476Ssam  BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names,
41104476Ssam                         lldb::FunctionNameType name_type_mask,
42104628Ssam                         lldb::LanguageType language, lldb::addr_t offset,
43104476Ssam                         bool skip_prologue);
44104476Ssam
45104476Ssam  // Creates a function breakpoint by regular expression.  Takes over control
46104476Ssam  // of the lifespan of func_regex.
47104476Ssam  BreakpointResolverName(Breakpoint *bkpt, RegularExpression func_regex,
48104476Ssam                         lldb::LanguageType language, lldb::addr_t offset,
49104476Ssam                         bool skip_prologue);
50104476Ssam
51104476Ssam  static BreakpointResolver *
52104476Ssam  CreateFromStructuredData(Breakpoint *bkpt,
53104476Ssam                           const StructuredData::Dictionary &data_dict,
54104476Ssam                           Status &error);
55104476Ssam
56104476Ssam  StructuredData::ObjectSP SerializeToStructuredData() override;
57104476Ssam
58104476Ssam  ~BreakpointResolverName() override;
59104476Ssam
60104476Ssam  Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
61104476Ssam                                          SymbolContext &context,
62104476Ssam                                          Address *addr) override;
63104476Ssam
64104476Ssam  lldb::SearchDepth GetDepth() override;
65104476Ssam
66104476Ssam  void GetDescription(Stream *s) override;
67104476Ssam
68104476Ssam  void Dump(Stream *s) const override;
69104476Ssam
70104476Ssam  /// Methods for support type inquiry through isa, cast, and dyn_cast:
71104476Ssam  static inline bool classof(const BreakpointResolverName *) { return true; }
72104476Ssam  static inline bool classof(const BreakpointResolver *V) {
73104476Ssam    return V->getResolverID() == BreakpointResolver::NameResolver;
74104476Ssam  }
75104476Ssam
76104476Ssam  lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
77104476Ssam
78104476Ssamprotected:
79104476Ssam  BreakpointResolverName(const BreakpointResolverName &rhs);
80104476Ssam
81104476Ssam  std::vector<Module::LookupInfo> m_lookups;
82104476Ssam  ConstString m_class_name;
83104476Ssam  RegularExpression m_regex;
84104476Ssam  Breakpoint::MatchType m_match_type;
85104476Ssam  lldb::LanguageType m_language;
86104476Ssam  bool m_skip_prologue;
87104476Ssam
88104476Ssam  void AddNameLookup(ConstString name,
89104476Ssam                     lldb::FunctionNameType name_type_mask);
90104476Ssam};
91104476Ssam
92104476Ssam} // namespace lldb_private
93104476Ssam
94104476Ssam#endif // liblldb_BreakpointResolverName_h_
95104476Ssam