@@ -85,23 +85,6 @@ void StackFrameList::ResetCurrentInlinedDepth() {
8585 if (!m_show_inlined_frames)
8686 return ;
8787
88- GetFramesUpTo (0 , DoNotAllowInterruption);
89- if (m_frames.empty ())
90- return ;
91- if (!m_frames[0 ]->IsInlined ()) {
92- m_current_inlined_depth = UINT32_MAX;
93- m_current_inlined_pc = LLDB_INVALID_ADDRESS;
94- Log *log = GetLog (LLDBLog::Step);
95- if (log && log->GetVerbose ())
96- LLDB_LOGF (
97- log,
98- " ResetCurrentInlinedDepth: Invalidating current inlined depth.\n " );
99- return ;
100- }
101-
102- m_current_inlined_pc = LLDB_INVALID_ADDRESS;
103- m_current_inlined_depth = UINT32_MAX;
104-
10588 StopInfoSP stop_info_sp = m_thread.GetStopInfo ();
10689 if (!stop_info_sp)
10790 return ;
@@ -111,6 +94,7 @@ void StackFrameList::ResetCurrentInlinedDepth() {
11194 // We're only adjusting the inlined stack here.
11295 Log *log = GetLog (LLDBLog::Step);
11396 if (inline_depth) {
97+ std::lock_guard<std::mutex> guard (m_inlined_depth_mutex);
11498 m_current_inlined_depth = *inline_depth;
11599 m_current_inlined_pc = m_thread.GetRegisterContext ()->GetPC ();
116100
@@ -120,6 +104,9 @@ void StackFrameList::ResetCurrentInlinedDepth() {
120104 " depth: %d 0x%" PRIx64 " .\n " ,
121105 m_current_inlined_depth, m_current_inlined_pc);
122106 } else {
107+ std::lock_guard<std::mutex> guard (m_inlined_depth_mutex);
108+ m_current_inlined_pc = LLDB_INVALID_ADDRESS;
109+ m_current_inlined_depth = UINT32_MAX;
123110 if (log && log->GetVerbose ())
124111 LLDB_LOGF (
125112 log,
@@ -689,6 +676,13 @@ StackFrameList::GetFrameWithConcreteFrameIndex(uint32_t unwind_idx) {
689676 return frame_sp;
690677}
691678
679+ static bool CompareStackID (const StackFrameSP &stack_sp,
680+ const StackID &stack_id) {
681+ ProcessSP process_sp = stack_sp->CalculateProcess ();
682+ assert (process_sp && " StackFrames must have a process" );
683+ return StackID::IsYounger (stack_sp->GetStackID (), stack_id, *(process_sp.get ()));
684+ }
685+
692686StackFrameSP StackFrameList::GetFrameWithStackID (const StackID &stack_id) {
693687 StackFrameSP frame_sp;
694688
@@ -698,17 +692,11 @@ StackFrameSP StackFrameList::GetFrameWithStackID(const StackID &stack_id) {
698692 // First see if the frame is already realized. This is the scope for
699693 // the shared mutex:
700694 std::shared_lock<std::shared_mutex> guard (m_list_mutex);
701- // Do a search in case the stack frame is already in our cache.
702- collection::const_iterator begin = m_frames.begin ();
703- collection::const_iterator end = m_frames.end ();
704- if (begin != end) {
705- collection::const_iterator pos =
706- std::find_if (begin, end, [&](StackFrameSP frame_sp) {
707- return frame_sp->GetStackID () == stack_id;
708- });
709- if (pos != end)
710- return *pos;
711- }
695+ // Do a binary search in case the stack frame is already in our cache
696+ collection::const_iterator pos =
697+ llvm::lower_bound (m_frames, stack_id, CompareStackID);
698+ if (pos != m_frames.end () && (*pos)->GetStackID () == stack_id)
699+ return *pos;
712700 }
713701 // If we needed to add more frames, we would get to here.
714702 do {
@@ -762,7 +750,7 @@ void StackFrameList::SelectMostRelevantFrame() {
762750 }
763751 LLDB_LOG (log, " Frame #0 not recognized" );
764752
765- // If this thread has a non-trivial StopInof , then let it suggest
753+ // If this thread has a non-trivial StopInfo , then let it suggest
766754 // a most relevant frame:
767755 StopInfoSP stop_info_sp = m_thread.GetStopInfo ();
768756 uint32_t stack_idx = 0 ;
0 commit comments