BreakpointResolverName.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H
  9. #define LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H
  10. #include <string>
  11. #include <vector>
  12. #include "lldb/Breakpoint/BreakpointResolver.h"
  13. #include "lldb/Core/Module.h"
  14. namespace lldb_private {
  15. /// \class BreakpointResolverName BreakpointResolverName.h
  16. /// "lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on
  17. /// a given function name, either by exact match or by regular expression.
  18. class BreakpointResolverName : public BreakpointResolver {
  19. public:
  20. BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *name,
  21. lldb::FunctionNameType name_type_mask,
  22. lldb::LanguageType language,
  23. Breakpoint::MatchType type, lldb::addr_t offset,
  24. bool skip_prologue);
  25. // This one takes an array of names. It is always MatchType = Exact.
  26. BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *names[],
  27. size_t num_names,
  28. lldb::FunctionNameType name_type_mask,
  29. lldb::LanguageType language, lldb::addr_t offset,
  30. bool skip_prologue);
  31. // This one takes a C++ array of names. It is always MatchType = Exact.
  32. BreakpointResolverName(const lldb::BreakpointSP &bkpt,
  33. std::vector<std::string> names,
  34. lldb::FunctionNameType name_type_mask,
  35. lldb::LanguageType language, lldb::addr_t offset,
  36. bool skip_prologue);
  37. // Creates a function breakpoint by regular expression. Takes over control
  38. // of the lifespan of func_regex.
  39. BreakpointResolverName(const lldb::BreakpointSP &bkpt,
  40. RegularExpression func_regex,
  41. lldb::LanguageType language, lldb::addr_t offset,
  42. bool skip_prologue);
  43. static BreakpointResolver *
  44. CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
  45. const StructuredData::Dictionary &data_dict,
  46. Status &error);
  47. StructuredData::ObjectSP SerializeToStructuredData() override;
  48. ~BreakpointResolverName() override = default;
  49. Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
  50. SymbolContext &context,
  51. Address *addr) override;
  52. lldb::SearchDepth GetDepth() override;
  53. void GetDescription(Stream *s) override;
  54. void Dump(Stream *s) const override;
  55. /// Methods for support type inquiry through isa, cast, and dyn_cast:
  56. static inline bool classof(const BreakpointResolverName *) { return true; }
  57. static inline bool classof(const BreakpointResolver *V) {
  58. return V->getResolverID() == BreakpointResolver::NameResolver;
  59. }
  60. lldb::BreakpointResolverSP
  61. CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
  62. protected:
  63. BreakpointResolverName(const BreakpointResolverName &rhs);
  64. std::vector<Module::LookupInfo> m_lookups;
  65. ConstString m_class_name;
  66. RegularExpression m_regex;
  67. Breakpoint::MatchType m_match_type;
  68. lldb::LanguageType m_language;
  69. bool m_skip_prologue;
  70. void AddNameLookup(ConstString name,
  71. lldb::FunctionNameType name_type_mask);
  72. };
  73. } // namespace lldb_private
  74. #endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H