[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
|
|
|
//===-- Breakpoint.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 "llvm/Support/Casting.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
#include "lldb/Breakpoint/Breakpoint.h"
|
|
|
|
|
#include "lldb/Breakpoint/BreakpointLocation.h"
|
2010-10-28 17:27:46 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
|
2019-06-21 19:43:07 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointPrecondition.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolver.h"
|
2010-10-28 17:27:46 +00:00
|
|
|
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Core/Address.h"
|
2025-06-18 13:06:20 -07:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2014-09-10 21:40:47 +00:00
|
|
|
#include "lldb/Core/Module.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Core/ModuleList.h"
|
|
|
|
|
#include "lldb/Core/SearchFilter.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/Section.h"
|
2014-09-10 21:40:47 +00:00
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
|
#include "lldb/Symbol/Function.h"
|
2017-04-06 21:28:29 +00:00
|
|
|
#include "lldb/Symbol/Symbol.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
2022-02-03 13:26:10 +01:00
|
|
|
#include "lldb/Target/SectionLoadList.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-16 02:00:15 +00:00
|
|
|
#include "lldb/Target/ThreadSpec.h"
|
2025-06-18 13:06:20 -07:00
|
|
|
#include "lldb/Utility/AnsiTerminal.h"
|
2022-02-03 13:26:10 +01:00
|
|
|
#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/Stream.h"
|
|
|
|
|
#include "lldb/Utility/StreamString.h"
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2019-02-11 23:13:08 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
2010-10-28 17:27:46 +00:00
|
|
|
using namespace llvm;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2016-09-20 22:54:49 +00:00
|
|
|
const char *Breakpoint::g_option_names[static_cast<uint32_t>(
|
|
|
|
|
Breakpoint::OptionNames::LastOptionName)]{"Names", "Hardware"};
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
// Breakpoint constructor
|
2014-01-10 23:46:59 +00:00
|
|
|
Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
|
|
|
|
|
BreakpointResolverSP &resolver_sp, bool hardware,
|
|
|
|
|
bool resolve_indirect_symbols)
|
2024-01-31 14:44:52 -08:00
|
|
|
: m_hardware(hardware), m_target(target), m_filter_sp(filter_sp),
|
|
|
|
|
m_resolver_sp(resolver_sp), m_options(true), m_locations(*this),
|
|
|
|
|
m_resolve_indirect_symbols(resolve_indirect_symbols), m_hit_counter() {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2020-02-13 16:48:38 +03:00
|
|
|
Breakpoint::Breakpoint(Target &new_target, const Breakpoint &source_bp)
|
2024-01-31 14:44:52 -08:00
|
|
|
: m_hardware(source_bp.m_hardware), m_target(new_target),
|
|
|
|
|
m_name_list(source_bp.m_name_list), m_options(source_bp.m_options),
|
|
|
|
|
m_locations(*this),
|
2015-01-15 01:41:04 +00:00
|
|
|
m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
|
2020-07-23 18:41:14 +03:00
|
|
|
m_hit_counter() {}
|
2014-12-06 01:28:03 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
// Destructor
|
2025-10-09 08:37:21 -07:00
|
|
|
Breakpoint::~Breakpoint() {
|
|
|
|
|
for (BreakpointLocationSP location_sp : m_locations.BreakpointLocations())
|
|
|
|
|
location_sp->SetInvalid();
|
|
|
|
|
for (BreakpointLocationSP location_sp :
|
|
|
|
|
m_facade_locations.BreakpointLocations())
|
|
|
|
|
location_sp->SetInvalid();
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2020-02-13 15:51:13 +03:00
|
|
|
BreakpointSP Breakpoint::CopyFromBreakpoint(TargetSP new_target,
|
2025-07-03 11:17:19 -07:00
|
|
|
const Breakpoint &bp_to_copy_from) {
|
2020-02-13 15:51:13 +03:00
|
|
|
if (!new_target)
|
|
|
|
|
return BreakpointSP();
|
|
|
|
|
|
|
|
|
|
BreakpointSP bp(new Breakpoint(*new_target, bp_to_copy_from));
|
2020-02-13 16:48:38 +03:00
|
|
|
// Now go through and copy the filter & resolver:
|
2020-03-03 13:29:12 +03:00
|
|
|
bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(bp);
|
2020-02-12 16:16:57 +03:00
|
|
|
bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CreateCopy(new_target);
|
2020-02-13 16:48:38 +03:00
|
|
|
return bp;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-12 23:10:56 +00:00
|
|
|
// Serialization
|
|
|
|
|
StructuredData::ObjectSP Breakpoint::SerializeToStructuredData() {
|
|
|
|
|
// Serialize the resolver:
|
|
|
|
|
StructuredData::DictionarySP breakpoint_dict_sp(
|
|
|
|
|
new StructuredData::Dictionary());
|
|
|
|
|
StructuredData::DictionarySP breakpoint_contents_sp(
|
|
|
|
|
new StructuredData::Dictionary());
|
|
|
|
|
|
2016-09-20 22:54:49 +00:00
|
|
|
if (!m_name_list.empty()) {
|
|
|
|
|
StructuredData::ArraySP names_array_sp(new StructuredData::Array());
|
|
|
|
|
for (auto name : m_name_list) {
|
2025-07-25 15:55:21 -07:00
|
|
|
names_array_sp->AddItem(std::make_shared<StructuredData::String>(name));
|
2016-09-20 22:54:49 +00:00
|
|
|
}
|
|
|
|
|
breakpoint_contents_sp->AddItem(Breakpoint::GetKey(OptionNames::Names),
|
|
|
|
|
names_array_sp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
breakpoint_contents_sp->AddBooleanItem(
|
|
|
|
|
Breakpoint::GetKey(OptionNames::Hardware), m_hardware);
|
|
|
|
|
|
2016-09-12 23:10:56 +00:00
|
|
|
StructuredData::ObjectSP resolver_dict_sp(
|
|
|
|
|
m_resolver_sp->SerializeToStructuredData());
|
|
|
|
|
if (!resolver_dict_sp)
|
|
|
|
|
return StructuredData::ObjectSP();
|
|
|
|
|
|
|
|
|
|
breakpoint_contents_sp->AddItem(BreakpointResolver::GetSerializationKey(),
|
|
|
|
|
resolver_dict_sp);
|
|
|
|
|
|
|
|
|
|
StructuredData::ObjectSP filter_dict_sp(
|
|
|
|
|
m_filter_sp->SerializeToStructuredData());
|
|
|
|
|
if (!filter_dict_sp)
|
|
|
|
|
return StructuredData::ObjectSP();
|
|
|
|
|
|
|
|
|
|
breakpoint_contents_sp->AddItem(SearchFilter::GetSerializationKey(),
|
|
|
|
|
filter_dict_sp);
|
|
|
|
|
|
|
|
|
|
StructuredData::ObjectSP options_dict_sp(
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SerializeToStructuredData());
|
2016-09-12 23:10:56 +00:00
|
|
|
if (!options_dict_sp)
|
|
|
|
|
return StructuredData::ObjectSP();
|
|
|
|
|
|
|
|
|
|
breakpoint_contents_sp->AddItem(BreakpointOptions::GetSerializationKey(),
|
|
|
|
|
options_dict_sp);
|
|
|
|
|
|
|
|
|
|
breakpoint_dict_sp->AddItem(GetSerializationKey(), breakpoint_contents_sp);
|
|
|
|
|
return breakpoint_dict_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
|
2020-02-13 15:51:13 +03:00
|
|
|
TargetSP target_sp, StructuredData::ObjectSP &object_data, Status &error) {
|
2016-09-12 23:10:56 +00:00
|
|
|
BreakpointSP result_sp;
|
2020-02-13 15:51:13 +03:00
|
|
|
if (!target_sp)
|
|
|
|
|
return result_sp;
|
2016-09-12 23:10:56 +00:00
|
|
|
|
|
|
|
|
StructuredData::Dictionary *breakpoint_dict = object_data->GetAsDictionary();
|
|
|
|
|
|
|
|
|
|
if (!breakpoint_dict || !breakpoint_dict->IsValid()) {
|
2024-08-27 10:59:31 -07:00
|
|
|
error = Status::FromErrorString(
|
|
|
|
|
"Can't deserialize from an invalid data object.");
|
2016-09-12 23:10:56 +00:00
|
|
|
return result_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructuredData::Dictionary *resolver_dict;
|
|
|
|
|
bool success = breakpoint_dict->GetValueForKeyAsDictionary(
|
|
|
|
|
BreakpointResolver::GetSerializationKey(), resolver_dict);
|
|
|
|
|
if (!success) {
|
2024-08-27 10:59:31 -07:00
|
|
|
error = Status::FromErrorString(
|
|
|
|
|
"Breakpoint data missing toplevel resolver key");
|
2016-09-12 23:10:56 +00:00
|
|
|
return result_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status create_error;
|
2016-09-12 23:10:56 +00:00
|
|
|
BreakpointResolverSP resolver_sp =
|
|
|
|
|
BreakpointResolver::CreateFromStructuredData(*resolver_dict,
|
|
|
|
|
create_error);
|
|
|
|
|
if (create_error.Fail()) {
|
2024-08-27 10:59:31 -07:00
|
|
|
error = Status::FromErrorStringWithFormatv(
|
|
|
|
|
"Error creating breakpoint resolver from data: {0}.", create_error);
|
2016-09-12 23:10:56 +00:00
|
|
|
return result_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StructuredData::Dictionary *filter_dict;
|
|
|
|
|
success = breakpoint_dict->GetValueForKeyAsDictionary(
|
|
|
|
|
SearchFilter::GetSerializationKey(), filter_dict);
|
|
|
|
|
SearchFilterSP filter_sp;
|
|
|
|
|
if (!success)
|
2020-02-13 15:51:13 +03:00
|
|
|
filter_sp =
|
|
|
|
|
std::make_shared<SearchFilterForUnconstrainedSearches>(target_sp);
|
2016-09-12 23:10:56 +00:00
|
|
|
else {
|
2020-02-13 15:51:13 +03:00
|
|
|
filter_sp = SearchFilter::CreateFromStructuredData(target_sp, *filter_dict,
|
2025-07-03 11:17:19 -07:00
|
|
|
create_error);
|
2016-09-12 23:10:56 +00:00
|
|
|
if (create_error.Fail()) {
|
2024-08-27 10:59:31 -07:00
|
|
|
error = Status::FromErrorStringWithFormat(
|
2016-09-12 23:10:56 +00:00
|
|
|
"Error creating breakpoint filter from data: %s.",
|
|
|
|
|
create_error.AsCString());
|
|
|
|
|
return result_sp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-13 01:58:08 +00:00
|
|
|
std::unique_ptr<BreakpointOptions> options_up;
|
2016-09-12 23:10:56 +00:00
|
|
|
StructuredData::Dictionary *options_dict;
|
2025-07-03 11:17:19 -07:00
|
|
|
Target &target = *target_sp;
|
2016-09-12 23:10:56 +00:00
|
|
|
success = breakpoint_dict->GetValueForKeyAsDictionary(
|
|
|
|
|
BreakpointOptions::GetSerializationKey(), options_dict);
|
|
|
|
|
if (success) {
|
2016-09-26 19:47:37 +00:00
|
|
|
options_up = BreakpointOptions::CreateFromStructuredData(
|
|
|
|
|
target, *options_dict, create_error);
|
2016-09-12 23:10:56 +00:00
|
|
|
if (create_error.Fail()) {
|
2024-08-27 10:59:31 -07:00
|
|
|
error = Status::FromErrorStringWithFormat(
|
2016-09-12 23:10:56 +00:00
|
|
|
"Error creating breakpoint options from data: %s.",
|
|
|
|
|
create_error.AsCString());
|
|
|
|
|
return result_sp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-20 22:54:49 +00:00
|
|
|
|
|
|
|
|
bool hardware = false;
|
|
|
|
|
success = breakpoint_dict->GetValueForKeyAsBoolean(
|
|
|
|
|
Breakpoint::GetKey(OptionNames::Hardware), hardware);
|
|
|
|
|
|
2025-07-03 11:17:19 -07:00
|
|
|
result_sp =
|
|
|
|
|
target.CreateBreakpoint(filter_sp, resolver_sp, false, hardware, true);
|
2016-09-20 22:54:49 +00:00
|
|
|
|
2016-09-13 01:58:08 +00:00
|
|
|
if (result_sp && options_up) {
|
2021-06-11 17:00:46 -07:00
|
|
|
result_sp->m_options = *options_up;
|
2016-09-12 23:10:56 +00:00
|
|
|
}
|
2016-09-20 22:54:49 +00:00
|
|
|
|
|
|
|
|
StructuredData::Array *names_array;
|
|
|
|
|
success = breakpoint_dict->GetValueForKeyAsArray(
|
|
|
|
|
Breakpoint::GetKey(OptionNames::Names), names_array);
|
|
|
|
|
if (success && names_array) {
|
|
|
|
|
size_t num_names = names_array->GetSize();
|
|
|
|
|
for (size_t i = 0; i < num_names; i++) {
|
2023-11-09 13:35:35 -08:00
|
|
|
if (std::optional<llvm::StringRef> maybe_name =
|
|
|
|
|
names_array->GetItemAtIndexAsString(i))
|
|
|
|
|
target.AddNameToBreakpoint(result_sp, *maybe_name, error);
|
2016-09-20 22:54:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-12 23:10:56 +00:00
|
|
|
return result_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-22 22:20:28 +00:00
|
|
|
bool Breakpoint::SerializedBreakpointMatchesNames(
|
|
|
|
|
StructuredData::ObjectSP &bkpt_object_sp, std::vector<std::string> &names) {
|
|
|
|
|
if (!bkpt_object_sp)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
StructuredData::Dictionary *bkpt_dict = bkpt_object_sp->GetAsDictionary();
|
|
|
|
|
if (!bkpt_dict)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (names.empty())
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
StructuredData::Array *names_array;
|
|
|
|
|
|
|
|
|
|
bool success =
|
|
|
|
|
bkpt_dict->GetValueForKeyAsArray(GetKey(OptionNames::Names), names_array);
|
|
|
|
|
// If there are no names, it can't match these names;
|
|
|
|
|
if (!success)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
size_t num_names = names_array->GetSize();
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < num_names; i++) {
|
2023-11-09 13:35:35 -08:00
|
|
|
std::optional<llvm::StringRef> maybe_name =
|
|
|
|
|
names_array->GetItemAtIndexAsString(i);
|
|
|
|
|
if (maybe_name && llvm::is_contained(names, *maybe_name))
|
|
|
|
|
return true;
|
2016-09-22 22:20:28 +00:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
const lldb::TargetSP Breakpoint::GetTargetSP() {
|
|
|
|
|
return m_target.shared_from_this();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-06 01:28:03 +00:00
|
|
|
bool Breakpoint::IsInternal() const { return LLDB_BREAK_ID_IS_INTERNAL(m_bid); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2025-07-03 11:17:19 -07:00
|
|
|
llvm::Error Breakpoint::SetIsHardware(bool is_hardware) {
|
|
|
|
|
if (is_hardware == m_hardware)
|
|
|
|
|
return llvm::Error::success();
|
|
|
|
|
|
2025-07-09 13:19:02 -07:00
|
|
|
Log *log = GetLog(LLDBLog::Breakpoints);
|
|
|
|
|
|
2025-07-03 11:17:19 -07:00
|
|
|
// Disable all non-hardware breakpoint locations.
|
|
|
|
|
std::vector<BreakpointLocationSP> locations;
|
|
|
|
|
for (BreakpointLocationSP location_sp : m_locations.BreakpointLocations()) {
|
|
|
|
|
if (!location_sp || !location_sp->IsEnabled())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
lldb::BreakpointSiteSP breakpoint_site_sp =
|
|
|
|
|
location_sp->GetBreakpointSite();
|
|
|
|
|
if (!breakpoint_site_sp ||
|
|
|
|
|
breakpoint_site_sp->GetType() == BreakpointSite::eHardware)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
locations.push_back(location_sp);
|
2025-07-09 13:19:02 -07:00
|
|
|
if (llvm::Error error = location_sp->SetEnabled(false))
|
|
|
|
|
LLDB_LOG_ERROR(log, std::move(error),
|
|
|
|
|
"Failed to disable breakpoint location: {0}");
|
2025-07-03 11:17:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Toggle the hardware mode.
|
|
|
|
|
m_hardware = is_hardware;
|
|
|
|
|
|
|
|
|
|
// Re-enable all breakpoint locations.
|
|
|
|
|
size_t num_failures = 0;
|
|
|
|
|
for (BreakpointLocationSP location_sp : locations) {
|
2025-07-09 13:19:02 -07:00
|
|
|
if (llvm::Error error = location_sp->SetEnabled(true)) {
|
|
|
|
|
LLDB_LOG_ERROR(log, std::move(error),
|
|
|
|
|
"Failed to re-enable breakpoint location: {0}");
|
2025-07-03 11:17:19 -07:00
|
|
|
num_failures++;
|
2025-07-09 13:19:02 -07:00
|
|
|
}
|
2025-07-03 11:17:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num_failures != 0)
|
|
|
|
|
return llvm::createStringError(
|
|
|
|
|
"%ull out of %ull breakpoint locations left disabled because they "
|
|
|
|
|
"couldn't be converted to hardware",
|
|
|
|
|
num_failures, locations.size());
|
|
|
|
|
|
|
|
|
|
return llvm::Error::success();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-05 00:38:04 +00:00
|
|
|
BreakpointLocationSP Breakpoint::AddLocation(const Address &addr,
|
|
|
|
|
bool *new_location) {
|
2014-01-10 23:46:59 +00:00
|
|
|
return m_locations.AddLocation(addr, m_resolve_indirect_symbols,
|
|
|
|
|
new_location);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2025-10-09 08:37:21 -07:00
|
|
|
BreakpointLocationSP Breakpoint::AddFacadeLocation() {
|
|
|
|
|
size_t next_id = m_facade_locations.GetSize() + 1;
|
|
|
|
|
BreakpointLocationSP break_loc_sp =
|
|
|
|
|
std::make_shared<BreakpointLocation>(next_id, *this);
|
|
|
|
|
break_loc_sp->m_is_facade = true;
|
|
|
|
|
m_facade_locations.Add(break_loc_sp);
|
|
|
|
|
return break_loc_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakpointLocationSP
|
|
|
|
|
Breakpoint::GetFacadeLocationByID(lldb::break_id_t loc_id) {
|
|
|
|
|
return m_facade_locations.GetByIndex(loc_id - 1);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-05 00:38:04 +00:00
|
|
|
BreakpointLocationSP Breakpoint::FindLocationByAddress(const Address &addr) {
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_locations.FindByAddress(addr);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-05 00:38:04 +00:00
|
|
|
break_id_t Breakpoint::FindLocationIDByAddress(const Address &addr) {
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_locations.FindIDByAddress(addr);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-09 08:37:21 -07:00
|
|
|
BreakpointLocationSP Breakpoint::FindLocationByID(break_id_t bp_loc_id,
|
|
|
|
|
bool use_facade) {
|
|
|
|
|
if (use_facade && m_facade_locations.GetSize())
|
|
|
|
|
return GetFacadeLocationByID(bp_loc_id);
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_locations.FindByID(bp_loc_id);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-09 08:37:21 -07:00
|
|
|
BreakpointLocationSP Breakpoint::GetLocationAtIndex(size_t index,
|
|
|
|
|
bool use_facade) {
|
|
|
|
|
if (use_facade && m_facade_locations.GetSize() > 0)
|
|
|
|
|
return m_facade_locations.GetByIndex(index);
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_locations.GetByIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-09 00:03:31 +00:00
|
|
|
void Breakpoint::RemoveInvalidLocations(const ArchSpec &arch) {
|
2025-10-09 08:37:21 -07:00
|
|
|
// FIXME: Should we ask the scripted resolver whether any of its facade
|
|
|
|
|
// locations are invalid?
|
2013-11-09 00:03:31 +00:00
|
|
|
m_locations.RemoveInvalidLocations(arch);
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// For each of the overall options we need to decide how they propagate to the
|
|
|
|
|
// location options. This will determine the precedence of options on the
|
|
|
|
|
// breakpoint vs. its locations.
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Disable at the breakpoint level should override the location settings. That
|
|
|
|
|
// way you can conveniently turn off a whole breakpoint without messing up the
|
|
|
|
|
// individual settings.
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
void Breakpoint::SetEnabled(bool enable) {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (enable == m_options.IsEnabled())
|
2012-02-08 05:23:15 +00:00
|
|
|
return;
|
|
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SetEnabled(enable);
|
2010-06-08 16:52:24 +00:00
|
|
|
if (enable)
|
|
|
|
|
m_locations.ResolveAllBreakpointSites();
|
|
|
|
|
else
|
|
|
|
|
m_locations.ClearAllBreakpointSites();
|
2012-02-08 05:23:15 +00:00
|
|
|
|
|
|
|
|
SendBreakpointChangedEvent(enable ? eBreakpointEventTypeEnabled
|
|
|
|
|
: eBreakpointEventTypeDisabled);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
bool Breakpoint::IsEnabled() { return m_options.IsEnabled(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-07-09 20:39:50 +00:00
|
|
|
void Breakpoint::SetIgnoreCount(uint32_t n) {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetIgnoreCount() == n)
|
2012-02-08 05:23:15 +00:00
|
|
|
return;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SetIgnoreCount(n);
|
2012-06-26 22:27:55 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeIgnoreChanged);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Breakpoint::DecrementIgnoreCount() {
|
2021-06-11 17:00:46 -07:00
|
|
|
uint32_t ignore = m_options.GetIgnoreCount();
|
2012-06-26 22:27:55 +00:00
|
|
|
if (ignore != 0)
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SetIgnoreCount(ignore - 1);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-26 22:27:55 +00:00
|
|
|
uint32_t Breakpoint::GetIgnoreCount() const {
|
2021-06-11 17:00:46 -07:00
|
|
|
return m_options.GetIgnoreCount();
|
2012-06-26 22:27:55 +00:00
|
|
|
}
|
|
|
|
|
|
2020-07-23 18:41:14 +03:00
|
|
|
uint32_t Breakpoint::GetHitCount() const { return m_hit_counter.GetValue(); }
|
2012-10-05 19:16:31 +00:00
|
|
|
|
2022-09-13 11:30:07 -04:00
|
|
|
void Breakpoint::ResetHitCount() {
|
|
|
|
|
m_hit_counter.Reset();
|
|
|
|
|
m_locations.ResetHitCount();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
bool Breakpoint::IsOneShot() const { return m_options.IsOneShot(); }
|
2012-10-05 19:16:31 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
void Breakpoint::SetOneShot(bool one_shot) { m_options.SetOneShot(one_shot); }
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
bool Breakpoint::IsAutoContinue() const { return m_options.IsAutoContinue(); }
|
2017-08-03 18:13:24 +00:00
|
|
|
|
|
|
|
|
void Breakpoint::SetAutoContinue(bool auto_continue) {
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SetAutoContinue(auto_continue);
|
2017-08-03 18:13:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Breakpoint::SetThreadID(lldb::tid_t thread_id) {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpec()->GetTID() == thread_id)
|
2012-02-08 05:23:15 +00:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.GetThreadSpec()->SetTID(thread_id);
|
2012-02-08 05:23:15 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-08 05:23:15 +00:00
|
|
|
lldb::tid_t Breakpoint::GetThreadID() const {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpecNoCreate() == nullptr)
|
2010-06-16 02:00:15 +00:00
|
|
|
return LLDB_INVALID_THREAD_ID;
|
2025-07-02 10:37:09 -07:00
|
|
|
return m_options.GetThreadSpecNoCreate()->GetTID();
|
2012-02-08 05:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Breakpoint::SetThreadIndex(uint32_t index) {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpec()->GetIndex() == index)
|
2012-02-08 05:23:15 +00:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.GetThreadSpec()->SetIndex(index);
|
2012-02-08 05:23:15 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t Breakpoint::GetThreadIndex() const {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpecNoCreate() == nullptr)
|
2012-02-08 05:23:15 +00:00
|
|
|
return 0;
|
2025-07-02 10:37:09 -07:00
|
|
|
return m_options.GetThreadSpecNoCreate()->GetIndex();
|
2012-02-08 05:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Breakpoint::SetThreadName(const char *thread_name) {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpec()->GetName() != nullptr &&
|
|
|
|
|
::strcmp(m_options.GetThreadSpec()->GetName(), thread_name) == 0)
|
2012-02-08 05:23:15 +00:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.GetThreadSpec()->SetName(thread_name);
|
2012-02-08 05:23:15 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *Breakpoint::GetThreadName() const {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpecNoCreate() == nullptr)
|
2015-10-30 18:50:12 +00:00
|
|
|
return nullptr;
|
2025-07-02 10:37:09 -07:00
|
|
|
return m_options.GetThreadSpecNoCreate()->GetName();
|
2012-02-08 05:23:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Breakpoint::SetQueueName(const char *queue_name) {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpec()->GetQueueName() != nullptr &&
|
|
|
|
|
::strcmp(m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0)
|
2012-02-08 05:23:15 +00:00
|
|
|
return;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.GetThreadSpec()->SetQueueName(queue_name);
|
2012-02-08 05:23:15 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeThreadChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *Breakpoint::GetQueueName() const {
|
2021-06-11 17:00:46 -07:00
|
|
|
if (m_options.GetThreadSpecNoCreate() == nullptr)
|
2015-10-30 18:50:12 +00:00
|
|
|
return nullptr;
|
2025-07-02 10:37:09 -07:00
|
|
|
return m_options.GetThreadSpecNoCreate()->GetQueueName();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-10 15:24:27 -07:00
|
|
|
void Breakpoint::SetCondition(StopCondition condition) {
|
|
|
|
|
m_options.SetCondition(std::move(condition));
|
2012-02-08 05:23:15 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeConditionChanged);
|
2010-10-14 23:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-10 15:24:27 -07:00
|
|
|
const StopCondition &Breakpoint::GetCondition() const {
|
|
|
|
|
return m_options.GetCondition();
|
2010-10-14 23:45:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
// This function is used when "baton" doesn't need to be freed
|
|
|
|
|
void Breakpoint::SetCallback(BreakpointHitCallback callback, void *baton,
|
|
|
|
|
bool is_synchronous) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// The default "Baton" class will keep a copy of "baton" and won't free or
|
2023-09-01 21:32:24 -07:00
|
|
|
// delete it when it goes out of scope.
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SetCallback(callback, std::make_shared<UntypedBaton>(baton),
|
|
|
|
|
is_synchronous);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-02-08 05:23:15 +00:00
|
|
|
SendBreakpointChangedEvent(eBreakpointEventTypeCommandChanged);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This function is used when a baton needs to be freed and therefore is
|
|
|
|
|
// contained in a "Baton" subclass.
|
|
|
|
|
void Breakpoint::SetCallback(BreakpointHitCallback callback,
|
|
|
|
|
const BatonSP &callback_baton_sp,
|
|
|
|
|
bool is_synchronous) {
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.SetCallback(callback, callback_baton_sp, is_synchronous);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
void Breakpoint::ClearCallback() { m_options.ClearCallback(); }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
|
|
|
|
bool Breakpoint::InvokeCallback(StoppointCallbackContext *context,
|
|
|
|
|
break_id_t bp_loc_id) {
|
2021-06-11 17:00:46 -07:00
|
|
|
return m_options.InvokeCallback(context, GetID(), bp_loc_id);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
BreakpointOptions &Breakpoint::GetOptions() { return m_options; }
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
const BreakpointOptions &Breakpoint::GetOptions() const { return m_options; }
|
2017-09-14 20:22:49 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Breakpoint::ResolveBreakpoint() {
|
2021-10-26 17:48:42 -07:00
|
|
|
if (m_resolver_sp) {
|
|
|
|
|
ElapsedTime elapsed(m_resolve_time);
|
2010-06-08 16:52:24 +00:00
|
|
|
m_resolver_sp->ResolveBreakpoint(*m_filter_sp);
|
2021-10-26 17:48:42 -07:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
void Breakpoint::ResolveBreakpointInModules(
|
|
|
|
|
ModuleList &module_list, BreakpointLocationCollection &new_locations) {
|
2021-10-26 17:48:42 -07:00
|
|
|
ElapsedTime elapsed(m_resolve_time);
|
2014-09-10 21:40:47 +00:00
|
|
|
m_locations.StartRecordingNewLocations(new_locations);
|
|
|
|
|
|
|
|
|
|
m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
m_locations.StopRecordingNewLocations();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Breakpoint::ResolveBreakpointInModules(ModuleList &module_list,
|
|
|
|
|
bool send_event) {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (m_resolver_sp) {
|
2014-09-10 21:40:47 +00:00
|
|
|
// If this is not an internal breakpoint, set up to record the new
|
2018-04-30 16:49:04 +00:00
|
|
|
// locations, then dispatch an event with the new locations.
|
2014-09-10 21:40:47 +00:00
|
|
|
if (!IsInternal() && send_event) {
|
2024-01-18 14:26:45 -08:00
|
|
|
std::shared_ptr<BreakpointEventData> new_locations_event =
|
|
|
|
|
std::make_shared<BreakpointEventData>(
|
|
|
|
|
eBreakpointEventTypeLocationsAdded, shared_from_this());
|
2014-09-10 21:40:47 +00:00
|
|
|
ResolveBreakpointInModules(
|
|
|
|
|
module_list, new_locations_event->GetBreakpointLocationCollection());
|
2024-01-18 14:26:45 -08:00
|
|
|
if (new_locations_event->GetBreakpointLocationCollection().GetSize() != 0)
|
2014-09-10 21:40:47 +00:00
|
|
|
SendBreakpointChangedEvent(new_locations_event);
|
|
|
|
|
} else {
|
2021-10-26 17:48:42 -07:00
|
|
|
ElapsedTime elapsed(m_resolve_time);
|
2014-09-10 21:40:47 +00:00
|
|
|
m_resolver_sp->ResolveBreakpointInModules(*m_filter_sp, module_list);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Breakpoint::ClearAllBreakpointSites() {
|
|
|
|
|
m_locations.ClearAllBreakpointSites();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ModulesChanged: Pass in a list of new modules, and
|
|
|
|
|
|
2012-05-17 18:38:42 +00:00
|
|
|
void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
|
|
|
|
|
bool delete_locations) {
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Breakpoints);
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log,
|
|
|
|
|
"Breakpoint::ModulesChanged: num_modules: %zu load: %i "
|
|
|
|
|
"delete_locations: %i\n",
|
|
|
|
|
module_list.GetSize(), load, delete_locations);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (load) {
|
|
|
|
|
// The logic for handling new modules is:
|
2018-04-30 16:49:04 +00:00
|
|
|
// 1) If the filter rejects this module, then skip it. 2) Run through the
|
|
|
|
|
// current location list and if there are any locations
|
2010-06-08 16:52:24 +00:00
|
|
|
// for that module, we mark the module as "seen" and we don't try to
|
|
|
|
|
// re-resolve
|
|
|
|
|
// breakpoint locations for that module.
|
|
|
|
|
// However, we do add breakpoint sites to these locations if needed.
|
|
|
|
|
// 3) If we don't see this module in our breakpoint location list, call
|
|
|
|
|
// ResolveInModules.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
ModuleList new_modules; // We'll stuff the "unseen" modules in this list,
|
|
|
|
|
// and then resolve
|
2018-04-30 16:49:04 +00:00
|
|
|
// them after the locations pass. Have to do it this way because resolving
|
|
|
|
|
// breakpoints will add new locations potentially.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-01-07 20:12:01 -08:00
|
|
|
for (ModuleSP module_sp : module_list.Modules()) {
|
2010-06-08 16:52:24 +00:00
|
|
|
bool seen = false;
|
|
|
|
|
if (!m_filter_sp->ModulePasses(module_sp))
|
|
|
|
|
continue;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-01-12 03:03:23 +00:00
|
|
|
BreakpointLocationCollection locations_with_no_section;
|
2014-09-10 21:40:47 +00:00
|
|
|
for (BreakpointLocationSP break_loc_sp :
|
|
|
|
|
m_locations.BreakpointLocations()) {
|
2018-01-12 03:03:23 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// If the section for this location was deleted, that means it's Module
|
|
|
|
|
// has gone away but somebody forgot to tell us. Let's clean it up
|
|
|
|
|
// here.
|
2018-01-12 03:03:23 +00:00
|
|
|
Address section_addr(break_loc_sp->GetAddress());
|
|
|
|
|
if (section_addr.SectionWasDeleted()) {
|
|
|
|
|
locations_with_no_section.Add(break_loc_sp);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2023-03-02 16:03:35 -08:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (!break_loc_sp->IsEnabled())
|
2010-10-20 03:36:33 +00:00
|
|
|
continue;
|
2023-03-02 16:03:35 -08:00
|
|
|
|
2018-01-12 03:03:23 +00:00
|
|
|
SectionSP section_sp(section_addr.GetSection());
|
2023-03-02 16:03:35 -08:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// If we don't have a Section, that means this location is a raw
|
|
|
|
|
// address that we haven't resolved to a section yet. So we'll have to
|
|
|
|
|
// look in all the new modules to resolve this location. Otherwise, if
|
|
|
|
|
// it was set in this module, re-resolve it here.
|
2018-09-10 23:09:09 +00:00
|
|
|
if (section_sp && section_sp->GetModule() == module_sp) {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (!seen)
|
|
|
|
|
seen = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-07-09 13:19:02 -07:00
|
|
|
if (llvm::Error error = break_loc_sp->ResolveBreakpointSite()) {
|
|
|
|
|
LLDB_LOG_ERROR(log, std::move(error),
|
|
|
|
|
"could not set breakpoint site for "
|
|
|
|
|
"breakpoint location {1} of breakpoint {2}: {0}",
|
|
|
|
|
break_loc_sp->GetID(), GetID());
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2023-03-02 16:03:35 -08:00
|
|
|
|
2018-01-12 03:03:23 +00:00
|
|
|
size_t num_to_delete = locations_with_no_section.GetSize();
|
2023-03-02 16:03:35 -08:00
|
|
|
|
2018-01-12 03:03:23 +00:00
|
|
|
for (size_t i = 0; i < num_to_delete; i++)
|
|
|
|
|
m_locations.RemoveLocation(locations_with_no_section.GetByIndex(i));
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (!seen)
|
2010-12-12 21:03:32 +00:00
|
|
|
new_modules.AppendIfNeeded(module_sp);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (new_modules.GetSize() > 0) {
|
2014-09-10 21:40:47 +00:00
|
|
|
ResolveBreakpointInModules(new_modules);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2010-06-08 16:52:24 +00:00
|
|
|
// Go through the currently set locations and if any have breakpoints in
|
2012-05-17 18:38:42 +00:00
|
|
|
// the module list, then remove their breakpoint sites, and their locations
|
|
|
|
|
// if asked to.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2024-01-18 14:26:45 -08:00
|
|
|
std::shared_ptr<BreakpointEventData> removed_locations_event;
|
2012-02-08 05:23:15 +00:00
|
|
|
if (!IsInternal())
|
2024-01-18 14:26:45 -08:00
|
|
|
removed_locations_event = std::make_shared<BreakpointEventData>(
|
2012-02-08 05:23:15 +00:00
|
|
|
eBreakpointEventTypeLocationsRemoved, shared_from_this());
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2021-01-07 20:12:01 -08:00
|
|
|
for (ModuleSP module_sp : module_list.Modules()) {
|
2010-12-06 23:51:26 +00:00
|
|
|
if (m_filter_sp->ModulePasses(module_sp)) {
|
2012-02-24 01:59:29 +00:00
|
|
|
size_t loc_idx = 0;
|
2012-05-17 18:38:42 +00:00
|
|
|
size_t num_locations = m_locations.GetSize();
|
|
|
|
|
BreakpointLocationCollection locations_to_remove;
|
|
|
|
|
for (loc_idx = 0; loc_idx < num_locations; loc_idx++) {
|
2012-02-24 01:59:29 +00:00
|
|
|
BreakpointLocationSP break_loc_sp(m_locations.GetByIndex(loc_idx));
|
|
|
|
|
SectionSP section_sp(break_loc_sp->GetAddress().GetSection());
|
|
|
|
|
if (section_sp && section_sp->GetModule() == module_sp) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// Remove this breakpoint since the shared library is unloaded, but
|
|
|
|
|
// keep the breakpoint location around so we always get complete
|
|
|
|
|
// hit count and breakpoint lifetime info
|
2025-07-09 13:19:02 -07:00
|
|
|
if (llvm::Error error = break_loc_sp->ClearBreakpointSite())
|
|
|
|
|
LLDB_LOG_ERROR(log, std::move(error),
|
|
|
|
|
"Failed to clear breakpoint locations on library "
|
|
|
|
|
"unload: {0}");
|
2012-02-08 05:23:15 +00:00
|
|
|
if (removed_locations_event) {
|
2012-02-24 01:59:29 +00:00
|
|
|
removed_locations_event->GetBreakpointLocationCollection().Add(
|
2012-05-17 18:38:42 +00:00
|
|
|
break_loc_sp);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2012-05-17 18:38:42 +00:00
|
|
|
if (delete_locations)
|
2014-09-10 21:40:47 +00:00
|
|
|
locations_to_remove.Add(break_loc_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (delete_locations) {
|
|
|
|
|
size_t num_locations_to_remove = locations_to_remove.GetSize();
|
|
|
|
|
for (loc_idx = 0; loc_idx < num_locations_to_remove; loc_idx++)
|
|
|
|
|
m_locations.RemoveLocation(locations_to_remove.GetByIndex(loc_idx));
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
}
|
|
|
|
|
SendBreakpointChangedEvent(removed_locations_event);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
|
|
|
|
|
SymbolContext &new_sc) {
|
|
|
|
|
bool equivalent_scs = false;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (old_sc.module_sp.get() == new_sc.module_sp.get()) {
|
2018-04-30 16:49:04 +00:00
|
|
|
// If these come from the same module, we can directly compare the
|
|
|
|
|
// pointers:
|
2014-09-10 21:40:47 +00:00
|
|
|
if (old_sc.comp_unit && new_sc.comp_unit &&
|
|
|
|
|
(old_sc.comp_unit == new_sc.comp_unit)) {
|
|
|
|
|
if (old_sc.function && new_sc.function &&
|
|
|
|
|
(old_sc.function == new_sc.function)) {
|
|
|
|
|
equivalent_scs = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
} else if (old_sc.symbol && new_sc.symbol &&
|
|
|
|
|
(old_sc.symbol == new_sc.symbol)) {
|
|
|
|
|
equivalent_scs = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2014-09-10 21:40:47 +00:00
|
|
|
// Otherwise we will compare by name...
|
|
|
|
|
if (old_sc.comp_unit && new_sc.comp_unit) {
|
[lldb] s/FileSpec::Equal/FileSpec::Match
Summary:
The FileSpec class is often used as a sort of a pattern -- one specifies
a bare file name to search, and we check if in matches the full file
name of an existing module (for example).
These comparisons used FileSpec::Equal, which had some support for it
(via the full=false argument), but it was not a good fit for this job.
For one, it did a symmetric comparison, which makes sense for a function
called "equal", but not for typical searches (when searching for
"/foo/bar.so", we don't want to find a module whose name is just
"bar.so"). This resulted in patterns like:
if (FileSpec::Equal(pattern, file, pattern.GetDirectory()))
which would request a "full" match only if the pattern really contained
a directory. This worked, but the intended behavior was very unobvious.
On top of that, a lot of the code wanted to handle the case of an
"empty" pattern, and treat it as matching everything. This resulted in
conditions like:
if (pattern && !FileSpec::Equal(pattern, file, pattern.GetDirectory())
which are nearly impossible to decipher.
This patch introduces a FileSpec::Match function, which does exactly
what most of FileSpec::Equal callers want, an asymmetric match between a
"pattern" FileSpec and a an actual FileSpec. Empty paterns match
everything, filename-only patterns match only the filename component.
I've tried to update all callers of FileSpec::Equal to use a simpler
interface. Those that hardcoded full=true have been changed to use
operator==. Those passing full=pattern.GetDirectory() have been changed
to use FileSpec::Match.
There was also a handful of places which hardcoded full=false. I've
changed these to use FileSpec::Match too. This is a slight change in
semantics, but it does not look like that was ever intended, and it was
more likely a result of a misunderstanding of the "proper" way to use
FileSpec::Equal.
[In an ideal world a "FileSpec" and a "FileSpec pattern" would be two
different types, but given how widespread FileSpec is, it is unlikely
we'll get there in one go. This at least provides a good starting point
by centralizing all matching behavior.]
Reviewers: teemperor, JDevlieghere, jdoerfert
Subscribers: emaste, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D70851
2019-11-29 11:31:00 +01:00
|
|
|
if (old_sc.comp_unit->GetPrimaryFile() ==
|
|
|
|
|
new_sc.comp_unit->GetPrimaryFile()) {
|
2014-09-10 21:40:47 +00:00
|
|
|
// Now check the functions:
|
|
|
|
|
if (old_sc.function && new_sc.function &&
|
|
|
|
|
(old_sc.function->GetName() == new_sc.function->GetName())) {
|
|
|
|
|
equivalent_scs = true;
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
} else if (old_sc.symbol && new_sc.symbol) {
|
|
|
|
|
if (Mangled::Compare(old_sc.symbol->GetMangled(),
|
|
|
|
|
new_sc.symbol->GetMangled()) == 0) {
|
|
|
|
|
equivalent_scs = true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
return equivalent_scs;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-17 18:38:42 +00:00
|
|
|
void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
|
|
|
|
|
ModuleSP new_module_sp) {
|
2022-01-31 15:57:48 +01:00
|
|
|
Log *log = GetLog(LLDBLog::Breakpoints);
|
2019-07-24 17:56:10 +00:00
|
|
|
LLDB_LOGF(log, "Breakpoint::ModulesReplaced for %s\n",
|
|
|
|
|
old_module_sp->GetSpecificationDescription().c_str());
|
2014-09-10 21:40:47 +00:00
|
|
|
// First find all the locations that are in the old module
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
BreakpointLocationCollection old_break_locs;
|
|
|
|
|
for (BreakpointLocationSP break_loc_sp : m_locations.BreakpointLocations()) {
|
|
|
|
|
SectionSP section_sp = break_loc_sp->GetAddress().GetSection();
|
|
|
|
|
if (section_sp && section_sp->GetModule() == old_module_sp) {
|
|
|
|
|
old_break_locs.Add(break_loc_sp);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
size_t num_old_locations = old_break_locs.GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (num_old_locations == 0) {
|
|
|
|
|
// There were no locations in the old module, so we just need to check if
|
|
|
|
|
// there were any in the new module.
|
|
|
|
|
ModuleList temp_list;
|
|
|
|
|
temp_list.Append(new_module_sp);
|
|
|
|
|
ResolveBreakpointInModules(temp_list);
|
|
|
|
|
} else {
|
2018-04-30 16:49:04 +00:00
|
|
|
// First search the new module for locations. Then compare this with the
|
|
|
|
|
// old list, copy over locations that "look the same" Then delete the old
|
|
|
|
|
// locations. Finally remember to post the creation event.
|
2016-09-06 20:57:50 +00:00
|
|
|
//
|
2018-04-30 16:49:04 +00:00
|
|
|
// Two locations are the same if they have the same comp unit & function
|
|
|
|
|
// (by name) and there are the same number of locations in the old function
|
|
|
|
|
// as in the new one.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
ModuleList temp_list;
|
|
|
|
|
temp_list.Append(new_module_sp);
|
|
|
|
|
BreakpointLocationCollection new_break_locs;
|
|
|
|
|
ResolveBreakpointInModules(temp_list, new_break_locs);
|
|
|
|
|
BreakpointLocationCollection locations_to_remove;
|
|
|
|
|
BreakpointLocationCollection locations_to_announce;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
size_t num_new_locations = new_break_locs.GetSize();
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (num_new_locations > 0) {
|
|
|
|
|
// Break out the case of one location -> one location since that's the
|
2018-04-30 16:49:04 +00:00
|
|
|
// most common one, and there's no need to build up the structures needed
|
|
|
|
|
// for the merge in that case.
|
2014-09-10 21:40:47 +00:00
|
|
|
if (num_new_locations == 1 && num_old_locations == 1) {
|
|
|
|
|
bool equivalent_locations = false;
|
|
|
|
|
SymbolContext old_sc, new_sc;
|
|
|
|
|
// The only way the old and new location can be equivalent is if they
|
|
|
|
|
// have the same amount of information:
|
|
|
|
|
BreakpointLocationSP old_loc_sp = old_break_locs.GetByIndex(0);
|
|
|
|
|
BreakpointLocationSP new_loc_sp = new_break_locs.GetByIndex(0);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (old_loc_sp->GetAddress().CalculateSymbolContext(&old_sc) ==
|
|
|
|
|
new_loc_sp->GetAddress().CalculateSymbolContext(&new_sc)) {
|
|
|
|
|
equivalent_locations =
|
|
|
|
|
SymbolContextsMightBeEquivalent(old_sc, new_sc);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (equivalent_locations) {
|
|
|
|
|
m_locations.SwapLocation(old_loc_sp, new_loc_sp);
|
|
|
|
|
} else {
|
|
|
|
|
locations_to_remove.Add(old_loc_sp);
|
|
|
|
|
locations_to_announce.Add(new_loc_sp);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
} else {
|
|
|
|
|
// We don't want to have to keep computing the SymbolContexts for these
|
2018-04-30 16:49:04 +00:00
|
|
|
// addresses over and over, so lets get them up front:
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
typedef std::map<lldb::break_id_t, SymbolContext> IDToSCMap;
|
|
|
|
|
IDToSCMap old_sc_map;
|
|
|
|
|
for (size_t idx = 0; idx < num_old_locations; idx++) {
|
|
|
|
|
SymbolContext sc;
|
|
|
|
|
BreakpointLocationSP bp_loc_sp = old_break_locs.GetByIndex(idx);
|
2015-10-30 18:50:12 +00:00
|
|
|
lldb::break_id_t loc_id = bp_loc_sp->GetID();
|
2014-09-10 21:40:47 +00:00
|
|
|
bp_loc_sp->GetAddress().CalculateSymbolContext(&old_sc_map[loc_id]);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
std::map<lldb::break_id_t, SymbolContext> new_sc_map;
|
|
|
|
|
for (size_t idx = 0; idx < num_new_locations; idx++) {
|
|
|
|
|
SymbolContext sc;
|
|
|
|
|
BreakpointLocationSP bp_loc_sp = new_break_locs.GetByIndex(idx);
|
|
|
|
|
lldb::break_id_t loc_id = bp_loc_sp->GetID();
|
|
|
|
|
bp_loc_sp->GetAddress().CalculateSymbolContext(&new_sc_map[loc_id]);
|
|
|
|
|
}
|
|
|
|
|
// Take an element from the old Symbol Contexts
|
|
|
|
|
while (old_sc_map.size() > 0) {
|
|
|
|
|
lldb::break_id_t old_id = old_sc_map.begin()->first;
|
|
|
|
|
SymbolContext &old_sc = old_sc_map.begin()->second;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2018-04-30 16:49:04 +00:00
|
|
|
// Count the number of entries equivalent to this SC for the old
|
|
|
|
|
// list:
|
2014-09-10 21:40:47 +00:00
|
|
|
std::vector<lldb::break_id_t> old_id_vec;
|
|
|
|
|
old_id_vec.push_back(old_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
IDToSCMap::iterator tmp_iter;
|
|
|
|
|
for (tmp_iter = ++old_sc_map.begin(); tmp_iter != old_sc_map.end();
|
|
|
|
|
tmp_iter++) {
|
|
|
|
|
if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
|
|
|
|
|
old_id_vec.push_back(tmp_iter->first);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
// Now find all the equivalent locations in the new list.
|
|
|
|
|
std::vector<lldb::break_id_t> new_id_vec;
|
|
|
|
|
for (tmp_iter = new_sc_map.begin(); tmp_iter != new_sc_map.end();
|
|
|
|
|
tmp_iter++) {
|
|
|
|
|
if (SymbolContextsMightBeEquivalent(old_sc, tmp_iter->second))
|
|
|
|
|
new_id_vec.push_back(tmp_iter->first);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
// Alright, if we have the same number of potentially equivalent
|
2018-04-30 16:49:04 +00:00
|
|
|
// locations in the old and new modules, we'll just map them one to
|
|
|
|
|
// one in ascending ID order (assuming the resolver's order would
|
|
|
|
|
// match the equivalent ones. Otherwise, we'll dump all the old ones,
|
|
|
|
|
// and just take the new ones, erasing the elements from both maps as
|
|
|
|
|
// we go.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
if (old_id_vec.size() == new_id_vec.size()) {
|
2018-09-27 03:35:05 +00:00
|
|
|
llvm::sort(old_id_vec);
|
|
|
|
|
llvm::sort(new_id_vec);
|
2014-09-10 21:40:47 +00:00
|
|
|
size_t num_elements = old_id_vec.size();
|
|
|
|
|
for (size_t idx = 0; idx < num_elements; idx++) {
|
|
|
|
|
BreakpointLocationSP old_loc_sp =
|
|
|
|
|
old_break_locs.FindByIDPair(GetID(), old_id_vec[idx]);
|
|
|
|
|
BreakpointLocationSP new_loc_sp =
|
|
|
|
|
new_break_locs.FindByIDPair(GetID(), new_id_vec[idx]);
|
|
|
|
|
m_locations.SwapLocation(old_loc_sp, new_loc_sp);
|
|
|
|
|
old_sc_map.erase(old_id_vec[idx]);
|
|
|
|
|
new_sc_map.erase(new_id_vec[idx]);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2014-09-10 21:40:47 +00:00
|
|
|
for (lldb::break_id_t old_id : old_id_vec) {
|
|
|
|
|
locations_to_remove.Add(
|
|
|
|
|
old_break_locs.FindByIDPair(GetID(), old_id));
|
|
|
|
|
old_sc_map.erase(old_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
for (lldb::break_id_t new_id : new_id_vec) {
|
|
|
|
|
locations_to_announce.Add(
|
|
|
|
|
new_break_locs.FindByIDPair(GetID(), new_id));
|
|
|
|
|
new_sc_map.erase(new_id);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-09-10 21:40:47 +00:00
|
|
|
}
|
2012-05-17 18:38:42 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
// Now remove the remaining old locations, and cons up a removed locations
|
2018-04-30 16:49:04 +00:00
|
|
|
// event. Note, we don't put the new locations that were swapped with an
|
|
|
|
|
// old location on the locations_to_remove list, so we don't need to worry
|
|
|
|
|
// about telling the world about removing a location we didn't tell them
|
2014-09-10 21:40:47 +00:00
|
|
|
// about adding.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2024-01-18 14:26:45 -08:00
|
|
|
std::shared_ptr<BreakpointEventData> removed_locations_event;
|
2010-06-08 16:52:24 +00:00
|
|
|
if (!IsInternal())
|
2024-01-18 14:26:45 -08:00
|
|
|
removed_locations_event = std::make_shared<BreakpointEventData>(
|
2012-02-08 05:23:15 +00:00
|
|
|
eBreakpointEventTypeLocationsRemoved, shared_from_this());
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
for (BreakpointLocationSP loc_sp :
|
2010-06-08 16:52:24 +00:00
|
|
|
locations_to_remove.BreakpointLocations()) {
|
|
|
|
|
m_locations.RemoveLocation(loc_sp);
|
2024-01-18 14:26:45 -08:00
|
|
|
if (removed_locations_event)
|
|
|
|
|
removed_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2024-01-18 14:26:45 -08:00
|
|
|
SendBreakpointChangedEvent(removed_locations_event);
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2014-09-10 21:40:47 +00:00
|
|
|
// And announce the new ones.
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
if (!IsInternal()) {
|
2024-01-18 14:26:45 -08:00
|
|
|
std::shared_ptr<BreakpointEventData> added_locations_event =
|
|
|
|
|
std::make_shared<BreakpointEventData>(
|
|
|
|
|
eBreakpointEventTypeLocationsAdded, shared_from_this());
|
2010-07-23 23:33:17 +00:00
|
|
|
for (BreakpointLocationSP loc_sp :
|
2010-06-08 16:52:24 +00:00
|
|
|
locations_to_announce.BreakpointLocations())
|
2024-01-18 14:26:45 -08:00
|
|
|
added_locations_event->GetBreakpointLocationCollection().Add(loc_sp);
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2024-01-18 14:26:45 -08:00
|
|
|
SendBreakpointChangedEvent(added_locations_event);
|
2014-12-16 23:40:14 +00:00
|
|
|
}
|
|
|
|
|
m_locations.Compact();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-12-16 23:40:14 +00:00
|
|
|
|
|
|
|
|
void Breakpoint::Dump(Stream *) {}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-10-09 08:37:21 -07:00
|
|
|
size_t Breakpoint::GetNumResolvedLocations(bool use_facade) const {
|
2018-04-30 16:49:04 +00:00
|
|
|
// Return the number of breakpoints that are actually resolved and set down
|
|
|
|
|
// in the inferior process.
|
2025-10-09 08:37:21 -07:00
|
|
|
// All facade locations are considered to be resolved:
|
|
|
|
|
if (use_facade) {
|
|
|
|
|
size_t num_facade_locs = m_facade_locations.GetSize();
|
|
|
|
|
if (num_facade_locs)
|
|
|
|
|
return num_facade_locs;
|
|
|
|
|
}
|
2014-12-16 23:40:14 +00:00
|
|
|
return m_locations.GetNumResolvedLocations();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-15 01:18:15 +00:00
|
|
|
bool Breakpoint::HasResolvedLocations() const {
|
|
|
|
|
return GetNumResolvedLocations() > 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-09 08:37:21 -07:00
|
|
|
size_t Breakpoint::GetNumLocations(bool use_facade) const {
|
|
|
|
|
if (use_facade) {
|
|
|
|
|
size_t num_facade_locs = m_facade_locations.GetSize();
|
|
|
|
|
if (num_facade_locs > 0)
|
|
|
|
|
return num_facade_locs;
|
|
|
|
|
}
|
|
|
|
|
return m_locations.GetSize();
|
|
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2023-11-09 13:34:59 -08:00
|
|
|
void Breakpoint::AddName(llvm::StringRef new_name) {
|
2023-05-16 10:38:49 -07:00
|
|
|
m_name_list.insert(new_name.str());
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
void Breakpoint::GetDescription(Stream *s, lldb::DescriptionLevel level,
|
2014-12-16 23:40:14 +00:00
|
|
|
bool show_locations) {
|
|
|
|
|
assert(s != nullptr);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-06-18 13:06:20 -07:00
|
|
|
const bool dim_breakpoint_description =
|
|
|
|
|
!IsEnabled() && s->AsRawOstream().colors_enabled();
|
|
|
|
|
if (dim_breakpoint_description)
|
|
|
|
|
s->Printf("%s", ansi::FormatAnsiTerminalCodes(
|
|
|
|
|
GetTarget().GetDebugger().GetDisabledAnsiPrefix())
|
|
|
|
|
.c_str());
|
|
|
|
|
|
2014-12-16 23:40:14 +00:00
|
|
|
if (!m_kind_description.empty()) {
|
2012-09-22 00:04:04 +00:00
|
|
|
if (level == eDescriptionLevelBrief) {
|
|
|
|
|
s->PutCString(GetBreakpointKind());
|
2016-09-06 20:57:50 +00:00
|
|
|
return;
|
2025-07-02 10:37:09 -07:00
|
|
|
}
|
|
|
|
|
s->Printf("Kind: %s\n", GetBreakpointKind());
|
2012-09-22 00:04:04 +00:00
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2025-10-09 08:37:21 -07:00
|
|
|
bool show_both_types = level == eDescriptionLevelVerbose &&
|
|
|
|
|
HasFacadeLocations() && show_locations;
|
|
|
|
|
uint8_t display_mask = eDisplayFacade;
|
|
|
|
|
if (show_both_types)
|
|
|
|
|
display_mask |= eDisplayHeader;
|
|
|
|
|
|
|
|
|
|
GetDescriptionForType(s, level, display_mask, show_locations);
|
|
|
|
|
|
|
|
|
|
if (show_both_types) {
|
|
|
|
|
display_mask = eDisplayReal | eDisplayHeader;
|
|
|
|
|
GetDescriptionForType(s, level, display_mask, show_locations);
|
|
|
|
|
}
|
|
|
|
|
// Reset the colors back to normal if they were previously greyed out.
|
|
|
|
|
if (dim_breakpoint_description)
|
|
|
|
|
s->Printf("%s", ansi::FormatAnsiTerminalCodes(
|
|
|
|
|
GetTarget().GetDebugger().GetDisabledAnsiSuffix())
|
|
|
|
|
.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Breakpoint::GetDescriptionForType(Stream *s, lldb::DescriptionLevel level,
|
|
|
|
|
uint8_t display_type,
|
|
|
|
|
bool show_locations) {
|
|
|
|
|
bool use_facade = (display_type & eDisplayFacade) != 0;
|
|
|
|
|
const size_t num_locations = GetNumLocations(use_facade);
|
|
|
|
|
const size_t num_resolved_locations = GetNumResolvedLocations(use_facade);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2015-03-30 17:46:36 +00:00
|
|
|
// They just made the breakpoint, they don't need to be told HOW they made
|
2018-04-30 16:49:04 +00:00
|
|
|
// it... Also, we'll print the breakpoint number differently depending on
|
|
|
|
|
// whether there is 1 or more locations.
|
2015-03-30 17:46:36 +00:00
|
|
|
if (level != eDescriptionLevelInitial) {
|
|
|
|
|
s->Printf("%i: ", GetID());
|
|
|
|
|
GetResolverDescription(s);
|
2012-09-22 00:04:04 +00:00
|
|
|
GetFilterDescription(s);
|
|
|
|
|
}
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
switch (level) {
|
2012-09-22 00:04:04 +00:00
|
|
|
case lldb::eDescriptionLevelBrief:
|
2015-03-30 17:46:36 +00:00
|
|
|
case lldb::eDescriptionLevelFull:
|
|
|
|
|
if (num_locations > 0) {
|
|
|
|
|
s->Printf(", locations = %" PRIu64, (uint64_t)num_locations);
|
2010-06-08 16:52:24 +00:00
|
|
|
if (num_resolved_locations > 0)
|
|
|
|
|
s->Printf(", resolved = %" PRIu64 ", hit count = %d",
|
2013-10-12 00:40:02 +00:00
|
|
|
(uint64_t)num_resolved_locations, GetHitCount());
|
2010-06-08 16:52:24 +00:00
|
|
|
} else {
|
|
|
|
|
// Don't print the pending notification for exception resolvers since we
|
2018-04-30 16:49:04 +00:00
|
|
|
// don't generally know how to set them until the target is run.
|
2010-06-18 01:00:58 +00:00
|
|
|
if (m_resolver_sp->getResolverID() !=
|
|
|
|
|
BreakpointResolver::ExceptionResolver)
|
|
|
|
|
s->Printf(", locations = 0 (pending)");
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.GetDescription(s, level);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-05-14 01:11:02 +00:00
|
|
|
if (m_precondition_sp)
|
|
|
|
|
m_precondition_sp->GetDescription(*s, level);
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-05-14 01:11:02 +00:00
|
|
|
if (level == lldb::eDescriptionLevelFull) {
|
2010-06-08 16:52:24 +00:00
|
|
|
if (!m_name_list.empty()) {
|
2014-12-16 23:40:14 +00:00
|
|
|
s->EOL();
|
|
|
|
|
s->Indent();
|
|
|
|
|
s->Printf("Names:");
|
|
|
|
|
s->EOL();
|
2010-06-08 16:52:24 +00:00
|
|
|
s->IndentMore();
|
2024-06-08 22:34:40 +05:30
|
|
|
for (const std::string &name : m_name_list) {
|
2010-06-08 16:52:24 +00:00
|
|
|
s->Indent();
|
|
|
|
|
s->Printf("%s\n", name.c_str());
|
|
|
|
|
}
|
|
|
|
|
s->IndentLess();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2010-06-18 01:00:58 +00:00
|
|
|
s->IndentLess();
|
2014-12-16 23:40:14 +00:00
|
|
|
s->EOL();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
case lldb::eDescriptionLevelInitial:
|
2013-01-26 02:19:28 +00:00
|
|
|
s->Printf("Breakpoint %i: ", GetID());
|
2012-09-22 00:04:04 +00:00
|
|
|
if (num_locations == 0) {
|
|
|
|
|
s->Printf("no locations (pending).");
|
2014-09-10 21:40:47 +00:00
|
|
|
} else if (num_locations == 1 && !show_locations) {
|
2012-09-22 00:04:04 +00:00
|
|
|
// There is only one location, so we'll just print that location
|
|
|
|
|
// information.
|
2025-10-09 08:37:21 -07:00
|
|
|
GetLocationAtIndex(0, use_facade)->GetDescription(s, level);
|
2016-09-06 20:57:50 +00:00
|
|
|
} else {
|
2012-11-29 21:49:15 +00:00
|
|
|
s->Printf("%" PRIu64 " locations.", static_cast<uint64_t>(num_locations));
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
2014-12-16 23:40:14 +00:00
|
|
|
s->EOL();
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
|
2010-06-08 16:52:24 +00:00
|
|
|
case lldb::eDescriptionLevelVerbose:
|
|
|
|
|
// Verbose mode does a debug dump of the breakpoint
|
2016-09-06 20:57:50 +00:00
|
|
|
Dump(s);
|
2014-12-16 23:40:14 +00:00
|
|
|
s->EOL();
|
|
|
|
|
// s->Indent();
|
2021-06-11 17:00:46 -07:00
|
|
|
m_options.GetDescription(s, level);
|
2016-09-06 20:57:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-14 01:11:02 +00:00
|
|
|
// The brief description is just the location name (1.2 or whatever). That's
|
2018-04-30 16:49:04 +00:00
|
|
|
// pointless to show in the breakpoint's description, so suppress it.
|
2010-06-08 16:52:24 +00:00
|
|
|
if (show_locations && level != lldb::eDescriptionLevelBrief) {
|
2025-10-09 08:37:21 -07:00
|
|
|
if ((display_type & eDisplayHeader) != 0) {
|
|
|
|
|
if ((display_type & eDisplayFacade) != 0)
|
|
|
|
|
s->Printf("Facade locations:\n");
|
|
|
|
|
else
|
|
|
|
|
s->Printf("Implementation Locations\n");
|
|
|
|
|
}
|
2014-12-16 23:40:14 +00:00
|
|
|
s->IndentMore();
|
2014-09-10 21:40:47 +00:00
|
|
|
for (size_t i = 0; i < num_locations; ++i) {
|
2025-10-09 08:37:21 -07:00
|
|
|
BreakpointLocation *loc = GetLocationAtIndex(i, use_facade).get();
|
2010-06-08 16:52:24 +00:00
|
|
|
loc->GetDescription(s, level);
|
2014-12-16 23:40:14 +00:00
|
|
|
s->EOL();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2010-06-18 01:00:58 +00:00
|
|
|
s->IndentLess();
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-09 01:49:26 +00:00
|
|
|
void Breakpoint::GetResolverDescription(Stream *s) {
|
|
|
|
|
if (m_resolver_sp)
|
|
|
|
|
m_resolver_sp->GetDescription(s);
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-03 11:17:19 -07:00
|
|
|
bool Breakpoint::GetMatchingFileLine(ConstString filename, uint32_t line_number,
|
2012-02-09 01:49:26 +00:00
|
|
|
BreakpointLocationCollection &loc_coll) {
|
|
|
|
|
// TODO: To be correct, this method needs to fill the breakpoint location
|
|
|
|
|
// collection
|
|
|
|
|
// with the location IDs which match the filename and line_number.
|
2016-09-06 20:57:50 +00:00
|
|
|
//
|
|
|
|
|
|
2012-02-09 01:49:26 +00:00
|
|
|
if (m_resolver_sp) {
|
|
|
|
|
BreakpointResolverFileLine *resolverFileLine =
|
|
|
|
|
dyn_cast<BreakpointResolverFileLine>(m_resolver_sp.get());
|
2021-05-04 23:03:10 +00:00
|
|
|
|
|
|
|
|
// TODO: Handle SourceLocationSpec column information
|
2012-02-09 01:49:26 +00:00
|
|
|
if (resolverFileLine &&
|
2021-05-04 23:03:10 +00:00
|
|
|
resolverFileLine->m_location_spec.GetFileSpec().GetFilename() ==
|
|
|
|
|
filename &&
|
|
|
|
|
resolverFileLine->m_location_spec.GetLine() == line_number) {
|
2012-02-09 01:49:26 +00:00
|
|
|
return true;
|
2016-09-06 20:57:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-12-16 23:40:14 +00:00
|
|
|
return false;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-09 01:49:26 +00:00
|
|
|
void Breakpoint::GetFilterDescription(Stream *s) {
|
|
|
|
|
m_filter_sp->GetDescription(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Breakpoint::EvaluatePrecondition(StoppointCallbackContext &context) {
|
|
|
|
|
if (!m_precondition_sp)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return m_precondition_sp->EvaluatePrecondition(context);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-22 19:42:18 +00:00
|
|
|
void Breakpoint::SendBreakpointChangedEvent(
|
2025-10-31 13:06:36 -07:00
|
|
|
lldb::BreakpointEventType event_kind) {
|
|
|
|
|
if (!IsInternal())
|
|
|
|
|
GetTarget().NotifyBreakpointChanged(*this, event_kind);
|
2015-04-22 19:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
2024-01-18 14:26:45 -08:00
|
|
|
void Breakpoint::SendBreakpointChangedEvent(
|
|
|
|
|
const lldb::EventDataSP &breakpoint_data_sp) {
|
|
|
|
|
if (!breakpoint_data_sp)
|
2015-04-22 19:42:18 +00:00
|
|
|
return;
|
|
|
|
|
|
2025-10-31 13:06:36 -07:00
|
|
|
if (!IsInternal())
|
|
|
|
|
GetTarget().NotifyBreakpointChanged(*this, breakpoint_data_sp);
|
2012-02-09 01:49:26 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 09:56:50 -08:00
|
|
|
const char *Breakpoint::BreakpointEventTypeAsCString(BreakpointEventType type) {
|
|
|
|
|
switch (type) {
|
2025-07-03 11:17:19 -07:00
|
|
|
case eBreakpointEventTypeInvalidType:
|
|
|
|
|
return "invalid";
|
|
|
|
|
case eBreakpointEventTypeAdded:
|
|
|
|
|
return "breakpoint added";
|
|
|
|
|
case eBreakpointEventTypeRemoved:
|
|
|
|
|
return "breakpoint removed";
|
|
|
|
|
case eBreakpointEventTypeLocationsAdded:
|
|
|
|
|
return "locations added";
|
|
|
|
|
case eBreakpointEventTypeLocationsRemoved:
|
|
|
|
|
return "locations removed";
|
|
|
|
|
case eBreakpointEventTypeLocationsResolved:
|
|
|
|
|
return "locations resolved";
|
|
|
|
|
case eBreakpointEventTypeEnabled:
|
|
|
|
|
return "breakpoint enabled";
|
|
|
|
|
case eBreakpointEventTypeDisabled:
|
|
|
|
|
return "breakpoint disabled";
|
|
|
|
|
case eBreakpointEventTypeCommandChanged:
|
|
|
|
|
return "command changed";
|
|
|
|
|
case eBreakpointEventTypeConditionChanged:
|
|
|
|
|
return "condition changed";
|
|
|
|
|
case eBreakpointEventTypeIgnoreChanged:
|
|
|
|
|
return "ignore count changed";
|
|
|
|
|
case eBreakpointEventTypeThreadChanged:
|
|
|
|
|
return "thread changed";
|
|
|
|
|
case eBreakpointEventTypeAutoContinueChanged:
|
|
|
|
|
return "autocontinue changed";
|
2022-03-03 09:56:50 -08:00
|
|
|
};
|
2022-04-06 14:09:22 +03:00
|
|
|
llvm_unreachable("Fully covered switch above!");
|
2022-03-03 09:56:50 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log *Breakpoint::BreakpointEventData::GetLogChannel() {
|
|
|
|
|
return GetLog(LLDBLog::Breakpoints);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-09 01:49:26 +00:00
|
|
|
Breakpoint::BreakpointEventData::BreakpointEventData(
|
2010-07-23 23:33:17 +00:00
|
|
|
BreakpointEventType sub_type, const BreakpointSP &new_breakpoint_sp)
|
2022-02-06 10:54:46 -08:00
|
|
|
: m_breakpoint_event(sub_type), m_new_breakpoint_sp(new_breakpoint_sp) {}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2015-10-30 18:50:12 +00:00
|
|
|
Breakpoint::BreakpointEventData::~BreakpointEventData() = default;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2023-04-07 18:39:24 -07:00
|
|
|
llvm::StringRef Breakpoint::BreakpointEventData::GetFlavorString() {
|
|
|
|
|
return "Breakpoint::BreakpointEventData";
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2023-04-07 18:39:24 -07:00
|
|
|
llvm::StringRef Breakpoint::BreakpointEventData::GetFlavor() const {
|
2010-06-08 16:52:24 +00:00
|
|
|
return BreakpointEventData::GetFlavorString();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 09:56:50 -08:00
|
|
|
BreakpointSP Breakpoint::BreakpointEventData::GetBreakpoint() const {
|
2010-06-08 16:52:24 +00:00
|
|
|
return m_new_breakpoint_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
BreakpointEventType
|
|
|
|
|
Breakpoint::BreakpointEventData::GetBreakpointEventType() const {
|
|
|
|
|
return m_breakpoint_event;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-03 09:56:50 -08:00
|
|
|
void Breakpoint::BreakpointEventData::Dump(Stream *s) const {
|
|
|
|
|
if (!s)
|
|
|
|
|
return;
|
|
|
|
|
BreakpointEventType event_type = GetBreakpointEventType();
|
|
|
|
|
break_id_t bkpt_id = GetBreakpoint()->GetID();
|
|
|
|
|
s->Format("bkpt: {0} type: {1}", bkpt_id,
|
2025-07-03 11:17:19 -07:00
|
|
|
BreakpointEventTypeAsCString(event_type));
|
2022-03-03 09:56:50 -08:00
|
|
|
}
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2012-02-08 05:23:15 +00:00
|
|
|
const Breakpoint::BreakpointEventData *
|
|
|
|
|
Breakpoint::BreakpointEventData::GetEventDataFromEvent(const Event *event) {
|
|
|
|
|
if (event) {
|
|
|
|
|
const EventData *event_data = event->GetData();
|
2010-06-08 16:52:24 +00:00
|
|
|
if (event_data &&
|
|
|
|
|
event_data->GetFlavor() == BreakpointEventData::GetFlavorString())
|
2012-02-08 05:23:15 +00:00
|
|
|
return static_cast<const BreakpointEventData *>(event->GetData());
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2015-10-30 18:50:12 +00:00
|
|
|
return nullptr;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
BreakpointEventType
|
|
|
|
|
Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
|
|
|
|
|
const EventSP &event_sp) {
|
2012-02-08 05:23:15 +00:00
|
|
|
const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2015-10-30 18:50:12 +00:00
|
|
|
if (data == nullptr)
|
2010-07-23 23:33:17 +00:00
|
|
|
return eBreakpointEventTypeInvalidType;
|
2025-07-02 10:37:09 -07:00
|
|
|
return data->GetBreakpointEventType();
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakpointSP Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
|
|
|
|
|
const EventSP &event_sp) {
|
2010-07-23 23:33:17 +00:00
|
|
|
BreakpointSP bp_sp;
|
|
|
|
|
|
2012-02-08 05:23:15 +00:00
|
|
|
const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
|
2010-07-23 23:33:17 +00:00
|
|
|
if (data)
|
2012-02-08 05:23:15 +00:00
|
|
|
bp_sp = data->m_new_breakpoint_sp;
|
2010-06-08 16:52:24 +00:00
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
return bp_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-08 05:23:15 +00:00
|
|
|
size_t Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent(
|
|
|
|
|
const EventSP &event_sp) {
|
|
|
|
|
const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
|
|
|
|
|
if (data)
|
|
|
|
|
return data->m_locations.GetSize();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 23:33:17 +00:00
|
|
|
lldb::BreakpointLocationSP
|
|
|
|
|
Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
|
|
|
|
|
const lldb::EventSP &event_sp, uint32_t bp_loc_idx) {
|
|
|
|
|
lldb::BreakpointLocationSP bp_loc_sp;
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2012-02-08 05:23:15 +00:00
|
|
|
const BreakpointEventData *data = GetEventDataFromEvent(event_sp.get());
|
2010-07-23 23:33:17 +00:00
|
|
|
if (data) {
|
2012-02-08 05:23:15 +00:00
|
|
|
bp_loc_sp = data->m_locations.GetByIndex(bp_loc_idx);
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2010-07-23 23:33:17 +00:00
|
|
|
|
|
|
|
|
return bp_loc_sp;
|
2010-06-08 16:52:24 +00:00
|
|
|
}
|
2021-10-26 17:48:42 -07:00
|
|
|
|
|
|
|
|
json::Value Breakpoint::GetStatistics() {
|
|
|
|
|
json::Object bp;
|
|
|
|
|
bp.try_emplace("id", GetID());
|
2022-01-17 15:04:30 +01:00
|
|
|
bp.try_emplace("resolveTime", m_resolve_time.get().count());
|
2021-10-26 17:48:42 -07:00
|
|
|
bp.try_emplace("numLocations", (int64_t)GetNumLocations());
|
|
|
|
|
bp.try_emplace("numResolvedLocations", (int64_t)GetNumResolvedLocations());
|
2023-03-02 16:03:35 -08:00
|
|
|
bp.try_emplace("hitCount", (int64_t)GetHitCount());
|
2021-10-26 17:48:42 -07:00
|
|
|
bp.try_emplace("internal", IsInternal());
|
|
|
|
|
if (!m_kind_description.empty())
|
|
|
|
|
bp.try_emplace("kindDescription", m_kind_description);
|
|
|
|
|
// Put the full structured data for reproducing this breakpoint in a key/value
|
|
|
|
|
// pair named "details". This allows the breakpoint's details to be visible
|
2023-03-02 16:03:35 -08:00
|
|
|
// in the stats in case we need to reproduce a breakpoint that has long
|
2021-10-26 17:48:42 -07:00
|
|
|
// resolve times
|
|
|
|
|
StructuredData::ObjectSP bp_data_sp = SerializeToStructuredData();
|
|
|
|
|
if (bp_data_sp) {
|
|
|
|
|
std::string buffer;
|
|
|
|
|
llvm::raw_string_ostream ss(buffer);
|
|
|
|
|
json::OStream json_os(ss);
|
|
|
|
|
bp_data_sp->Serialize(json_os);
|
2024-09-16 00:26:51 -04:00
|
|
|
if (auto expected_value = llvm::json::parse(buffer)) {
|
2021-10-26 17:48:42 -07:00
|
|
|
bp.try_emplace("details", std::move(*expected_value));
|
|
|
|
|
} else {
|
|
|
|
|
std::string details_error = toString(expected_value.takeError());
|
|
|
|
|
json::Object details;
|
|
|
|
|
details.try_emplace("error", details_error);
|
|
|
|
|
bp.try_emplace("details", std::move(details));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return json::Value(std::move(bp));
|
|
|
|
|
}
|
2024-11-17 20:36:54 -08:00
|
|
|
|
|
|
|
|
void Breakpoint::ResetStatistics() { m_resolve_time.reset(); }
|