summaryrefslogtreecommitdiff
path: root/lldb/source/Target
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2025-09-10 15:25:31 -0700
committerGitHub <noreply@github.com>2025-09-10 15:25:31 -0700
commit1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch)
tree57f4b1f313c8cf74eed8819870f39c36ea263c68 /lldb/source/Target
parent898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff)
parentb8cefcb601ddaa18482555c4ff363c01a270c2fe (diff)
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'lldb/source/Target')
-rw-r--r--lldb/source/Target/ABI.cpp4
-rw-r--r--lldb/source/Target/InstrumentationRuntimeStopInfo.cpp42
-rw-r--r--lldb/source/Target/Process.cpp8
-rw-r--r--lldb/source/Target/RegisterContextUnwind.cpp44
-rw-r--r--lldb/source/Target/StackFrame.cpp40
-rw-r--r--lldb/source/Target/StackFrameList.cpp8
-rw-r--r--lldb/source/Target/StackID.cpp11
-rw-r--r--lldb/source/Target/Statistics.cpp20
-rw-r--r--lldb/source/Target/StopInfo.cpp105
9 files changed, 227 insertions, 55 deletions
diff --git a/lldb/source/Target/ABI.cpp b/lldb/source/Target/ABI.cpp
index b86fef6bf03e..3c5107434014 100644
--- a/lldb/source/Target/ABI.cpp
+++ b/lldb/source/Target/ABI.cpp
@@ -232,13 +232,13 @@ bool ABI::GetFallbackRegisterLocation(
}
std::unique_ptr<llvm::MCRegisterInfo> ABI::MakeMCRegisterInfo(const ArchSpec &arch) {
- std::string triple = arch.GetTriple().getTriple();
+ const llvm::Triple &triple = arch.GetTriple();
std::string lookup_error;
const llvm::Target *target =
llvm::TargetRegistry::lookupTarget(triple, lookup_error);
if (!target) {
LLDB_LOG(GetLog(LLDBLog::Process),
- "Failed to create an llvm target for {0}: {1}", triple,
+ "Failed to create an llvm target for {0}: {1}", triple.str(),
lookup_error);
return nullptr;
}
diff --git a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
index 7f82581cc601..aef895def793 100644
--- a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
+++ b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
@@ -8,13 +8,20 @@
#include "lldb/Target/InstrumentationRuntimeStopInfo.h"
+#include "lldb/Core/Module.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/Process.h"
+#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private.h"
using namespace lldb;
using namespace lldb_private;
+static bool IsStoppedInDarwinSanitizer(Thread &thread, Module &module) {
+ return module.GetFileSpec().GetFilename().GetStringRef().starts_with(
+ "libclang_rt.");
+}
+
InstrumentationRuntimeStopInfo::InstrumentationRuntimeStopInfo(
Thread &thread, std::string description,
StructuredData::ObjectSP additional_data)
@@ -34,3 +41,38 @@ InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
return StopInfoSP(
new InstrumentationRuntimeStopInfo(thread, description, additionalData));
}
+
+std::optional<uint32_t>
+InstrumentationRuntimeStopInfo::GetSuggestedStackFrameIndex(
+ bool inlined_stack) {
+ ThreadSP thread_sp = GetThread();
+ if (!thread_sp)
+ return std::nullopt;
+
+ // Defensive upper-bound of when we stop walking up the frames in
+ // case we somehow ended up looking at an infinite recursion.
+ constexpr size_t max_stack_depth = 128;
+
+ // Start at parent frame.
+ size_t stack_idx = 1;
+ StackFrameSP most_relevant_frame_sp =
+ thread_sp->GetStackFrameAtIndex(stack_idx);
+
+ while (most_relevant_frame_sp && stack_idx <= max_stack_depth) {
+ auto const &sc =
+ most_relevant_frame_sp->GetSymbolContext(lldb::eSymbolContextModule);
+
+ if (!sc.module_sp)
+ return std::nullopt;
+
+ // Found a frame outside of the sanitizer runtime libraries.
+ // That's the one we want to display.
+ if (!IsStoppedInDarwinSanitizer(*thread_sp, *sc.module_sp))
+ return stack_idx;
+
+ ++stack_idx;
+ most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(stack_idx);
+ }
+
+ return stack_idx;
+}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index ff9e5fc12059..3176852f0b72 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4269,6 +4269,14 @@ bool Process::ProcessEventData::ShouldStop(Event *event_ptr,
// appropriately. We also need to stop processing actions, since they
// aren't expecting the target to be running.
+ // Clear the selected frame which may have been set as part of utility
+ // expressions that have been run as part of this stop. If we didn't
+ // clear this, then StopInfo::GetSuggestedStackFrameIndex would not
+ // take affect when we next called SelectMostRelevantFrame.
+ // PerformAction should not be the one setting a selected frame, instead
+ // this should be done via GetSuggestedStackFrameIndex.
+ thread_sp->ClearSelectedFrameIndex();
+
// FIXME: we might have run.
if (stop_info_sp->HasTargetRunSinceMe()) {
SetRestarted(true);
diff --git a/lldb/source/Target/RegisterContextUnwind.cpp b/lldb/source/Target/RegisterContextUnwind.cpp
index bcf1297f2114..787eb94be3b4 100644
--- a/lldb/source/Target/RegisterContextUnwind.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -293,6 +293,9 @@ void RegisterContextUnwind::InitializeZerothFrame() {
return;
}
+ // Give the Architecture a chance to replace the UnwindPlan.
+ TryAdoptArchitectureUnwindPlan();
+
UnwindLogMsg("initialized frame current pc is 0x%" PRIx64 " cfa is 0x%" PRIx64
" afa is 0x%" PRIx64 " using %s UnwindPlan",
(uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()),
@@ -482,6 +485,9 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
}
}
+ // Give the Architecture a chance to replace the UnwindPlan.
+ TryAdoptArchitectureUnwindPlan();
+
UnwindLogMsg("initialized frame cfa is 0x%" PRIx64 " afa is 0x%" PRIx64,
(uint64_t)m_cfa, (uint64_t)m_afa);
return;
@@ -686,6 +692,9 @@ void RegisterContextUnwind::InitializeNonZerothFrame() {
}
}
+ // Give the Architecture a chance to replace the UnwindPlan.
+ TryAdoptArchitectureUnwindPlan();
+
UnwindLogMsg("initialized frame current pc is 0x%" PRIx64
" cfa is 0x%" PRIx64 " afa is 0x%" PRIx64,
(uint64_t)m_current_pc.GetLoadAddress(exe_ctx.GetTargetPtr()),
@@ -1717,6 +1726,41 @@ RegisterContextUnwind::SavedLocationForRegister(
return UnwindLLDB::RegisterSearchResult::eRegisterNotFound;
}
+UnwindPlanSP RegisterContextUnwind::TryAdoptArchitectureUnwindPlan() {
+ if (!m_full_unwind_plan_sp)
+ return {};
+ ProcessSP process_sp = m_thread.GetProcess();
+ if (!process_sp)
+ return {};
+
+ UnwindPlanSP arch_override_plan_sp;
+ if (Architecture *arch = process_sp->GetTarget().GetArchitecturePlugin())
+ arch_override_plan_sp =
+ arch->GetArchitectureUnwindPlan(m_thread, this, m_full_unwind_plan_sp);
+
+ if (arch_override_plan_sp) {
+ m_full_unwind_plan_sp = arch_override_plan_sp;
+ PropagateTrapHandlerFlagFromUnwindPlan(m_full_unwind_plan_sp);
+ m_registers.clear();
+ if (GetLog(LLDBLog::Unwind)) {
+ UnwindLogMsg(
+ "Replacing Full Unwindplan with Architecture UnwindPlan, '%s'",
+ m_full_unwind_plan_sp->GetSourceName().AsCString());
+ const UnwindPlan::Row *active_row =
+ m_full_unwind_plan_sp->GetRowForFunctionOffset(m_current_offset);
+ if (active_row) {
+ StreamString active_row_strm;
+ active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(),
+ &m_thread,
+ m_start_pc.GetLoadAddress(&process_sp->GetTarget()));
+ UnwindLogMsg("%s", active_row_strm.GetData());
+ }
+ }
+ }
+
+ return {};
+}
+
// TryFallbackUnwindPlan() -- this method is a little tricky.
//
// When this is called, the frame above -- the caller frame, the "previous"
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 40049d40aa41..2ed58c5331df 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -57,14 +57,14 @@ using namespace lldb_private;
StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
user_id_t unwind_frame_index, addr_t cfa,
bool cfa_is_valid, addr_t pc, StackFrame::Kind kind,
- bool behaves_like_zeroth_frame,
+ bool artificial, bool behaves_like_zeroth_frame,
const SymbolContext *sc_ptr)
: m_thread_wp(thread_sp), m_frame_index(frame_idx),
m_concrete_frame_index(unwind_frame_index), m_reg_context_sp(),
m_id(pc, cfa, nullptr, thread_sp->GetProcess().get()),
m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(),
m_frame_base_error(), m_cfa_is_valid(cfa_is_valid),
- m_stack_frame_kind(kind),
+ m_stack_frame_kind(kind), m_artificial(artificial),
m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
m_variable_list_sp(), m_variable_list_value_objects(),
m_recognized_frame_sp(), m_disassembly(), m_mutex() {
@@ -92,7 +92,7 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
m_id(pc, cfa, nullptr, thread_sp->GetProcess().get()),
m_frame_code_addr(pc), m_sc(), m_flags(), m_frame_base(),
m_frame_base_error(), m_cfa_is_valid(true),
- m_stack_frame_kind(StackFrame::Kind::Regular),
+ m_stack_frame_kind(StackFrame::Kind::Regular), m_artificial(false),
m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
m_variable_list_sp(), m_variable_list_value_objects(),
m_recognized_frame_sp(), m_disassembly(), m_mutex() {
@@ -120,7 +120,7 @@ StackFrame::StackFrame(const ThreadSP &thread_sp, user_id_t frame_idx,
nullptr, thread_sp->GetProcess().get()),
m_frame_code_addr(pc_addr), m_sc(), m_flags(), m_frame_base(),
m_frame_base_error(), m_cfa_is_valid(true),
- m_stack_frame_kind(StackFrame::Kind::Regular),
+ m_stack_frame_kind(StackFrame::Kind::Regular), m_artificial(false),
m_behaves_like_zeroth_frame(behaves_like_zeroth_frame),
m_variable_list_sp(), m_variable_list_value_objects(),
m_recognized_frame_sp(), m_disassembly(), m_mutex() {
@@ -266,6 +266,7 @@ bool StackFrame::ChangePC(addr_t pc) {
const char *StackFrame::Disassemble() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
+
if (!m_disassembly.Empty())
return m_disassembly.GetData();
@@ -440,10 +441,10 @@ VariableList *StackFrame::GetVariableList(bool get_file_globals,
const bool get_child_variables = true;
const bool can_create = true;
const bool stop_if_child_block_is_inlined_function = true;
- frame_block->AppendBlockVariables(can_create, get_child_variables,
- stop_if_child_block_is_inlined_function,
- [](Variable *v) { return true; },
- m_variable_list_sp.get());
+ frame_block->AppendBlockVariables(
+ can_create, get_child_variables,
+ stop_if_child_block_is_inlined_function,
+ [](Variable *v) { return true; }, m_variable_list_sp.get());
}
}
@@ -1227,10 +1228,12 @@ StackFrame::GetValueObjectForFrameVariable(const VariableSP &variable_sp,
VariableList *var_list = GetVariableList(true, nullptr);
if (var_list) {
// Make sure the variable is a frame variable
- const uint32_t var_idx = var_list->FindIndexForVariable(variable_sp.get());
+ const uint32_t var_idx =
+ var_list->FindIndexForVariable(variable_sp.get());
const uint32_t num_variables = var_list->GetSize();
if (var_idx < num_variables) {
- valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex(var_idx);
+ valobj_sp =
+ m_variable_list_value_objects.GetValueObjectAtIndex(var_idx);
if (!valobj_sp) {
if (m_variable_list_value_objects.GetSize() < num_variables)
m_variable_list_value_objects.Resize(num_variables);
@@ -1261,10 +1264,12 @@ bool StackFrame::IsHistorical() const {
return m_stack_frame_kind == StackFrame::Kind::History;
}
-bool StackFrame::IsArtificial() const {
- return m_stack_frame_kind == StackFrame::Kind::Artificial;
+bool StackFrame::IsSynthetic() const {
+ return m_stack_frame_kind == StackFrame::Kind::Synthetic;
}
+bool StackFrame::IsArtificial() const { return m_artificial; }
+
bool StackFrame::IsHidden() {
if (auto recognized_frame_sp = GetRecognizedFrame())
return recognized_frame_sp->ShouldHide();
@@ -1764,11 +1769,9 @@ lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
if (clobbered_reg_matcher(operands[0])) {
origin_operand = &operands[1];
- }
- else if (clobbered_reg_matcher(operands[1])) {
+ } else if (clobbered_reg_matcher(operands[1])) {
origin_operand = &operands[0];
- }
- else {
+ } else {
continue;
}
@@ -1794,8 +1797,7 @@ lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
if (!source_path) {
continue;
}
- source_path =
- GetValueForDereferincingOffset(frame, source_path, offset);
+ source_path = GetValueForDereferincingOffset(frame, source_path, offset);
}
if (source_path) {
@@ -1805,7 +1807,7 @@ lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
return ValueObjectSP();
}
-}
+} // namespace
lldb::ValueObjectSP StackFrame::GuessValueForRegisterAndOffset(ConstString reg,
int64_t offset) {
diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp
index aedfc52cfb4c..fa5d159c0c91 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -321,13 +321,14 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
addr_t pc = calleeInfo.address;
// If the callee address refers to the call instruction, we do not want to
// subtract 1 from this value.
+ const bool artificial = true;
const bool behaves_like_zeroth_frame =
calleeInfo.address_type == CallEdge::AddrType::Call;
SymbolContext sc;
callee->CalculateSymbolContext(&sc);
auto synth_frame = std::make_shared<StackFrame>(
m_thread.shared_from_this(), frame_idx, concrete_frame_idx, cfa,
- cfa_is_valid, pc, StackFrame::Kind::Artificial,
+ cfa_is_valid, pc, StackFrame::Kind::Regular, artificial,
behaves_like_zeroth_frame, &sc);
m_frames.push_back(synth_frame);
LLDB_LOG(log, "Pushed frame {0} at {1:x}", callee->GetDisplayName(), pc);
@@ -470,7 +471,8 @@ bool StackFrameList::FetchFramesUpTo(uint32_t end_idx,
const bool cfa_is_valid = true;
unwind_frame_sp = std::make_shared<StackFrame>(
m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid,
- pc, StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
+ pc, StackFrame::Kind::Regular, false, behaves_like_zeroth_frame,
+ nullptr);
// Create synthetic tail call frames between the previous frame and the
// newly-found frame. The new frame's index may change after this call,
@@ -942,3 +944,5 @@ size_t StackFrameList::GetStatus(Stream &strm, uint32_t first_frame,
strm.IndentLess();
return num_frames_displayed;
}
+
+void StackFrameList::ClearSelectedFrameIndex() { m_selected_frame_idx.reset(); }
diff --git a/lldb/source/Target/StackID.cpp b/lldb/source/Target/StackID.cpp
index b1795970802a..f879276527dd 100644
--- a/lldb/source/Target/StackID.cpp
+++ b/lldb/source/Target/StackID.cpp
@@ -63,16 +63,7 @@ bool lldb_private::operator==(const StackID &lhs, const StackID &rhs) {
}
bool lldb_private::operator!=(const StackID &lhs, const StackID &rhs) {
- if (lhs.GetCallFrameAddress() != rhs.GetCallFrameAddress())
- return true;
-
- SymbolContextScope *lhs_scope = lhs.GetSymbolContextScope();
- SymbolContextScope *rhs_scope = rhs.GetSymbolContextScope();
-
- if (lhs_scope == nullptr && rhs_scope == nullptr)
- return lhs.GetPC() != rhs.GetPC();
-
- return lhs_scope != rhs_scope;
+ return !(lhs == rhs);
}
bool lldb_private::operator<(const StackID &lhs, const StackID &rhs) {
diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index 909f335687b2..8ad8d507268e 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -73,8 +73,9 @@ json::Value ModuleStats::ToJSON() const {
debug_info_had_incomplete_types);
module.try_emplace("symbolTableStripped", symtab_stripped);
module.try_emplace("symbolTableSymbolCount", symtab_symbol_count);
- module.try_emplace("dwoFileCount", dwo_file_count);
- module.try_emplace("loadedDwoFileCount", loaded_dwo_file_count);
+ module.try_emplace("dwoFileCount", dwo_stats.dwo_file_count);
+ module.try_emplace("loadedDwoFileCount", dwo_stats.loaded_dwo_file_count);
+ module.try_emplace("dwoErrorCount", dwo_stats.dwo_error_count);
if (!symbol_locator_time.map.empty()) {
json::Object obj;
@@ -324,8 +325,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(
uint32_t num_modules_with_incomplete_types = 0;
uint32_t num_stripped_modules = 0;
uint32_t symtab_symbol_count = 0;
- uint32_t total_loaded_dwo_file_count = 0;
- uint32_t total_dwo_file_count = 0;
+ DWOStats total_dwo_stats;
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
Module *module = target != nullptr
? target->GetImages().GetModuleAtIndex(image_idx).get()
@@ -357,10 +357,9 @@ llvm::json::Value DebuggerStats::ReportStatistics(
for (const auto &symbol_module : symbol_modules.Modules())
module_stat.symfile_modules.push_back((intptr_t)symbol_module.get());
}
- std::tie(module_stat.loaded_dwo_file_count, module_stat.dwo_file_count) =
- sym_file->GetDwoFileCounts();
- total_dwo_file_count += module_stat.dwo_file_count;
- total_loaded_dwo_file_count += module_stat.loaded_dwo_file_count;
+ DWOStats current_dwo_stats = sym_file->GetDwoStats();
+ module_stat.dwo_stats += current_dwo_stats;
+ total_dwo_stats += current_dwo_stats;
module_stat.debug_info_index_loaded_from_cache =
sym_file->GetDebugInfoIndexWasLoadedFromCache();
if (module_stat.debug_info_index_loaded_from_cache)
@@ -435,8 +434,9 @@ llvm::json::Value DebuggerStats::ReportStatistics(
{"totalDebugInfoEnabled", num_debug_info_enabled_modules},
{"totalSymbolTableStripped", num_stripped_modules},
{"totalSymbolTableSymbolCount", symtab_symbol_count},
- {"totalLoadedDwoFileCount", total_loaded_dwo_file_count},
- {"totalDwoFileCount", total_dwo_file_count},
+ {"totalLoadedDwoFileCount", total_dwo_stats.loaded_dwo_file_count},
+ {"totalDwoFileCount", total_dwo_stats.dwo_file_count},
+ {"totalDwoErrorCount", total_dwo_stats.dwo_error_count},
};
if (include_targets) {
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index ddf8c62e969e..f47dae2b2465 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -108,8 +108,7 @@ public:
void StoreBPInfo() {
ThreadSP thread_sp(m_thread_wp.lock());
if (thread_sp) {
- BreakpointSiteSP bp_site_sp(
- thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value));
+ BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
if (bp_site_sp) {
uint32_t num_constituents = bp_site_sp->GetNumberOfConstituents();
if (num_constituents == 1) {
@@ -139,8 +138,7 @@ public:
bool IsValidForOperatingSystemThread(Thread &thread) override {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
- BreakpointSiteSP bp_site_sp(
- process_sp->GetBreakpointSiteList().FindByID(m_value));
+ BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
if (bp_site_sp)
return bp_site_sp->ValidForThisThread(thread);
}
@@ -154,8 +152,7 @@ public:
if (thread_sp) {
if (!m_should_stop_is_valid) {
// Only check once if we should stop at a breakpoint
- BreakpointSiteSP bp_site_sp(
- thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value));
+ BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
if (bp_site_sp) {
ExecutionContext exe_ctx(thread_sp->GetStackFrameAtIndex(0));
StoppointCallbackContext context(event_ptr, exe_ctx, true);
@@ -186,8 +183,7 @@ public:
if (m_description.empty()) {
ThreadSP thread_sp(m_thread_wp.lock());
if (thread_sp) {
- BreakpointSiteSP bp_site_sp(
- thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value));
+ BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
if (bp_site_sp) {
StreamString strm;
// If we have just hit an internal breakpoint, and it has a kind
@@ -247,6 +243,35 @@ public:
return m_description.c_str();
}
+ uint32_t GetStopReasonDataCount() const override {
+ lldb::BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
+ if (bp_site_sp)
+ return bp_site_sp->GetNumberOfConstituents() * 2;
+ return 0; // Breakpoint must have cleared itself...
+ }
+
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ lldb::BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
+ if (bp_site_sp) {
+ uint32_t bp_index = idx / 2;
+ BreakpointLocationSP bp_loc_sp(
+ bp_site_sp->GetConstituentAtIndex(bp_index));
+ if (bp_loc_sp) {
+ if (idx & 1) {
+ // FIXME: This might be a Facade breakpoint, so we need to fetch
+ // the one that the thread actually hit, not the native loc ID.
+
+ // Odd idx, return the breakpoint location ID
+ return bp_loc_sp->GetID();
+ } else {
+ // Even idx, return the breakpoint ID
+ return bp_loc_sp->GetBreakpoint().GetID();
+ }
+ }
+ }
+ return LLDB_INVALID_BREAK_ID;
+ }
+
std::optional<uint32_t>
GetSuggestedStackFrameIndex(bool inlined_stack) override {
if (!inlined_stack)
@@ -255,8 +280,7 @@ public:
ThreadSP thread_sp(m_thread_wp.lock());
if (!thread_sp)
return {};
- BreakpointSiteSP bp_site_sp(
- thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value));
+ BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
if (!bp_site_sp)
return {};
@@ -297,8 +321,7 @@ protected:
return;
}
- BreakpointSiteSP bp_site_sp(
- thread_sp->GetProcess()->GetBreakpointSiteList().FindByID(m_value));
+ BreakpointSiteSP bp_site_sp = GetBreakpointSiteSP();
std::unordered_set<break_id_t> precondition_breakpoints;
// Breakpoints that fail their condition check are not considered to
// have been hit. If the only locations at this site have failed their
@@ -629,6 +652,20 @@ protected:
}
private:
+ BreakpointSiteSP GetBreakpointSiteSP() const {
+ if (m_value == LLDB_INVALID_BREAK_ID)
+ return {};
+
+ ThreadSP thread_sp = GetThread();
+ if (!thread_sp)
+ return {};
+ ProcessSP process_sp = thread_sp->GetProcess();
+ if (!process_sp)
+ return {};
+
+ return process_sp->GetBreakpointSiteList().FindByID(m_value);
+ }
+
bool m_should_stop;
bool m_should_stop_is_valid;
bool m_should_perform_action; // Since we are trying to preserve the "state"
@@ -699,6 +736,13 @@ public:
StopReason GetStopReason() const override { return eStopReasonWatchpoint; }
+ uint32_t GetStopReasonDataCount() const override { return 1; }
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ if (idx == 0)
+ return GetValue();
+ return 0;
+ }
+
const char *GetDescription() override {
if (m_description.empty()) {
StreamString strm;
@@ -1139,6 +1183,13 @@ public:
bool ShouldSelect() const override { return IsShouldStopSignal(); }
+ uint32_t GetStopReasonDataCount() const override { return 1; }
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ if (idx == 0)
+ return GetValue();
+ return 0;
+ }
+
private:
// In siginfo_t terms, if m_value is si_signo, m_code is si_code.
std::optional<int> m_code;
@@ -1171,6 +1222,14 @@ public:
}
return m_description.c_str();
}
+
+ uint32_t GetStopReasonDataCount() const override { return 1; }
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ if (idx == 0)
+ return GetValue();
+ else
+ return 0;
+ }
};
// StopInfoTrace
@@ -1249,6 +1308,13 @@ public:
else
return m_description.c_str();
}
+ uint32_t GetStopReasonDataCount() const override { return 1; }
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ if (idx == 0)
+ return GetValue();
+ else
+ return 0;
+ }
};
// StopInfoProcessorTrace
@@ -1390,6 +1456,14 @@ public:
const char *GetDescription() override { return "fork"; }
+ uint32_t GetStopReasonDataCount() const override { return 1; }
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ if (idx == 0)
+ return GetValue();
+ else
+ return 0;
+ }
+
protected:
void PerformAction(Event *event_ptr) override {
// Only perform the action once
@@ -1424,6 +1498,13 @@ public:
const char *GetDescription() override { return "vfork"; }
+ uint32_t GetStopReasonDataCount() const override { return 1; }
+ uint64_t GetStopReasonDataAtIndex(uint32_t idx) override {
+ if (idx == 0)
+ return GetValue();
+ return 0;
+ }
+
protected:
void PerformAction(Event *event_ptr) override {
// Only perform the action once