[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 08:23:27 +01:00
|
|
|
//===-- BreakpointResolverName.cpp ----------------------------------------===//
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-06-08 16:52:24 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2015-10-30 18:50:12 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolverName.h"
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
2018-03-12 21:17:04 +00:00
|
|
|
#include "lldb/Core/Architecture.h"
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-29 21:13:06 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
|
#include "lldb/Symbol/Function.h"
|
|
|
|
|
#include "lldb/Symbol/Symbol.h"
|
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
2019-05-11 03:32:25 +00:00
|
|
|
#include "lldb/Target/Language.h"
|
2022-02-03 13:26:10 +01:00
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
|
#include "lldb/Utility/LLDBLog.h"
|
2017-03-03 20:56:28 +00:00
|
|
|
#include "lldb/Utility/Log.h"
|
2017-02-02 21:39:50 +00:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2020-03-03 13:29:12 +03:00
|
|
|
BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
|
|
|
|
|
const char *name_cstr, FunctionNameType name_type_mask,
|
2013-04-03 02:00:15 +00:00
|
|
|
LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
|
|
|
|
|
bool skip_prologue)
|
2016-03-09 18:59:13 +00:00
|
|
|
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
|
2022-02-06 10:54:46 -08:00
|
|
|
m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (m_match_type == Breakpoint::Regexp) {
|
2021-05-18 09:03:28 +02:00
|
|
|
m_regex = RegularExpression(name_cstr);
|
2019-08-20 09:24:20 +00:00
|
|
|
if (!m_regex.IsValid()) {
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Breakpoints);
|
2012-03-03 02:05:11 +00:00
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
|
log->Warning("function name regexp: \"%s\" did not compile.",
|
2013-04-03 02:00:15 +00:00
|
|
|
name_cstr);
|
2012-03-03 02:05:11 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2013-04-03 02:00:15 +00:00
|
|
|
AddNameLookup(ConstString(name_cstr), name_type_mask);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-06 00:37:27 +00:00
|
|
|
BreakpointResolverName::BreakpointResolverName(
|
2020-03-03 13:29:12 +03:00
|
|
|
const BreakpointSP &bkpt, const char *names[], size_t num_names,
|
2018-10-25 20:45:40 +00:00
|
|
|
FunctionNameType name_type_mask, LanguageType language, lldb::addr_t offset,
|
2012-03-06 00:37:27 +00:00
|
|
|
bool skip_prologue)
|
2016-03-09 18:59:13 +00:00
|
|
|
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
|
2012-03-06 00:37:27 +00:00
|
|
|
m_match_type(Breakpoint::Exact), m_language(language),
|
|
|
|
|
m_skip_prologue(skip_prologue) {
|
2013-04-03 02:00:15 +00:00
|
|
|
for (size_t i = 0; i < num_names; i++) {
|
|
|
|
|
AddNameLookup(ConstString(names[i]), name_type_mask);
|
2012-03-06 00:37:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-12 15:32:06 -07:00
|
|
|
BreakpointResolverName::BreakpointResolverName(
|
|
|
|
|
const BreakpointSP &bkpt, const std::vector<std::string> &names,
|
|
|
|
|
FunctionNameType name_type_mask, LanguageType language, lldb::addr_t offset,
|
|
|
|
|
bool skip_prologue)
|
2016-03-09 18:59:13 +00:00
|
|
|
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
|
2011-07-12 17:06:17 +00:00
|
|
|
m_match_type(Breakpoint::Exact), m_language(language),
|
|
|
|
|
m_skip_prologue(skip_prologue) {
|
|
|
|
|
for (const std::string &name : names) {
|
2013-04-03 02:00:15 +00:00
|
|
|
AddNameLookup(ConstString(name.c_str(), name.size()), name_type_mask);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-03 13:29:12 +03:00
|
|
|
BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
|
2019-08-16 21:25:36 +00:00
|
|
|
RegularExpression func_regex,
|
2016-03-09 18:59:13 +00:00
|
|
|
lldb::LanguageType language,
|
|
|
|
|
lldb::addr_t offset,
|
2012-03-03 02:05:11 +00:00
|
|
|
bool skip_prologue)
|
2016-03-09 18:59:13 +00:00
|
|
|
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
|
2019-08-16 21:25:36 +00:00
|
|
|
m_class_name(nullptr), m_regex(std::move(func_regex)),
|
2010-06-08 16:52:24 +00:00
|
|
|
m_match_type(Breakpoint::Regexp), m_language(language),
|
2012-03-03 02:05:11 +00:00
|
|
|
m_skip_prologue(skip_prologue) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
BreakpointResolverName::BreakpointResolverName(
|
|
|
|
|
const BreakpointResolverName &rhs)
|
2020-03-03 13:29:12 +03:00
|
|
|
: BreakpointResolver(rhs.GetBreakpoint(), BreakpointResolver::NameResolver,
|
|
|
|
|
rhs.GetOffset()),
|
2014-12-06 01:28:03 +00:00
|
|
|
m_lookups(rhs.m_lookups), m_class_name(rhs.m_class_name),
|
|
|
|
|
m_regex(rhs.m_regex), m_match_type(rhs.m_match_type),
|
|
|
|
|
m_language(rhs.m_language), m_skip_prologue(rhs.m_skip_prologue) {}
|
|
|
|
|
|
2023-11-07 11:22:23 -08:00
|
|
|
BreakpointResolverSP BreakpointResolverName::CreateFromStructuredData(
|
2023-12-15 10:26:01 -08:00
|
|
|
const StructuredData::Dictionary &options_dict, Status &error) {
|
2016-09-12 23:10:56 +00:00
|
|
|
LanguageType language = eLanguageTypeUnknown;
|
2017-05-12 05:49:54 +00:00
|
|
|
llvm::StringRef language_name;
|
2016-09-12 23:10:56 +00:00
|
|
|
bool success = options_dict.GetValueForKeyAsString(
|
|
|
|
|
GetKey(OptionNames::LanguageName), language_name);
|
|
|
|
|
if (success) {
|
2016-09-17 02:00:02 +00:00
|
|
|
language = Language::GetLanguageTypeFromString(language_name);
|
2016-09-12 23:10:56 +00:00
|
|
|
if (language == eLanguageTypeUnknown) {
|
2017-05-12 05:49:54 +00:00
|
|
|
error.SetErrorStringWithFormatv("BRN::CFSD: Unknown language: {0}.",
|
|
|
|
|
language_name);
|
2016-09-12 23:10:56 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-22 13:52:09 -07:00
|
|
|
lldb::offset_t offset = 0;
|
2016-09-12 23:10:56 +00:00
|
|
|
success =
|
|
|
|
|
options_dict.GetValueForKeyAsInteger(GetKey(OptionNames::Offset), offset);
|
|
|
|
|
if (!success) {
|
2020-07-20 22:57:06 -07:00
|
|
|
error.SetErrorString("BRN::CFSD: Missing offset entry.");
|
2016-09-12 23:10:56 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool skip_prologue;
|
|
|
|
|
success = options_dict.GetValueForKeyAsBoolean(
|
|
|
|
|
GetKey(OptionNames::SkipPrologue), skip_prologue);
|
|
|
|
|
if (!success) {
|
2020-07-20 22:57:06 -07:00
|
|
|
error.SetErrorString("BRN::CFSD: Missing Skip prologue entry.");
|
2016-09-12 23:10:56 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 05:49:54 +00:00
|
|
|
llvm::StringRef regex_text;
|
2016-09-12 23:10:56 +00:00
|
|
|
success = options_dict.GetValueForKeyAsString(
|
|
|
|
|
GetKey(OptionNames::RegexString), regex_text);
|
|
|
|
|
if (success) {
|
2023-11-07 11:22:23 -08:00
|
|
|
return std::make_shared<BreakpointResolverName>(
|
2023-12-15 10:26:01 -08:00
|
|
|
nullptr, RegularExpression(regex_text), language, offset,
|
|
|
|
|
skip_prologue);
|
2016-09-12 23:10:56 +00:00
|
|
|
} else {
|
|
|
|
|
StructuredData::Array *names_array;
|
|
|
|
|
success = options_dict.GetValueForKeyAsArray(
|
|
|
|
|
GetKey(OptionNames::SymbolNameArray), names_array);
|
|
|
|
|
if (!success) {
|
2020-07-20 22:57:06 -07:00
|
|
|
error.SetErrorString("BRN::CFSD: Missing symbol names entry.");
|
2016-09-12 23:10:56 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
StructuredData::Array *names_mask_array;
|
|
|
|
|
success = options_dict.GetValueForKeyAsArray(
|
|
|
|
|
GetKey(OptionNames::NameMaskArray), names_mask_array);
|
|
|
|
|
if (!success) {
|
2020-07-20 22:57:06 -07:00
|
|
|
error.SetErrorString("BRN::CFSD: Missing symbol names mask entry.");
|
2016-09-12 23:10:56 +00:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t num_elem = names_array->GetSize();
|
|
|
|
|
if (num_elem != names_mask_array->GetSize()) {
|
|
|
|
|
error.SetErrorString(
|
|
|
|
|
"BRN::CFSD: names and names mask arrays have different sizes.");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_elem == 0) {
|
|
|
|
|
error.SetErrorString(
|
|
|
|
|
"BRN::CFSD: no name entry in a breakpoint by name breakpoint.");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
std::vector<std::string> names;
|
2018-10-25 20:45:40 +00:00
|
|
|
std::vector<FunctionNameType> name_masks;
|
2016-09-12 23:10:56 +00:00
|
|
|
for (size_t i = 0; i < num_elem; i++) {
|
2023-11-09 13:35:35 -08:00
|
|
|
std::optional<llvm::StringRef> maybe_name =
|
|
|
|
|
names_array->GetItemAtIndexAsString(i);
|
|
|
|
|
if (!maybe_name) {
|
2016-09-12 23:10:56 +00:00
|
|
|
error.SetErrorString("BRN::CFSD: name entry is not a string.");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2024-01-08 13:31:03 -08:00
|
|
|
auto maybe_fnt = names_mask_array->GetItemAtIndexAsInteger<
|
|
|
|
|
std::underlying_type<FunctionNameType>::type>(i);
|
|
|
|
|
if (!maybe_fnt) {
|
2016-09-12 23:10:56 +00:00
|
|
|
error.SetErrorString("BRN::CFSD: name mask entry is not an integer.");
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2023-11-09 13:35:35 -08:00
|
|
|
names.push_back(std::string(*maybe_name));
|
2024-01-08 13:31:03 -08:00
|
|
|
name_masks.push_back(static_cast<FunctionNameType>(*maybe_fnt));
|
2016-09-12 23:10:56 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-07 11:22:23 -08:00
|
|
|
std::shared_ptr<BreakpointResolverName> resolver_sp =
|
|
|
|
|
std::make_shared<BreakpointResolverName>(
|
2023-12-15 10:26:01 -08:00
|
|
|
nullptr, names[0].c_str(), name_masks[0], language,
|
2023-11-07 11:22:23 -08:00
|
|
|
Breakpoint::MatchType::Exact, offset, skip_prologue);
|
2016-09-12 23:10:56 +00:00
|
|
|
for (size_t i = 1; i < num_elem; i++) {
|
2023-11-07 11:22:23 -08:00
|
|
|
resolver_sp->AddNameLookup(ConstString(names[i]), name_masks[i]);
|
2016-09-12 23:10:56 +00:00
|
|
|
}
|
2023-11-07 11:22:23 -08:00
|
|
|
return resolver_sp;
|
2016-09-12 23:10:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() {
|
|
|
|
|
StructuredData::DictionarySP options_dict_sp(
|
|
|
|
|
new StructuredData::Dictionary());
|
|
|
|
|
|
|
|
|
|
if (m_regex.IsValid()) {
|
|
|
|
|
options_dict_sp->AddStringItem(GetKey(OptionNames::RegexString),
|
|
|
|
|
m_regex.GetText());
|
|
|
|
|
} else {
|
|
|
|
|
StructuredData::ArraySP names_sp(new StructuredData::Array());
|
|
|
|
|
StructuredData::ArraySP name_masks_sp(new StructuredData::Array());
|
|
|
|
|
for (auto lookup : m_lookups) {
|
|
|
|
|
names_sp->AddItem(StructuredData::StringSP(
|
2020-02-11 09:05:37 +01:00
|
|
|
new StructuredData::String(lookup.GetName().GetStringRef())));
|
2023-05-22 13:52:09 -07:00
|
|
|
name_masks_sp->AddItem(StructuredData::UnsignedIntegerSP(
|
|
|
|
|
new StructuredData::UnsignedInteger(lookup.GetNameTypeMask())));
|
2016-09-12 23:10:56 +00:00
|
|
|
}
|
|
|
|
|
options_dict_sp->AddItem(GetKey(OptionNames::SymbolNameArray), names_sp);
|
|
|
|
|
options_dict_sp->AddItem(GetKey(OptionNames::NameMaskArray), name_masks_sp);
|
|
|
|
|
}
|
|
|
|
|
if (m_language != eLanguageTypeUnknown)
|
|
|
|
|
options_dict_sp->AddStringItem(
|
|
|
|
|
GetKey(OptionNames::LanguageName),
|
|
|
|
|
Language::GetNameForLanguageType(m_language));
|
|
|
|
|
options_dict_sp->AddBooleanItem(GetKey(OptionNames::SkipPrologue),
|
|
|
|
|
m_skip_prologue);
|
|
|
|
|
|
|
|
|
|
return WrapOptionsDict(options_dict_sp);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-06 21:22:25 +00:00
|
|
|
void BreakpointResolverName::AddNameLookup(ConstString name,
|
2018-10-25 20:45:40 +00:00
|
|
|
FunctionNameType name_type_mask) {
|
2019-05-11 03:32:25 +00:00
|
|
|
|
|
|
|
|
Module::LookupInfo lookup(name, name_type_mask, m_language);
|
|
|
|
|
m_lookups.emplace_back(lookup);
|
|
|
|
|
|
|
|
|
|
auto add_variant_funcs = [&](Language *lang) {
|
2021-06-10 14:55:25 -07:00
|
|
|
for (Language::MethodNameVariant variant :
|
|
|
|
|
lang->GetMethodNameVariants(name)) {
|
|
|
|
|
// FIXME: Should we be adding variants that aren't of type Full?
|
|
|
|
|
if (variant.GetType() & lldb::eFunctionNameTypeFull) {
|
|
|
|
|
Module::LookupInfo variant_lookup(name, variant.GetType(),
|
|
|
|
|
lang->GetLanguageType());
|
|
|
|
|
variant_lookup.SetLookupName(variant.GetName());
|
|
|
|
|
m_lookups.emplace_back(variant_lookup);
|
|
|
|
|
}
|
2013-04-03 02:00:15 +00:00
|
|
|
}
|
2019-05-11 03:32:25 +00:00
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Language *lang = Language::FindPlugin(m_language)) {
|
|
|
|
|
add_variant_funcs(lang);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2019-05-11 03:32:25 +00:00
|
|
|
// Most likely m_language is eLanguageTypeUnknown. We check each language for
|
|
|
|
|
// possible variants or more qualified names and create lookups for those as
|
|
|
|
|
// well.
|
|
|
|
|
Language::ForEach(add_variant_funcs);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2013-04-03 02:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
// FIXME: Right now we look at the module level, and call the module's
|
|
|
|
|
// "FindFunctions".
|
|
|
|
|
// Greg says he will add function tables, maybe at the CompileUnit level to
|
2018-04-30 16:49:04 +00:00
|
|
|
// accelerate function lookup. At that point, we should switch the depth to
|
|
|
|
|
// CompileUnit, and look in these tables.
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
Searcher::CallbackReturn
|
2015-10-30 18:50:12 +00:00
|
|
|
BreakpointResolverName::SearchCallback(SearchFilter &filter,
|
2019-10-10 11:26:51 +00:00
|
|
|
SymbolContext &context, Address *addr) {
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Breakpoints);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (m_class_name) {
|
|
|
|
|
if (log)
|
|
|
|
|
log->Warning("Class/method function specification not supported yet.\n");
|
|
|
|
|
return Searcher::eCallbackReturnStop;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2020-03-03 13:29:12 +03:00
|
|
|
|
2020-02-12 13:50:34 +03:00
|
|
|
SymbolContextList func_list;
|
2013-06-12 00:46:38 +00:00
|
|
|
bool filter_by_cu =
|
2010-06-08 16:52:24 +00:00
|
|
|
(filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
|
|
|
|
|
bool filter_by_language = (m_language != eLanguageTypeUnknown);
|
2021-08-05 09:27:19 -07:00
|
|
|
|
|
|
|
|
ModuleFunctionSearchOptions function_options;
|
|
|
|
|
function_options.include_symbols = !filter_by_cu;
|
|
|
|
|
function_options.include_inlines = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
switch (m_match_type) {
|
|
|
|
|
case Breakpoint::Exact:
|
2010-06-28 21:30:43 +00:00
|
|
|
if (context.module_sp) {
|
2010-06-08 16:52:24 +00:00
|
|
|
for (const auto &lookup : m_lookups) {
|
2013-04-03 02:00:15 +00:00
|
|
|
const size_t start_func_idx = func_list.GetSize();
|
2022-08-04 11:53:28 -07:00
|
|
|
context.module_sp->FindFunctions(lookup, CompilerDeclContext(),
|
|
|
|
|
function_options, func_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-04-03 02:00:15 +00:00
|
|
|
const size_t end_func_idx = func_list.GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2013-04-03 02:00:15 +00:00
|
|
|
if (start_func_idx < end_func_idx)
|
2010-06-08 16:52:24 +00:00
|
|
|
lookup.Prune(func_list, start_func_idx);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2013-06-12 00:46:38 +00:00
|
|
|
break;
|
2010-06-28 21:30:43 +00:00
|
|
|
case Breakpoint::Regexp:
|
|
|
|
|
if (context.module_sp) {
|
2021-08-05 09:27:19 -07:00
|
|
|
context.module_sp->FindFunctions(m_regex, function_options, func_list);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
2010-06-28 21:30:43 +00:00
|
|
|
case Breakpoint::Glob:
|
2016-09-06 20:57:50 +00:00
|
|
|
if (log)
|
2010-06-28 21:30:43 +00:00
|
|
|
log->Warning("glob is not supported yet.");
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2011-09-23 00:54:11 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// If the filter specifies a Compilation Unit, remove the ones that don't
|
|
|
|
|
// pass at this point.
|
2015-11-06 22:48:59 +00:00
|
|
|
if (filter_by_cu || filter_by_language) {
|
2011-09-23 00:54:11 +00:00
|
|
|
uint32_t num_functions = func_list.GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-09-23 00:54:11 +00:00
|
|
|
for (size_t idx = 0; idx < num_functions; idx++) {
|
2015-11-06 22:48:59 +00:00
|
|
|
bool remove_it = false;
|
2011-09-23 00:54:11 +00:00
|
|
|
SymbolContext sc;
|
|
|
|
|
func_list.GetContextAtIndex(idx, sc);
|
2015-11-06 22:48:59 +00:00
|
|
|
if (filter_by_cu) {
|
|
|
|
|
if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit))
|
|
|
|
|
remove_it = true;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-11-06 22:48:59 +00:00
|
|
|
if (filter_by_language) {
|
2015-12-16 19:40:00 +00:00
|
|
|
LanguageType sym_language = sc.GetLanguage();
|
|
|
|
|
if ((Language::GetPrimaryLanguage(sym_language) !=
|
|
|
|
|
Language::GetPrimaryLanguage(m_language)) &&
|
|
|
|
|
(sym_language != eLanguageTypeUnknown)) {
|
|
|
|
|
remove_it = true;
|
2011-09-23 00:54:11 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-06 22:48:59 +00:00
|
|
|
if (remove_it) {
|
2011-09-23 00:54:11 +00:00
|
|
|
func_list.RemoveContextAtIndex(idx);
|
|
|
|
|
num_functions--;
|
2016-09-06 20:57:50 +00:00
|
|
|
idx--;
|
|
|
|
|
}
|
2011-09-23 00:54:11 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-03 13:29:12 +03:00
|
|
|
BreakpointSP breakpoint_sp = GetBreakpoint();
|
|
|
|
|
Breakpoint &breakpoint = *breakpoint_sp;
|
2020-02-12 13:50:34 +03:00
|
|
|
Address break_addr;
|
2020-03-03 13:29:12 +03:00
|
|
|
|
2014-07-01 21:22:11 +00:00
|
|
|
// Remove any duplicates between the function list and the symbol list
|
2023-05-04 18:19:15 -07:00
|
|
|
for (const SymbolContext &sc : func_list) {
|
2020-04-03 14:49:47 +02:00
|
|
|
bool is_reexported = false;
|
|
|
|
|
|
|
|
|
|
if (sc.block && sc.block->GetInlinedFunctionInfo()) {
|
|
|
|
|
if (!sc.block->GetStartAddress(break_addr))
|
|
|
|
|
break_addr.Clear();
|
|
|
|
|
} else if (sc.function) {
|
|
|
|
|
break_addr = sc.function->GetAddressRange().GetBaseAddress();
|
|
|
|
|
if (m_skip_prologue && break_addr.IsValid()) {
|
|
|
|
|
const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
|
|
|
|
|
if (prologue_byte_size)
|
|
|
|
|
break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
|
|
|
|
|
}
|
|
|
|
|
} else if (sc.symbol) {
|
|
|
|
|
if (sc.symbol->GetType() == eSymbolTypeReExported) {
|
|
|
|
|
const Symbol *actual_symbol =
|
|
|
|
|
sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
|
|
|
|
|
if (actual_symbol) {
|
|
|
|
|
is_reexported = true;
|
|
|
|
|
break_addr = actual_symbol->GetAddress();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2020-04-03 14:49:47 +02:00
|
|
|
} else {
|
|
|
|
|
break_addr = sc.symbol->GetAddress();
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-04-03 14:49:47 +02:00
|
|
|
if (m_skip_prologue && break_addr.IsValid()) {
|
|
|
|
|
const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
|
|
|
|
|
if (prologue_byte_size)
|
|
|
|
|
break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
|
|
|
|
|
else {
|
|
|
|
|
const Architecture *arch =
|
|
|
|
|
breakpoint.GetTarget().GetArchitecturePlugin();
|
|
|
|
|
if (arch)
|
|
|
|
|
arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2020-04-03 14:49:47 +02:00
|
|
|
|
|
|
|
|
if (!break_addr.IsValid())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!filter.AddressPasses(break_addr))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
bool new_location;
|
|
|
|
|
BreakpointLocationSP bp_loc_sp(AddLocation(break_addr, &new_location));
|
|
|
|
|
bp_loc_sp->SetIsReExported(is_reexported);
|
|
|
|
|
if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
|
|
|
|
|
if (log) {
|
|
|
|
|
StreamString s;
|
|
|
|
|
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
|
|
|
|
|
LLDB_LOGF(log, "Added location: %s\n", s.GetData());
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
return Searcher::eCallbackReturnContinue;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-07 18:43:04 +00:00
|
|
|
lldb::SearchDepth BreakpointResolverName::GetDepth() {
|
|
|
|
|
return lldb::eSearchDepthModule;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakpointResolverName::GetDescription(Stream *s) {
|
|
|
|
|
if (m_match_type == Breakpoint::Regexp)
|
2016-09-21 16:01:28 +00:00
|
|
|
s->Printf("regex = '%s'", m_regex.GetText().str().c_str());
|
2010-10-12 04:29:14 +00:00
|
|
|
else {
|
2013-04-03 02:00:15 +00:00
|
|
|
size_t num_names = m_lookups.size();
|
2012-03-03 02:05:11 +00:00
|
|
|
if (num_names == 1)
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-13 17:12:24 +00:00
|
|
|
s->Printf("name = '%s'", m_lookups[0].GetName().GetCString());
|
2012-03-03 02:05:11 +00:00
|
|
|
else {
|
|
|
|
|
s->Printf("names = {");
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-13 17:12:24 +00:00
|
|
|
for (size_t i = 0; i < num_names; i++) {
|
|
|
|
|
s->Printf("%s'%s'", (i == 0 ? "" : ", "),
|
|
|
|
|
m_lookups[i].GetName().GetCString());
|
2012-03-03 02:05:11 +00:00
|
|
|
}
|
Centralize the way symbol and functions are looked up by making a Module::LookupInfo class that does all of the heavy lifting.
Background: symbols and functions can be looked up by full mangled name and by basename. SymbolFile and ObjectFile are expected to be able to do the lookups based on full mangled name or by basename, so when the user types something that is incomplete, we must be able to look it up efficiently. For example the user types "a::b::c" as a symbol to set a breakpoint on, we will break this down into a 'lookup "c"' and then weed out N matches down to just the ones that match "a::b::c". Previously this was done manaully in many functions by calling Module::PrepareForFunctionNameLookup(...) and then doing the lookup and manually pruning the results down afterward with duplicated code. Now all places use Module::LookupInfo to do the work in one place.
This allowed me to fix the name lookups to look for "func" with eFunctionNameTypeFull as the "name_type_mask", and correctly weed the results:
"func", "func()", "func(int)", "a::func()", "b::func()", and "a::b::func()" down to just "func", "func()", "func(int)". Previously we would have set 6 breakpoints, now we correctly set just 3. This also extends to the expression parser when it looks up names for functions it needs to not get multiple results so we can call the correct function.
<rdar://problem/24599697>
llvm-svn: 275281
2016-07-13 17:12:24 +00:00
|
|
|
s->Printf("}");
|
2015-11-06 22:48:59 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2015-11-06 22:48:59 +00:00
|
|
|
if (m_language != eLanguageTypeUnknown) {
|
|
|
|
|
s->Printf(", language = %s", Language::GetNameForLanguageType(m_language));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BreakpointResolverName::Dump(Stream *s) const {}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
lldb::BreakpointResolverSP
|
2020-03-03 13:29:12 +03:00
|
|
|
BreakpointResolverName::CopyForBreakpoint(BreakpointSP &breakpoint) {
|
2014-12-06 01:28:03 +00:00
|
|
|
lldb::BreakpointResolverSP ret_sp(new BreakpointResolverName(*this));
|
2020-03-03 13:29:12 +03:00
|
|
|
ret_sp->SetBreakpoint(breakpoint);
|
2014-12-06 01:28:03 +00:00
|
|
|
return ret_sp;
|
|
|
|
|
}
|