File indexing completed on 2026-05-10 08:42:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H
0010 #define LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H
0011
0012 #include "lldb/Breakpoint/Breakpoint.h"
0013 #include "lldb/Core/Address.h"
0014 #include "lldb/Core/SearchFilter.h"
0015 #include "lldb/Utility/ConstString.h"
0016 #include "lldb/Utility/FileSpec.h"
0017 #include "lldb/Utility/RegularExpression.h"
0018 #include "lldb/lldb-private.h"
0019 #include <optional>
0020
0021 namespace lldb_private {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 class BreakpointResolver : public Searcher {
0037 friend class Breakpoint;
0038
0039 public:
0040
0041
0042
0043
0044
0045
0046
0047
0048 BreakpointResolver(const lldb::BreakpointSP &bkpt,
0049 unsigned char resolverType,
0050 lldb::addr_t offset = 0);
0051
0052
0053
0054 ~BreakpointResolver() override;
0055
0056
0057
0058
0059
0060 void SetBreakpoint(const lldb::BreakpointSP &bkpt);
0061
0062
0063 lldb::BreakpointSP GetBreakpoint() const {
0064 auto breakpoint_sp = m_breakpoint.expired() ? lldb::BreakpointSP() :
0065 m_breakpoint.lock();
0066 assert(breakpoint_sp);
0067 return breakpoint_sp;
0068 }
0069
0070
0071
0072
0073
0074
0075
0076 void SetOffset(lldb::addr_t offset);
0077
0078 lldb::addr_t GetOffset() const { return m_offset; }
0079
0080
0081
0082
0083
0084
0085 virtual void ResolveBreakpoint(SearchFilter &filter);
0086
0087
0088
0089
0090
0091
0092 virtual void ResolveBreakpointInModules(SearchFilter &filter,
0093 ModuleList &modules);
0094
0095
0096
0097
0098
0099 void GetDescription(Stream *s) override = 0;
0100
0101
0102 virtual void Dump(Stream *s) const = 0;
0103
0104
0105
0106
0107 static lldb::BreakpointResolverSP
0108 CreateFromStructuredData(const StructuredData::Dictionary &resolver_dict,
0109 Status &error);
0110
0111 virtual StructuredData::ObjectSP SerializeToStructuredData() {
0112 return StructuredData::ObjectSP();
0113 }
0114
0115 static const char *GetSerializationKey() { return "BKPTResolver"; }
0116
0117 static const char *GetSerializationSubclassKey() { return "Type"; }
0118
0119 static const char *GetSerializationSubclassOptionsKey() { return "Options"; }
0120
0121 StructuredData::DictionarySP
0122 WrapOptionsDict(StructuredData::DictionarySP options_dict_sp);
0123
0124
0125
0126
0127
0128 enum ResolverTy {
0129 FileLineResolver = 0,
0130 AddressResolver,
0131 NameResolver,
0132 FileRegexResolver,
0133 PythonResolver,
0134 ExceptionResolver,
0135 LastKnownResolverType = ExceptionResolver,
0136 UnknownResolver
0137 };
0138
0139
0140
0141 static const char *g_ty_to_name[LastKnownResolverType + 2];
0142
0143
0144
0145
0146 unsigned getResolverID() const { return SubclassID; }
0147
0148 enum ResolverTy GetResolverTy() {
0149 if (SubclassID > ResolverTy::LastKnownResolverType)
0150 return ResolverTy::UnknownResolver;
0151 else
0152 return (enum ResolverTy)SubclassID;
0153 }
0154
0155 const char *GetResolverName() { return ResolverTyToName(GetResolverTy()); }
0156
0157 static const char *ResolverTyToName(enum ResolverTy);
0158
0159 static ResolverTy NameToResolverTy(llvm::StringRef name);
0160
0161 virtual lldb::BreakpointResolverSP
0162 CopyForBreakpoint(lldb::BreakpointSP &breakpoint) = 0;
0163
0164 protected:
0165
0166
0167
0168 enum class OptionNames : uint32_t {
0169 AddressOffset = 0,
0170 ExactMatch,
0171 FileName,
0172 Inlines,
0173 LanguageName,
0174 LineNumber,
0175 Column,
0176 ModuleName,
0177 NameMaskArray,
0178 Offset,
0179 PythonClassName,
0180 RegexString,
0181 ScriptArgs,
0182 SectionName,
0183 SearchDepth,
0184 SkipPrologue,
0185 SymbolNameArray,
0186 LastOptionName
0187 };
0188 static const char
0189 *g_option_names[static_cast<uint32_t>(OptionNames::LastOptionName)];
0190
0191 virtual void NotifyBreakpointSet() {};
0192
0193 public:
0194 static const char *GetKey(OptionNames enum_value) {
0195 return g_option_names[static_cast<uint32_t>(enum_value)];
0196 }
0197
0198 protected:
0199
0200
0201
0202
0203
0204
0205
0206 void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list,
0207 bool skip_prologue, llvm::StringRef log_ident,
0208 uint32_t line = 0,
0209 std::optional<uint16_t> column = std::nullopt);
0210 void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool,
0211 const char *) = delete;
0212
0213 lldb::BreakpointLocationSP AddLocation(Address loc_addr,
0214 bool *new_location = nullptr);
0215
0216 private:
0217
0218 void AddLocation(SearchFilter &filter, const SymbolContext &sc,
0219 bool skip_prologue, llvm::StringRef log_ident);
0220
0221 lldb::BreakpointWP m_breakpoint;
0222 lldb::addr_t m_offset;
0223
0224
0225
0226 const unsigned char SubclassID;
0227 BreakpointResolver(const BreakpointResolver &) = delete;
0228 const BreakpointResolver &operator=(const BreakpointResolver &) = delete;
0229 };
0230
0231 }
0232
0233 #endif