38 "SymbolName",
"SourceRegex",
39 "Python",
"Exception",
43 BreakpointResolver::OptionNames::LastOptionName)] = {
44 "AddressOffset",
"Exact",
"FileName",
"Inlines",
"Language",
45 "LineNumber",
"Column",
"ModuleName",
"NameMask",
"Offset",
46 "PythonClass",
"Regex",
"ScriptArgs",
"SectionName",
"SearchDepth",
47 "SkipPrologue",
"SymbolNames"};
66 const unsigned char resolverTy,
68 : m_breakpoint(bkpt), m_offset(offset), SubclassID(resolverTy) {}
74 BreakpointResolverSP result_sp;
76 error.SetErrorString(
"Can't deserialize from an invalid data object.");
80 llvm::StringRef subclass_name;
86 error.SetErrorString(
"Resolver data missing subclass resolver key");
92 error.SetErrorStringWithFormatv(
"Unknown resolver type: {0}.",
100 if (!success || !subclass_options || !subclass_options->
IsValid()) {
101 error.SetErrorString(
"Resolver data missing subclass options key.");
109 error.SetErrorString(
"Resolver data missing offset options key.");
114 switch (resolver_type) {
117 nullptr, *subclass_options,
error);
121 nullptr, *subclass_options,
error);
125 nullptr, *subclass_options,
error);
129 nullptr, *subclass_options,
error);
133 nullptr, *subclass_options,
error);
136 error.SetErrorString(
"Exception resolvers are hard.");
139 llvm_unreachable(
"Should never get an unresolvable resolver type.");
142 if (!resolver ||
error.Fail())
147 return BreakpointResolverSP(resolver);
152 if (!options_dict_sp || !options_dict_sp->IsValid())
184 SourceLoc(
uint32_t l, std::optional<uint16_t> c)
187 : line(sc.line_entry.line),
188 column(sc.line_entry.column ? sc.line_entry.column
192bool operator<(
const SourceLoc lhs,
const SourceLoc rhs) {
193 if (lhs.line < rhs.line)
195 if (lhs.line > rhs.line)
199 return lhs.column < rhs.column;
205 llvm::StringRef log_ident,
uint32_t line, std::optional<uint16_t> column) {
206 llvm::SmallVector<SymbolContext, 16> all_scs;
208 all_scs.push_back(sc_list[i]);
210 while (all_scs.size()) {
214 auto &match = all_scs[0];
215 auto worklist_begin = std::partition(
216 all_scs.begin(), all_scs.end(), [&](
const SymbolContext &sc) {
217 if (sc.line_entry.file == match.line_entry.file ||
218 sc.line_entry.original_file == match.line_entry.original_file) {
220 closest_line = std::min(closest_line, sc.line_entry.line);
227 auto worklist_end = all_scs.end();
233 SourceLoc requested(line, *column);
235 worklist_end = std::remove_if(
236 worklist_begin, worklist_end,
237 [&](
const SymbolContext &sc) {
return requested < SourceLoc(sc); });
239 llvm::sort(worklist_begin, worklist_end,
241 return SourceLoc(a) < SourceLoc(b);
245 if (worklist_begin != worklist_end)
246 worklist_end = std::remove_if(
248 return SourceLoc(*worklist_begin) < SourceLoc(sc);
255 worklist_end = std::remove_if(worklist_begin, worklist_end,
262 llvm::sort(worklist_begin, worklist_end,
271 llvm::SmallDenseSet<Block *, 8> blocks_with_breakpoints;
272 for (
auto first = worklist_begin; first != worklist_end; ++first) {
273 assert(!blocks_with_breakpoints.count(first->block));
274 blocks_with_breakpoints.insert(first->block);
276 std::remove_if(std::next(first), worklist_end,
278 return blocks_with_breakpoints.count(sc.
block);
283 for (
auto &sc : llvm::make_range(worklist_begin, worklist_end))
287 all_scs.erase(worklist_begin, all_scs.end());
294 llvm::StringRef log_ident) {
299 "error: Unable to set breakpoint %s at file address "
307 "Breakpoint %s at file address 0x%" PRIx64
308 " didn't pass the filter.\n",
313 bool skipped_prologue =
false;
316 if (prologue_addr.
IsValid() && (line_start == prologue_addr)) {
318 if (prologue_byte_size) {
319 prologue_addr.
Slide(prologue_byte_size);
322 skipped_prologue =
true;
323 line_start = prologue_addr;
329 BreakpointLocationSP bp_loc_sp(
AddLocation(line_start));
333 LLDB_LOGF(log,
"Added location (skipped prologue: %s): %s \n",
334 skipped_prologue ?
"yes" :
"no", s.
GetData());
339 bool *new_location) {
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Address & GetBaseAddress()
Get accessor for the base address of the range.
A section + offset based address class.
bool Slide(int64_t offset)
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict, Status &error)
static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &data_dict, Status &error)
static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict, Status &error)
static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &data_dict, Status &error)
static BreakpointResolver * CreateFromStructuredData(const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict, Status &error)
General Outline: The BreakpointResolver is a Searcher.
const char * GetResolverName()
void SetBreakpoint(const lldb::BreakpointSP &bkpt)
This sets the breakpoint for this resolver.
~BreakpointResolver() override
The Destructor is virtual, all significant breakpoint resolvers derive from this class.
lldb::BreakpointLocationSP AddLocation(Address loc_addr, bool *new_location=nullptr)
static const char * GetKey(OptionNames enum_value)
static lldb::BreakpointResolverSP CreateFromStructuredData(const StructuredData::Dictionary &resolver_dict, Status &error)
This section handles serializing and deserializing from StructuredData objects.
static ResolverTy NameToResolverTy(llvm::StringRef name)
StructuredData::DictionarySP WrapOptionsDict(StructuredData::DictionarySP options_dict_sp)
BreakpointResolver(const lldb::BreakpointSP &bkpt, unsigned char resolverType, lldb::addr_t offset=0)
The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint to make sense.
ResolverTy
An enumeration for keeping track of the concrete subclass that is actually instantiated.
void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident, uint32_t line=0, std::optional< uint16_t > column=std::nullopt)
Takes a symbol context list of matches which supposedly represent the same file and line number in a ...
lldb::BreakpointSP GetBreakpoint() const
This gets the breakpoint for this resolver.
void SetOffset(lldb::addr_t offset)
This updates the offset for this breakpoint.
static const char * g_option_names[static_cast< uint32_t >(OptionNames::LastOptionName)]
static const char * ResolverTyToName(enum ResolverTy)
virtual void NotifyBreakpointSet()
static const char * g_ty_to_name[LastKnownResolverType+2]
static const char * GetSerializationSubclassKey()
virtual void ResolveBreakpointInModules(SearchFilter &filter, ModuleList &modules)
In response to this method the resolver scans the modules in the module list modules,...
static const char * GetSerializationSubclassOptionsKey()
virtual void ResolveBreakpoint(SearchFilter &filter)
In response to this method the resolver scans all the modules in the breakpoint's target,...
lldb::BreakpointWP m_breakpoint
const AddressRange & GetAddressRange()
uint32_t GetPrologueByteSize()
Get the size of the prologue instructions for this function.
A collection class for Module objects.
General Outline: Provides the callback and search depth for the SearchFilter search.
virtual void SearchInModuleList(Searcher &searcher, ModuleList &modules)
Call this method to do the search using the Searcher in the module list modules.
virtual bool AddressPasses(Address &addr)
Call this method with a Address to see if address passes the filter.
virtual void Search(Searcher &searcher)
Call this method to do the search using the Searcher.
const char * GetData() const
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
bool GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
virtual bool IsValid() const
std::shared_ptr< Dictionary > DictionarySP
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Block * block
The Block for a given query.
LineEntry line_entry
The LineEntry for a given query.
#define LLDB_INVALID_COLUMN_NUMBER
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
bool operator<(const Address &lhs, const Address &rhs)
@ eDescriptionLevelVerbose
AddressRange range
The section offset address range for this line entry.
uint32_t line
The source line number, or zero if there is no line number information.