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 && 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 && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
335 // We've gotten to the end of the stack.
336 SetAllFramesFetched();
339 const bool cfa_is_valid = true;
340 const bool stop_id_is_valid = false;
341 const bool is_history_frame = false;
342 unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid, pc, 0, stop_id_is_valid, is_history_frame, NULL));
343 m_frames.push_back (unwind_frame_sp);
346 SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction);
347 Block *unwind_block = unwind_sc.block;
350 Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
351 // Be sure to adjust the frame address to match the address
352 // that was used to lookup the symbol context above. If we are
353 // in the first concrete frame, then we lookup using the current
354 // address, else we decrement the address by one to get the correct
357 curr_frame_address.Slide(-1);
359 SymbolContext next_frame_sc;
360 Address next_frame_address;
362 while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
364 StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
367 unwind_frame_sp->GetRegisterContextSP (),
372 m_frames.push_back (frame_sp);
373 unwind_sc = next_frame_sc;
374 curr_frame_address = next_frame_address;
377 } while (m_frames.size() - 1 < end_idx);
379 // Don't try to merge till you've calculated all the frames in this stack.
380 if (GetAllFramesFetched() && m_prev_frames_sp)
382 StackFrameList *prev_frames = m_prev_frames_sp.get();
383 StackFrameList *curr_frames = this;
385 //curr_frames->m_current_inlined_depth = prev_frames->m_current_inlined_depth;
386 //curr_frames->m_current_inlined_pc = prev_frames->m_current_inlined_pc;
387 //printf ("GetFramesUpTo: Copying current inlined depth: %d 0x%" PRIx64 ".\n", curr_frames->m_current_inlined_depth, curr_frames->m_current_inlined_pc);
389 #if defined (DEBUG_STACK_FRAMES)
390 s.PutCString("\nprev_frames:\n");
391 prev_frames->Dump (&s);
392 s.PutCString("\ncurr_frames:\n");
393 curr_frames->Dump (&s);
396 size_t curr_frame_num, prev_frame_num;
398 for (curr_frame_num = curr_frames->m_frames.size(), prev_frame_num = prev_frames->m_frames.size();
399 curr_frame_num > 0 && prev_frame_num > 0;
400 --curr_frame_num, --prev_frame_num)
402 const size_t curr_frame_idx = curr_frame_num-1;
403 const size_t prev_frame_idx = prev_frame_num-1;
404 StackFrameSP curr_frame_sp (curr_frames->m_frames[curr_frame_idx]);
405 StackFrameSP prev_frame_sp (prev_frames->m_frames[prev_frame_idx]);
407 #if defined (DEBUG_STACK_FRAMES)
408 s.Printf("\n\nCurr frame #%u ", curr_frame_idx);
410 curr_frame_sp->Dump (&s, true, false);
412 s.PutCString("NULL");
413 s.Printf("\nPrev frame #%u ", prev_frame_idx);
415 prev_frame_sp->Dump (&s, true, false);
417 s.PutCString("NULL");
420 StackFrame *curr_frame = curr_frame_sp.get();
421 StackFrame *prev_frame = prev_frame_sp.get();
423 if (curr_frame == NULL || prev_frame == NULL)
426 // Check the stack ID to make sure they are equal
427 if (curr_frame->GetStackID() != prev_frame->GetStackID())
430 prev_frame->UpdatePreviousFrameFromCurrentFrame (*curr_frame);
431 // Now copy the fixed up previous frame into the current frames
432 // so the pointer doesn't change
433 m_frames[curr_frame_idx] = prev_frame_sp;
434 //curr_frame->UpdateCurrentFrameFromPreviousFrame (*prev_frame);
436 #if defined (DEBUG_STACK_FRAMES)
437 s.Printf("\n Copying previous frame to current frame");
440 // We are done with the old stack frame list, we can release it now
441 m_prev_frames_sp.reset();
444 #if defined (DEBUG_STACK_FRAMES)
445 s.PutCString("\n\nNew frames:\n");
452 if (end_idx < m_concrete_frames_fetched)
457 uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
458 if (num_frames <= end_idx + 1)
461 m_concrete_frames_fetched = UINT32_MAX;
463 m_frames.resize(num_frames);
469 StackFrameList::GetNumFrames (bool can_create)
471 Mutex::Locker locker (m_mutex);
474 GetFramesUpTo (UINT32_MAX);
476 uint32_t inlined_depth = GetCurrentInlinedDepth();
477 if (inlined_depth == UINT32_MAX)
478 return m_frames.size();
480 return m_frames.size() - inlined_depth;
484 StackFrameList::Dump (Stream *s)
488 Mutex::Locker locker (m_mutex);
490 const_iterator pos, begin = m_frames.begin(), end = m_frames.end();
491 for (pos = begin; pos != end; ++pos)
493 StackFrame *frame = (*pos).get();
494 s->Printf("%p: ", frame);
497 frame->GetStackID().Dump (s);
498 frame->DumpUsingSettingsFormat (s);
501 s->Printf("frame #%u", (uint32_t)std::distance (begin, pos));
508 StackFrameList::GetFrameAtIndex (uint32_t idx)
510 StackFrameSP frame_sp;
511 Mutex::Locker locker (m_mutex);
512 uint32_t original_idx = idx;
514 uint32_t inlined_depth = GetCurrentInlinedDepth();
515 if (inlined_depth != UINT32_MAX)
516 idx += inlined_depth;
518 if (idx < m_frames.size())
519 frame_sp = m_frames[idx];
524 // GetFramesUpTo will fill m_frames with as many frames as you asked for,
525 // if there are that many. If there weren't then you asked for too many
528 if (idx < m_frames.size())
530 if (m_show_inlined_frames)
532 // When inline frames are enabled we actually create all the frames in GetFramesUpTo.
533 frame_sp = m_frames[idx];
537 Unwind *unwinder = m_thread.GetUnwinder ();
541 if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
543 const bool cfa_is_valid = true;
544 const bool stop_id_is_valid = false;
545 const bool is_history_frame = false;
546 frame_sp.reset (new StackFrame (m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc, 0, stop_id_is_valid, is_history_frame, NULL));
548 Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function;
551 // When we aren't showing inline functions we always use
552 // the top most function block as the scope.
553 frame_sp->SetSymbolContextScope (&function->GetBlock(false));
557 // Set the symbol scope from the symbol regardless if it is NULL or valid.
558 frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
560 SetFrameAtIndex(idx, frame_sp);
565 else if (original_idx == 0)
567 // There should ALWAYS be a frame at index 0. If something went wrong with the CurrentInlinedDepth such that
568 // there weren't as many frames as we thought taking that into account, then reset the current inlined depth
569 // and return the real zeroth frame.
570 if (m_frames.size() > 0)
572 ResetCurrentInlinedDepth();
573 frame_sp = m_frames[original_idx];
577 // Why do we have a thread with zero frames, that should not ever happen...
578 if (m_thread.IsValid())
579 assert ("A valid thread has no frames.");
588 StackFrameList::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
590 // First try assuming the unwind index is the same as the frame index. The
591 // unwind index is always greater than or equal to the frame index, so it
592 // is a good place to start. If we have inlined frames we might have 5
593 // concrete frames (frame unwind indexes go from 0-4), but we might have 15
594 // frames after we make all the inlined frames. Most of the time the unwind
595 // frame index (or the concrete frame index) is the same as the frame index.
596 uint32_t frame_idx = unwind_idx;
597 StackFrameSP frame_sp (GetFrameAtIndex (frame_idx));
600 if (frame_sp->GetFrameIndex() == unwind_idx)
602 frame_sp = GetFrameAtIndex (++frame_idx);
608 CompareStackID (const StackFrameSP &stack_sp, const StackID &stack_id)
610 return stack_sp->GetStackID() < stack_id;
614 StackFrameList::GetFrameWithStackID (const StackID &stack_id)
616 StackFrameSP frame_sp;
618 if (stack_id.IsValid())
620 Mutex::Locker locker (m_mutex);
621 uint32_t frame_idx = 0;
622 // Do a binary search in case the stack frame is already in our cache
623 collection::const_iterator begin = m_frames.begin();
624 collection::const_iterator end = m_frames.end();
627 collection::const_iterator pos = std::lower_bound (begin, end, stack_id, CompareStackID);
628 if (pos != end && (*pos)->GetStackID() == stack_id)
631 if (m_frames.back()->GetStackID() < stack_id)
632 frame_idx = m_frames.size();
636 frame_sp = GetFrameAtIndex (frame_idx);
637 if (frame_sp && frame_sp->GetStackID() == stack_id)
647 StackFrameList::SetFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
649 if (idx >= m_frames.size())
650 m_frames.resize(idx + 1);
651 // Make sure allocation succeeded by checking bounds again
652 if (idx < m_frames.size())
654 m_frames[idx] = frame_sp;
657 return false; // resize failed, out of memory?
661 StackFrameList::GetSelectedFrameIndex () const
663 Mutex::Locker locker (m_mutex);
664 return m_selected_frame_idx;
669 StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame)
671 Mutex::Locker locker (m_mutex);
673 const_iterator begin = m_frames.begin();
674 const_iterator end = m_frames.end();
675 m_selected_frame_idx = 0;
676 for (pos = begin; pos != end; ++pos)
678 if (pos->get() == frame)
680 m_selected_frame_idx = std::distance (begin, pos);
681 uint32_t inlined_depth = GetCurrentInlinedDepth();
682 if (inlined_depth != UINT32_MAX)
683 m_selected_frame_idx -= inlined_depth;
687 SetDefaultFileAndLineToSelectedFrame();
688 return m_selected_frame_idx;
691 // Mark a stack frame as the current frame using the frame index
693 StackFrameList::SetSelectedFrameByIndex (uint32_t idx)
695 Mutex::Locker locker (m_mutex);
696 StackFrameSP frame_sp (GetFrameAtIndex (idx));
699 SetSelectedFrame(frame_sp.get());
707 StackFrameList::SetDefaultFileAndLineToSelectedFrame()
709 if (m_thread.GetID() == m_thread.GetProcess()->GetThreadList().GetSelectedThread()->GetID())
711 StackFrameSP frame_sp (GetFrameAtIndex (GetSelectedFrameIndex()));
714 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextLineEntry);
715 if (sc.line_entry.file)
716 m_thread.CalculateTarget()->GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file,
722 // The thread has been run, reset the number stack frames to zero so we can
723 // determine how many frames we have lazily.
725 StackFrameList::Clear ()
727 Mutex::Locker locker (m_mutex);
729 m_concrete_frames_fetched = 0;
733 StackFrameList::InvalidateFrames (uint32_t start_idx)
735 Mutex::Locker locker (m_mutex);
736 if (m_show_inlined_frames)
742 const size_t num_frames = m_frames.size();
743 while (start_idx < num_frames)
745 m_frames[start_idx].reset();
752 StackFrameList::Merge (std::unique_ptr<StackFrameList>& curr_ap, lldb::StackFrameListSP& prev_sp)
754 Mutex::Locker curr_locker (curr_ap.get() ? &curr_ap->m_mutex : NULL);
755 Mutex::Locker prev_locker (prev_sp.get() ? &prev_sp->m_mutex : NULL);
757 #if defined (DEBUG_STACK_FRAMES)
758 StreamFile s(stdout, false);
759 s.PutCString("\n\nStackFrameList::Merge():\nPrev:\n");
763 s.PutCString ("NULL");
764 s.PutCString("\nCurr:\n");
768 s.PutCString ("NULL");
772 if (curr_ap.get() == NULL || curr_ap->GetNumFrames (false) == 0)
774 #if defined (DEBUG_STACK_FRAMES)
775 s.PutCString("No current frames, leave previous frames alone...\n");
781 if (prev_sp.get() == NULL || prev_sp->GetNumFrames (false) == 0)
783 #if defined (DEBUG_STACK_FRAMES)
784 s.PutCString("No previous frames, so use current frames...\n");
786 // We either don't have any previous frames, or since we have more than
787 // one current frames it means we have all the frames and can safely
788 // replace our previous frames.
789 prev_sp.reset (curr_ap.release());
793 const uint32_t num_curr_frames = curr_ap->GetNumFrames (false);
795 if (num_curr_frames > 1)
797 #if defined (DEBUG_STACK_FRAMES)
798 s.PutCString("We have more than one current frame, so use current frames...\n");
800 // We have more than one current frames it means we have all the frames
801 // and can safely replace our previous frames.
802 prev_sp.reset (curr_ap.release());
804 #if defined (DEBUG_STACK_FRAMES)
805 s.PutCString("\nMerged:\n");
811 StackFrameSP prev_frame_zero_sp(prev_sp->GetFrameAtIndex (0));
812 StackFrameSP curr_frame_zero_sp(curr_ap->GetFrameAtIndex (0));
813 StackID curr_stack_id (curr_frame_zero_sp->GetStackID());
814 StackID prev_stack_id (prev_frame_zero_sp->GetStackID());
816 #if defined (DEBUG_STACK_FRAMES)
817 const uint32_t num_prev_frames = prev_sp->GetNumFrames (false);
818 s.Printf("\n%u previous frames with one current frame\n", num_prev_frames);
821 // We have only a single current frame
822 // Our previous stack frames only had a single frame as well...
823 if (curr_stack_id == prev_stack_id)
825 #if defined (DEBUG_STACK_FRAMES)
826 s.Printf("\nPrevious frame #0 is same as current frame #0, merge the cached data\n");
829 curr_frame_zero_sp->UpdateCurrentFrameFromPreviousFrame (*prev_frame_zero_sp);
830 // prev_frame_zero_sp->UpdatePreviousFrameFromCurrentFrame (*curr_frame_zero_sp);
831 // prev_sp->SetFrameAtIndex (0, prev_frame_zero_sp);
833 else if (curr_stack_id < prev_stack_id)
835 #if defined (DEBUG_STACK_FRAMES)
836 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");
838 prev_sp->m_frames.insert (prev_sp->m_frames.begin(), curr_frame_zero_sp);
843 #if defined (DEBUG_STACK_FRAMES)
844 s.PutCString("\nMerged:\n");
852 StackFrameList::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
855 const_iterator begin = m_frames.begin();
856 const_iterator end = m_frames.end();
857 lldb::StackFrameSP ret_sp;
859 for (pos = begin; pos != end; ++pos)
861 if (pos->get() == stack_frame_ptr)
871 StackFrameList::GetStatus (Stream& strm,
872 uint32_t first_frame,
874 bool show_frame_info,
875 uint32_t num_frames_with_source,
876 const char *selected_frame_marker)
878 size_t num_frames_displayed = 0;
883 StackFrameSP frame_sp;
884 uint32_t frame_idx = 0;
887 // Don't let the last frame wrap around...
888 if (num_frames == UINT32_MAX)
889 last_frame = UINT32_MAX;
891 last_frame = first_frame + num_frames;
893 StackFrameSP selected_frame_sp = m_thread.GetSelectedFrame();
894 const char *unselected_marker = NULL;
896 if (selected_frame_marker)
898 size_t len = strlen(selected_frame_marker);
899 buffer.insert(buffer.begin(), len, ' ');
900 unselected_marker = buffer.c_str();
902 const char *marker = NULL;
904 for (frame_idx = first_frame; frame_idx < last_frame; ++frame_idx)
906 frame_sp = GetFrameAtIndex(frame_idx);
907 if (frame_sp.get() == NULL)
910 if (selected_frame_marker != NULL)
912 if (frame_sp == selected_frame_sp)
913 marker = selected_frame_marker;
915 marker = unselected_marker;
918 if (!frame_sp->GetStatus (strm,
920 num_frames_with_source > (first_frame - frame_idx), marker))
922 ++num_frames_displayed;
926 return num_frames_displayed;