1 //===-- StackFrameList.cpp --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Target/StackFrameList.h"
14 // Other libraries and framework includes
16 #include "lldb/Breakpoint/BreakpointLocation.h"
17 #include "lldb/Breakpoint/Breakpoint.h"
18 #include "lldb/Core/Log.h"
19 #include "lldb/Core/StreamFile.h"
20 #include "lldb/Core/SourceManager.h"
21 #include "lldb/Symbol/Block.h"
22 #include "lldb/Symbol/Function.h"
23 #include "lldb/Symbol/Symbol.h"
24 #include "lldb/Target/Process.h"
25 #include "lldb/Target/RegisterContext.h"
26 #include "lldb/Target/StackFrame.h"
27 #include "lldb/Target/StopInfo.h"
28 #include "lldb/Target/Target.h"
29 #include "lldb/Target/Thread.h"
30 #include "lldb/Target/Unwind.h"
32 //#define DEBUG_STACK_FRAMES 1
35 using namespace lldb_private;
37 //----------------------------------------------------------------------
38 // StackFrameList constructor
39 //----------------------------------------------------------------------
40 StackFrameList::StackFrameList
43 const lldb::StackFrameListSP &prev_frames_sp,
44 bool show_inline_frames
47 m_prev_frames_sp (prev_frames_sp),
48 m_mutex (Mutex::eMutexTypeRecursive),
50 m_selected_frame_idx (0),
51 m_concrete_frames_fetched (0),
52 m_current_inlined_depth (UINT32_MAX),
53 m_current_inlined_pc (LLDB_INVALID_ADDRESS),
54 m_show_inlined_frames (show_inline_frames)
58 m_current_inlined_depth = prev_frames_sp->m_current_inlined_depth;
59 m_current_inlined_pc = prev_frames_sp->m_current_inlined_pc;
63 //----------------------------------------------------------------------
65 //----------------------------------------------------------------------
66 StackFrameList::~StackFrameList()
68 // Call clear since this takes a lock and clears the stack frame list
69 // in case another thread is currently using this stack frame list
74 StackFrameList::CalculateCurrentInlinedDepth()
76 uint32_t cur_inlined_depth = GetCurrentInlinedDepth();
77 if (cur_inlined_depth == UINT32_MAX)
79 ResetCurrentInlinedDepth();
84 StackFrameList::GetCurrentInlinedDepth ()
86 if (m_show_inlined_frames && m_current_inlined_pc != LLDB_INVALID_ADDRESS)
88 lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
89 if (cur_pc != m_current_inlined_pc)
91 m_current_inlined_pc = LLDB_INVALID_ADDRESS;
92 m_current_inlined_depth = UINT32_MAX;
93 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
94 if (log && log->GetVerbose())
95 log->Printf ("GetCurrentInlinedDepth: invalidating current inlined depth.\n");
97 return m_current_inlined_depth;
106 StackFrameList::ResetCurrentInlinedDepth ()
108 if (m_show_inlined_frames)
111 if (!m_frames[0]->IsInlined())
113 m_current_inlined_depth = UINT32_MAX;
114 m_current_inlined_pc = LLDB_INVALID_ADDRESS;
115 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
116 if (log && log->GetVerbose())
117 log->Printf ("ResetCurrentInlinedDepth: Invalidating current inlined depth.\n");
121 // We only need to do something special about inlined blocks when we
122 // are at the beginning of an inlined function:
123 // FIXME: We probably also have to do something special if the PC is at the END
124 // of an inlined function, which coincides with the end of either its containing
125 // function or another inlined function.
127 lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC();
128 Block *block_ptr = m_frames[0]->GetFrameBlock();
131 Address pc_as_address;
132 pc_as_address.SetLoadAddress(curr_pc, &(m_thread.GetProcess()->GetTarget()));
133 AddressRange containing_range;
134 if (block_ptr->GetRangeContainingAddress(pc_as_address, containing_range))
136 if (pc_as_address == containing_range.GetBaseAddress())
138 // If we got here because of a breakpoint hit, then set the inlined depth depending on where
139 // the breakpoint was set.
140 // If we got here because of a crash, then set the inlined depth to the deepest most block.
141 // Otherwise, we stopped here naturally as the result of a step, so set ourselves in the
142 // containing frame of the whole set of nested inlines, so the user can then "virtually"
143 // step into the frames one by one, or next over the whole mess.
144 // Note: We don't have to handle being somewhere in the middle of the stack here, since
145 // ResetCurrentInlinedDepth doesn't get called if there is a valid inlined depth set.
146 StopInfoSP stop_info_sp = m_thread.GetStopInfo();
149 switch (stop_info_sp->GetStopReason())
151 case eStopReasonWatchpoint:
152 case eStopReasonException:
153 case eStopReasonExec:
154 case eStopReasonSignal:
155 // In all these cases we want to stop in the deepest most frame.
156 m_current_inlined_pc = curr_pc;
157 m_current_inlined_depth = 0;
159 case eStopReasonBreakpoint:
161 // FIXME: Figure out what this break point is doing, and set the inline depth
162 // appropriately. Be careful to take into account breakpoints that implement
163 // step over prologue, since that should do the default calculation.
164 // For now, if the breakpoints corresponding to this hit are all internal,
165 // I set the stop location to the top of the inlined stack, since that will make
166 // things like stepping over prologues work right. But if there are any non-internal
167 // breakpoints I do to the bottom of the stack, since that was the old behavior.
168 uint32_t bp_site_id = stop_info_sp->GetValue();
169 BreakpointSiteSP bp_site_sp(m_thread.GetProcess()->GetBreakpointSiteList().FindByID(bp_site_id));
170 bool all_internal = true;
173 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
174 for (uint32_t i = 0; i < num_owners; i++)
176 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
177 if (!bp_ref.IsInternal())
179 all_internal = false;
185 m_current_inlined_pc = curr_pc;
186 m_current_inlined_depth = 0;
192 // Otherwise, we should set ourselves at the container of the inlining, so that the
193 // user can descend into them.
194 // So first we check whether we have more than one inlined block sharing this PC:
195 int num_inlined_functions = 0;
197 for (Block *container_ptr = block_ptr->GetInlinedParent();
198 container_ptr != NULL;
199 container_ptr = container_ptr->GetInlinedParent())
201 if (!container_ptr->GetRangeContainingAddress(pc_as_address, containing_range))
203 if (pc_as_address != containing_range.GetBaseAddress())
206 num_inlined_functions++;
208 m_current_inlined_pc = curr_pc;
209 m_current_inlined_depth = num_inlined_functions + 1;
210 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
211 if (log && log->GetVerbose())
212 log->Printf ("ResetCurrentInlinedDepth: setting inlined depth: %d 0x%" PRIx64 ".\n", m_current_inlined_depth, curr_pc);
226 StackFrameList::DecrementCurrentInlinedDepth ()
228 if (m_show_inlined_frames)
230 uint32_t current_inlined_depth = GetCurrentInlinedDepth();
231 if (current_inlined_depth != UINT32_MAX)
233 if (current_inlined_depth > 0)
235 m_current_inlined_depth--;
244 StackFrameList::SetCurrentInlinedDepth (uint32_t new_depth)
246 m_current_inlined_depth = new_depth;
247 if (new_depth == UINT32_MAX)
248 m_current_inlined_pc = LLDB_INVALID_ADDRESS;
250 m_current_inlined_pc = m_thread.GetRegisterContext()->GetPC();
254 StackFrameList::GetFramesUpTo(uint32_t end_idx)
256 // this makes sure we do not fetch frames for an invalid thread
257 if (m_thread.IsValid() == false)
260 // We've already gotten more frames than asked for, or we've already finished unwinding, return.
261 if (m_frames.size() > end_idx || GetAllFramesFetched())
264 Unwind *unwinder = m_thread.GetUnwinder ();
266 if (m_show_inlined_frames)
268 #if defined (DEBUG_STACK_FRAMES)
269 StreamFile s(stdout, false);
271 // If we are hiding some frames from the outside world, we need to add those onto the total count of
272 // frames to fetch. However, we don't need ot do that if end_idx is 0 since in that case we always
273 // get the first concrete frame and all the inlined frames below it... And of course, if end_idx is
274 // UINT32_MAX that means get all, so just do that...
276 uint32_t inlined_depth = 0;
277 if (end_idx > 0 && end_idx != UINT32_MAX)
279 inlined_depth = GetCurrentInlinedDepth();
280 if (inlined_depth != UINT32_MAX)
283 end_idx += inlined_depth;
287 StackFrameSP unwind_frame_sp;
290 uint32_t idx = m_concrete_frames_fetched++;
295 // We might have already created frame zero, only create it
297 if (m_frames.empty())
299 RegisterContextSP reg_ctx_sp (m_thread.GetRegisterContext());
304 const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
305 // There shouldn't be any way not to get the frame info for frame 0.
306 // But if the unwinder can't make one, lets make one by hand with the
307 // SP as the CFA and see if that gets any further.
310 cfa = reg_ctx_sp->GetSP();
311 pc = reg_ctx_sp->GetPC();
314 unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(),
321 m_frames.push_back (unwind_frame_sp);
326 unwind_frame_sp = m_frames.front();
327 cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
332 const bool success = unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
335 // We've gotten to the end of the stack.
336 SetAllFramesFetched();
339 unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), m_frames.size(), idx, cfa, pc, NULL));
340 m_frames.push_back (unwind_frame_sp);
343 SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction);
344 Block *unwind_block = unwind_sc.block;
347 Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
348 // Be sure to adjust the frame address to match the address
349 // that was used to lookup the symbol context above. If we are
350 // in the first concrete frame, then we lookup using the current
351 // address, else we decrement the address by one to get the correct
354 curr_frame_address.Slide(-1);
356 SymbolContext next_frame_sc;
357 Address next_frame_address;
359 while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
361 StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
364 unwind_frame_sp->GetRegisterContextSP (),
369 m_frames.push_back (frame_sp);
370 unwind_sc = next_frame_sc;
371 curr_frame_address = next_frame_address;
374 } while (m_frames.size() - 1 < end_idx);
376 // Don't try to merge till you've calculated all the frames in this stack.
377 if (GetAllFramesFetched() && m_prev_frames_sp)
379 StackFrameList *prev_frames = m_prev_frames_sp.get();
380 StackFrameList *curr_frames = this;
382 //curr_frames->m_current_inlined_depth = prev_frames->m_current_inlined_depth;
383 //curr_frames->m_current_inlined_pc = prev_frames->m_current_inlined_pc;
384 //printf ("GetFramesUpTo: Copying current inlined depth: %d 0x%" PRIx64 ".\n", curr_frames->m_current_inlined_depth, curr_frames->m_current_inlined_pc);
386 #if defined (DEBUG_STACK_FRAMES)
387 s.PutCString("\nprev_frames:\n");
388 prev_frames->Dump (&s);
389 s.PutCString("\ncurr_frames:\n");
390 curr_frames->Dump (&s);
393 size_t curr_frame_num, prev_frame_num;
395 for (curr_frame_num = curr_frames->m_frames.size(), prev_frame_num = prev_frames->m_frames.size();
396 curr_frame_num > 0 && prev_frame_num > 0;
397 --curr_frame_num, --prev_frame_num)
399 const size_t curr_frame_idx = curr_frame_num-1;
400 const size_t prev_frame_idx = prev_frame_num-1;
401 StackFrameSP curr_frame_sp (curr_frames->m_frames[curr_frame_idx]);
402 StackFrameSP prev_frame_sp (prev_frames->m_frames[prev_frame_idx]);
404 #if defined (DEBUG_STACK_FRAMES)
405 s.Printf("\n\nCurr frame #%u ", curr_frame_idx);
407 curr_frame_sp->Dump (&s, true, false);
409 s.PutCString("NULL");
410 s.Printf("\nPrev frame #%u ", prev_frame_idx);
412 prev_frame_sp->Dump (&s, true, false);
414 s.PutCString("NULL");
417 StackFrame *curr_frame = curr_frame_sp.get();
418 StackFrame *prev_frame = prev_frame_sp.get();
420 if (curr_frame == NULL || prev_frame == NULL)
423 // Check the stack ID to make sure they are equal
424 if (curr_frame->GetStackID() != prev_frame->GetStackID())
427 prev_frame->UpdatePreviousFrameFromCurrentFrame (*curr_frame);
428 // Now copy the fixed up previous frame into the current frames
429 // so the pointer doesn't change
430 m_frames[curr_frame_idx] = prev_frame_sp;
431 //curr_frame->UpdateCurrentFrameFromPreviousFrame (*prev_frame);
433 #if defined (DEBUG_STACK_FRAMES)
434 s.Printf("\n Copying previous frame to current frame");
437 // We are done with the old stack frame list, we can release it now
438 m_prev_frames_sp.reset();
441 #if defined (DEBUG_STACK_FRAMES)
442 s.PutCString("\n\nNew frames:\n");
449 if (end_idx < m_concrete_frames_fetched)
452 uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
453 if (num_frames <= end_idx + 1)
456 m_concrete_frames_fetched = UINT32_MAX;
458 m_frames.resize(num_frames);
463 StackFrameList::GetNumFrames (bool can_create)
465 Mutex::Locker locker (m_mutex);
468 GetFramesUpTo (UINT32_MAX);
470 uint32_t inlined_depth = GetCurrentInlinedDepth();
471 if (inlined_depth == UINT32_MAX)
472 return m_frames.size();
474 return m_frames.size() - inlined_depth;
478 StackFrameList::Dump (Stream *s)
482 Mutex::Locker locker (m_mutex);
484 const_iterator pos, begin = m_frames.begin(), end = m_frames.end();
485 for (pos = begin; pos != end; ++pos)
487 StackFrame *frame = (*pos).get();
488 s->Printf("%p: ", frame);
491 frame->GetStackID().Dump (s);
492 frame->DumpUsingSettingsFormat (s);
495 s->Printf("frame #%u", (uint32_t)std::distance (begin, pos));
502 StackFrameList::GetFrameAtIndex (uint32_t idx)
504 StackFrameSP frame_sp;
505 Mutex::Locker locker (m_mutex);
506 uint32_t original_idx = idx;
508 uint32_t inlined_depth = GetCurrentInlinedDepth();
509 if (inlined_depth != UINT32_MAX)
510 idx += inlined_depth;
512 if (idx < m_frames.size())
513 frame_sp = m_frames[idx];
518 // GetFramesUpTo will fill m_frames with as many frames as you asked for,
519 // if there are that many. If there weren't then you asked for too many
522 if (idx < m_frames.size())
524 if (m_show_inlined_frames)
526 // When inline frames are enabled we actually create all the frames in GetFramesUpTo.
527 frame_sp = m_frames[idx];
531 Unwind *unwinder = m_thread.GetUnwinder ();
535 if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
537 frame_sp.reset (new StackFrame (m_thread.shared_from_this(), idx, idx, cfa, pc, NULL));
539 Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function;
542 // When we aren't showing inline functions we always use
543 // the top most function block as the scope.
544 frame_sp->SetSymbolContextScope (&function->GetBlock(false));
548 // Set the symbol scope from the symbol regardless if it is NULL or valid.
549 frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
551 SetFrameAtIndex(idx, frame_sp);
556 else if (original_idx == 0)
558 // There should ALWAYS be a frame at index 0. If something went wrong with the CurrentInlinedDepth such that
559 // there weren't as many frames as we thought taking that into account, then reset the current inlined depth
560 // and return the real zeroth frame.
561 if (m_frames.size() > 0)
563 ResetCurrentInlinedDepth();
564 frame_sp = m_frames[original_idx];
568 // Why do we have a thread with zero frames, that should not ever happen...
569 if (m_thread.IsValid())
570 assert ("A valid thread has no frames.");
579 StackFrameList::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
581 // First try assuming the unwind index is the same as the frame index. The
582 // unwind index is always greater than or equal to the frame index, so it
583 // is a good place to start. If we have inlined frames we might have 5
584 // concrete frames (frame unwind indexes go from 0-4), but we might have 15
585 // frames after we make all the inlined frames. Most of the time the unwind
586 // frame index (or the concrete frame index) is the same as the frame index.
587 uint32_t frame_idx = unwind_idx;
588 StackFrameSP frame_sp (GetFrameAtIndex (frame_idx));
591 if (frame_sp->GetFrameIndex() == unwind_idx)
593 frame_sp = GetFrameAtIndex (++frame_idx);
599 CompareStackID (const StackFrameSP &stack_sp, const StackID &stack_id)
601 return stack_sp->GetStackID() < stack_id;
605 StackFrameList::GetFrameWithStackID (const StackID &stack_id)
607 StackFrameSP frame_sp;
609 if (stack_id.IsValid())
611 Mutex::Locker locker (m_mutex);
612 uint32_t frame_idx = 0;
613 // Do a binary search in case the stack frame is already in our cache
614 collection::const_iterator begin = m_frames.begin();
615 collection::const_iterator end = m_frames.end();
618 collection::const_iterator pos = std::lower_bound (begin, end, stack_id, CompareStackID);
619 if (pos != end && (*pos)->GetStackID() == stack_id)
622 if (m_frames.back()->GetStackID() < stack_id)
623 frame_idx = m_frames.size();
627 frame_sp = GetFrameAtIndex (frame_idx);
628 if (frame_sp && frame_sp->GetStackID() == stack_id)
638 StackFrameList::SetFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
640 if (idx >= m_frames.size())
641 m_frames.resize(idx + 1);
642 // Make sure allocation succeeded by checking bounds again
643 if (idx < m_frames.size())
645 m_frames[idx] = frame_sp;
648 return false; // resize failed, out of memory?
652 StackFrameList::GetSelectedFrameIndex () const
654 Mutex::Locker locker (m_mutex);
655 return m_selected_frame_idx;
660 StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame)
662 Mutex::Locker locker (m_mutex);
664 const_iterator begin = m_frames.begin();
665 const_iterator end = m_frames.end();
666 m_selected_frame_idx = 0;
667 for (pos = begin; pos != end; ++pos)
669 if (pos->get() == frame)
671 m_selected_frame_idx = std::distance (begin, pos);
672 uint32_t inlined_depth = GetCurrentInlinedDepth();
673 if (inlined_depth != UINT32_MAX)
674 m_selected_frame_idx -= inlined_depth;
678 SetDefaultFileAndLineToSelectedFrame();
679 return m_selected_frame_idx;
682 // Mark a stack frame as the current frame using the frame index
684 StackFrameList::SetSelectedFrameByIndex (uint32_t idx)
686 Mutex::Locker locker (m_mutex);
687 StackFrameSP frame_sp (GetFrameAtIndex (idx));
690 SetSelectedFrame(frame_sp.get());
698 StackFrameList::SetDefaultFileAndLineToSelectedFrame()
700 if (m_thread.GetID() == m_thread.GetProcess()->GetThreadList().GetSelectedThread()->GetID())
702 StackFrameSP frame_sp (GetFrameAtIndex (GetSelectedFrameIndex()));
705 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextLineEntry);
706 if (sc.line_entry.file)
707 m_thread.CalculateTarget()->GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file,
713 // The thread has been run, reset the number stack frames to zero so we can
714 // determine how many frames we have lazily.
716 StackFrameList::Clear ()
718 Mutex::Locker locker (m_mutex);
720 m_concrete_frames_fetched = 0;
724 StackFrameList::InvalidateFrames (uint32_t start_idx)
726 Mutex::Locker locker (m_mutex);
727 if (m_show_inlined_frames)
733 const size_t num_frames = m_frames.size();
734 while (start_idx < num_frames)
736 m_frames[start_idx].reset();
743 StackFrameList::Merge (std::unique_ptr<StackFrameList>& curr_ap, lldb::StackFrameListSP& prev_sp)
745 Mutex::Locker curr_locker (curr_ap.get() ? &curr_ap->m_mutex : NULL);
746 Mutex::Locker prev_locker (prev_sp.get() ? &prev_sp->m_mutex : NULL);
748 #if defined (DEBUG_STACK_FRAMES)
749 StreamFile s(stdout, false);
750 s.PutCString("\n\nStackFrameList::Merge():\nPrev:\n");
754 s.PutCString ("NULL");
755 s.PutCString("\nCurr:\n");
759 s.PutCString ("NULL");
763 if (curr_ap.get() == NULL || curr_ap->GetNumFrames (false) == 0)
765 #if defined (DEBUG_STACK_FRAMES)
766 s.PutCString("No current frames, leave previous frames alone...\n");
772 if (prev_sp.get() == NULL || prev_sp->GetNumFrames (false) == 0)
774 #if defined (DEBUG_STACK_FRAMES)
775 s.PutCString("No previous frames, so use current frames...\n");
777 // We either don't have any previous frames, or since we have more than
778 // one current frames it means we have all the frames and can safely
779 // replace our previous frames.
780 prev_sp.reset (curr_ap.release());
784 const uint32_t num_curr_frames = curr_ap->GetNumFrames (false);
786 if (num_curr_frames > 1)
788 #if defined (DEBUG_STACK_FRAMES)
789 s.PutCString("We have more than one current frame, so use current frames...\n");
791 // We have more than one current frames it means we have all the frames
792 // and can safely replace our previous frames.
793 prev_sp.reset (curr_ap.release());
795 #if defined (DEBUG_STACK_FRAMES)
796 s.PutCString("\nMerged:\n");
802 StackFrameSP prev_frame_zero_sp(prev_sp->GetFrameAtIndex (0));
803 StackFrameSP curr_frame_zero_sp(curr_ap->GetFrameAtIndex (0));
804 StackID curr_stack_id (curr_frame_zero_sp->GetStackID());
805 StackID prev_stack_id (prev_frame_zero_sp->GetStackID());
807 #if defined (DEBUG_STACK_FRAMES)
808 const uint32_t num_prev_frames = prev_sp->GetNumFrames (false);
809 s.Printf("\n%u previous frames with one current frame\n", num_prev_frames);
812 // We have only a single current frame
813 // Our previous stack frames only had a single frame as well...
814 if (curr_stack_id == prev_stack_id)
816 #if defined (DEBUG_STACK_FRAMES)
817 s.Printf("\nPrevious frame #0 is same as current frame #0, merge the cached data\n");
820 curr_frame_zero_sp->UpdateCurrentFrameFromPreviousFrame (*prev_frame_zero_sp);
821 // prev_frame_zero_sp->UpdatePreviousFrameFromCurrentFrame (*curr_frame_zero_sp);
822 // prev_sp->SetFrameAtIndex (0, prev_frame_zero_sp);
824 else if (curr_stack_id < prev_stack_id)
826 #if defined (DEBUG_STACK_FRAMES)
827 s.Printf("\nCurrent frame #0 has a stack ID that is less than the previous frame #0, insert current frame zero in front of previous\n");
829 prev_sp->m_frames.insert (prev_sp->m_frames.begin(), curr_frame_zero_sp);
834 #if defined (DEBUG_STACK_FRAMES)
835 s.PutCString("\nMerged:\n");
843 StackFrameList::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
846 const_iterator begin = m_frames.begin();
847 const_iterator end = m_frames.end();
848 lldb::StackFrameSP ret_sp;
850 for (pos = begin; pos != end; ++pos)
852 if (pos->get() == stack_frame_ptr)
862 StackFrameList::GetStatus (Stream& strm,
863 uint32_t first_frame,
865 bool show_frame_info,
866 uint32_t num_frames_with_source)
868 size_t num_frames_displayed = 0;
873 StackFrameSP frame_sp;
874 uint32_t frame_idx = 0;
877 // Don't let the last frame wrap around...
878 if (num_frames == UINT32_MAX)
879 last_frame = UINT32_MAX;
881 last_frame = first_frame + num_frames;
883 for (frame_idx = first_frame; frame_idx < last_frame; ++frame_idx)
885 frame_sp = GetFrameAtIndex(frame_idx);
886 if (frame_sp.get() == NULL)
889 if (!frame_sp->GetStatus (strm,
891 num_frames_with_source > (first_frame - frame_idx)))
893 ++num_frames_displayed;
897 return num_frames_displayed;