diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /lldb/source/Target/StopInfo.cpp | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'lldb/source/Target/StopInfo.cpp')
| -rw-r--r-- | lldb/source/Target/StopInfo.cpp | 105 |
1 files changed, 93 insertions, 12 deletions
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 |
