28 const char *name_cstr, FunctionNameType name_type_mask,
32 m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) {
35 if (!m_regex.IsValid()) {
39 log->
Warning(
"function name regexp: \"%s\" did not compile.",
43 AddNameLookup(
ConstString(name_cstr), name_type_mask);
48 const BreakpointSP &bkpt,
const char *names[],
size_t num_names,
52 m_match_type(
Breakpoint::Exact), m_language(language),
53 m_skip_prologue(skip_prologue) {
54 for (
size_t i = 0; i < num_names; i++) {
55 AddNameLookup(
ConstString(names[i]), name_type_mask);
60 const BreakpointSP &bkpt,
const std::vector<std::string> &names,
64 m_match_type(
Breakpoint::Exact), m_language(language),
65 m_skip_prologue(skip_prologue) {
66 for (
const std::string &name : names) {
67 AddNameLookup(
ConstString(name.c_str(), name.size()), name_type_mask);
77 m_class_name(nullptr), m_regex(std::move(func_regex)),
78 m_match_type(
Breakpoint::Regexp), m_language(language),
79 m_skip_prologue(skip_prologue) {}
85 m_lookups(rhs.m_lookups), m_class_name(rhs.m_class_name),
86 m_regex(rhs.m_regex), m_match_type(rhs.m_match_type),
87 m_language(rhs.m_language), m_skip_prologue(rhs.m_skip_prologue) {}
92 llvm::StringRef language_name;
98 error.SetErrorStringWithFormatv(
"BRN::CFSD: Unknown language: {0}.",
108 error.SetErrorString(
"BRN::CFSD: Missing offset entry.");
116 error.SetErrorString(
"BRN::CFSD: Missing Skip prologue entry.");
120 llvm::StringRef regex_text;
124 return std::make_shared<BreakpointResolverName>(
132 error.SetErrorString(
"BRN::CFSD: Missing symbol names entry.");
139 error.SetErrorString(
"BRN::CFSD: Missing symbol names mask entry.");
143 size_t num_elem = names_array->
GetSize();
144 if (num_elem != names_mask_array->
GetSize()) {
145 error.SetErrorString(
146 "BRN::CFSD: names and names mask arrays have different sizes.");
151 error.SetErrorString(
152 "BRN::CFSD: no name entry in a breakpoint by name breakpoint.");
155 std::vector<std::string> names;
156 std::vector<FunctionNameType> name_masks;
157 for (
size_t i = 0; i < num_elem; i++) {
158 std::optional<llvm::StringRef> maybe_name =
161 error.SetErrorString(
"BRN::CFSD: name entry is not a string.");
165 std::underlying_type<FunctionNameType>::type>(i);
167 error.SetErrorString(
"BRN::CFSD: name mask entry is not an integer.");
170 names.push_back(std::string(*maybe_name));
171 name_masks.push_back(
static_cast<FunctionNameType
>(*maybe_fnt));
174 std::shared_ptr<BreakpointResolverName> resolver_sp =
175 std::make_shared<BreakpointResolverName>(
176 nullptr, names[0].c_str(), name_masks[0], language,
178 for (
size_t i = 1; i < num_elem; i++) {
179 resolver_sp->AddNameLookup(
ConstString(names[i]), name_masks[i]);
205 options_dict_sp->AddStringItem(
215 FunctionNameType name_type_mask) {
220 auto add_variant_funcs = [&](
Language *lang) {
222 lang->GetMethodNameVariants(name)) {
224 if (variant.GetType() & lldb::eFunctionNameTypeFull) {
226 lang->GetLanguageType());
235 add_variant_funcs(lang);
257 log->
Warning(
"Class/method function specification not supported yet.\n");
274 const size_t start_func_idx = func_list.
GetSize();
276 function_options, func_list);
278 const size_t end_func_idx = func_list.
GetSize();
280 if (start_func_idx < end_func_idx)
281 lookup.Prune(func_list, start_func_idx);
292 log->
Warning(
"glob is not supported yet.");
298 if (filter_by_cu || filter_by_language) {
299 uint32_t num_functions = func_list.
GetSize();
301 for (
size_t idx = 0; idx < num_functions; idx++) {
302 bool remove_it =
false;
310 if (filter_by_language) {
333 bool is_reexported =
false;
335 if (sc.block && sc.block->GetInlinedFunctionInfo()) {
336 if (!sc.block->GetStartAddress(break_addr))
338 }
else if (sc.function) {
339 break_addr = sc.function->GetAddressRange().GetBaseAddress();
341 const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
342 if (prologue_byte_size)
345 }
else if (sc.symbol) {
347 const Symbol *actual_symbol =
350 is_reexported =
true;
354 break_addr = sc.symbol->GetAddress();
358 const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
359 if (prologue_byte_size)
378 bp_loc_sp->SetIsReExported(is_reexported);
379 if (bp_loc_sp && new_location && !breakpoint.
IsInternal()) {
404 for (
size_t i = 0; i < num_names; i++) {
405 s->
Printf(
"%s'%s'", (i == 0 ?
"" :
", "),
421 ret_sp->SetBreakpoint(breakpoint);
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
static llvm::StringRef GetName(XcodeSDK::Type type)
A section + offset based address class.
void Clear()
Clear the object's state.
lldb::addr_t GetOffset() const
Get the section relative offset value.
bool IsValid() const
Check if the object state is valid.
bool SetOffset(lldb::addr_t offset)
Set accessor for the offset.
virtual void AdjustBreakpointAddress(const Symbol &func, Address &addr) const
Adjust function breakpoint address, if needed.
"lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on a given function name,...
void AddNameLookup(ConstString name, lldb::FunctionNameType name_type_mask)
std::vector< Module::LookupInfo > m_lookups
void Dump(Stream *s) const override
Standard "Dump" method. At present it does nothing.
Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr) override
lldb::BreakpointResolverSP CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override
StructuredData::ObjectSP SerializeToStructuredData() override
Breakpoint::MatchType m_match_type
lldb::LanguageType m_language
BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue)
static lldb::BreakpointResolverSP CreateFromStructuredData(const StructuredData::Dictionary &data_dict, Status &error)
void GetDescription(Stream *s) override
Prints a canonical description for the breakpoint to the stream s.
RegularExpression m_regex
lldb::SearchDepth GetDepth() override
General Outline: The BreakpointResolver is a Searcher.
lldb::BreakpointLocationSP AddLocation(Address loc_addr, bool *new_location=nullptr)
static const char * GetKey(OptionNames enum_value)
StructuredData::DictionarySP WrapOptionsDict(StructuredData::DictionarySP options_dict_sp)
lldb::BreakpointSP GetBreakpoint() const
This gets the breakpoint for this resolver.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
MatchType
An enum specifying the match style for breakpoint settings.
Target & GetTarget()
Accessor for the breakpoint Target.
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
Represents a generic declaration context in a program.
A uniqued constant string class.
static Language * FindPlugin(lldb::LanguageType language)
static const char * GetNameForLanguageType(lldb::LanguageType language)
static lldb::LanguageType GetPrimaryLanguage(lldb::LanguageType language)
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
static void ForEach(std::function< bool(Language *)> callback)
void void void void void Warning(const char *fmt,...) __attribute__((format(printf
A class that encapsulates name lookup information.
void SetLookupName(ConstString name)
bool IsValid() const
Test if this object contains a valid regular expression.
llvm::StringRef GetText() const
Access the regular expression text.
General Outline: Provides the callback and search depth for the SearchFilter search.
virtual bool AddressPasses(Address &addr)
Call this method with a Address to see if address passes the filter.
virtual bool CompUnitPasses(FileSpec &fileSpec)
Call this method with a FileSpec to see if file spec passes the filter as the name of a compilation u...
virtual uint32_t GetFilterRequiredItems()
This determines which items are REQUIRED for the filter to pass.
@ eCallbackReturnContinue
const char * GetData() const
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
std::optional< IntType > GetItemAtIndexAsInteger(size_t idx) const
std::optional< llvm::StringRef > GetItemAtIndexAsString(size_t idx) const
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
bool GetValueForKeyAsBoolean(llvm::StringRef key, bool &result) const
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
std::shared_ptr< UnsignedInteger > UnsignedIntegerSP
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< String > StringSP
std::shared_ptr< Array > ArraySP
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
bool RemoveContextAtIndex(size_t idx)
Defines a symbol context baton that can be handed other debug core functions.
lldb::LanguageType GetLanguage() const
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
Address GetAddress() const
Symbol * ResolveReExportedSymbol(Target &target) const
Architecture * GetArchitecturePlugin() const
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.
std::shared_ptr< lldb_private::BreakpointResolver > BreakpointResolverSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
@ eDescriptionLevelVerbose
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.