blob: b93e80806deb39f72cb1a226ae655fb5297e5dcb [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- StackFrameList.cpp --------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Greg Clayton12daf9462010-08-25 00:35:26 +000010#include "lldb/Target/StackFrameList.h"
11
Chris Lattner30fdc8d2010-06-08 16:52:24 +000012// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
Jim Inghamc6355002012-09-08 00:26:49 +000016#include "lldb/Breakpoint/BreakpointLocation.h"
17#include "lldb/Breakpoint/Breakpoint.h"
Jim Ingham6cd41da2012-09-07 23:35:54 +000018#include "lldb/Core/Log.h"
Greg Clayton5082c5f2010-08-27 18:24:16 +000019#include "lldb/Core/StreamFile.h"
Jim Inghamb7f6b2f2011-09-08 22:13:49 +000020#include "lldb/Core/SourceManager.h"
Greg Clayton12daf9462010-08-25 00:35:26 +000021#include "lldb/Symbol/Block.h"
22#include "lldb/Symbol/Function.h"
Greg Clayton59e8fc1c2010-08-30 18:11:35 +000023#include "lldb/Symbol/Symbol.h"
Jim Inghamb7f6b2f2011-09-08 22:13:49 +000024#include "lldb/Target/Process.h"
Greg Clayton12daf9462010-08-25 00:35:26 +000025#include "lldb/Target/RegisterContext.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Target/StackFrame.h"
Jim Ingham513c6bb2012-09-01 01:02:41 +000027#include "lldb/Target/StopInfo.h"
Jim Inghamb7f6b2f2011-09-08 22:13:49 +000028#include "lldb/Target/Target.h"
Greg Clayton12daf9462010-08-25 00:35:26 +000029#include "lldb/Target/Thread.h"
30#include "lldb/Target/Unwind.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031
Greg Clayton5082c5f2010-08-27 18:24:16 +000032//#define DEBUG_STACK_FRAMES 1
33
Chris Lattner30fdc8d2010-06-08 16:52:24 +000034using namespace lldb;
35using namespace lldb_private;
36
37//----------------------------------------------------------------------
38// StackFrameList constructor
39//----------------------------------------------------------------------
Greg Clayton2cad65a2010-09-03 17:10:42 +000040StackFrameList::StackFrameList
41(
42 Thread &thread,
43 const lldb::StackFrameListSP &prev_frames_sp,
44 bool show_inline_frames
45) :
Greg Clayton12daf9462010-08-25 00:35:26 +000046 m_thread (thread),
Greg Clayton2cad65a2010-09-03 17:10:42 +000047 m_prev_frames_sp (prev_frames_sp),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000048 m_mutex (Mutex::eMutexTypeRecursive),
Greg Clayton5082c5f2010-08-27 18:24:16 +000049 m_frames (),
Stephen Wilson71c21d12011-04-11 19:41:40 +000050 m_selected_frame_idx (0),
Jim Inghamb0c72a52012-02-29 03:40:22 +000051 m_concrete_frames_fetched (0),
Jim Ingham513c6bb2012-09-01 01:02:41 +000052 m_current_inlined_depth (UINT32_MAX),
53 m_current_inlined_pc (LLDB_INVALID_ADDRESS),
Stephen Wilson71c21d12011-04-11 19:41:40 +000054 m_show_inlined_frames (show_inline_frames)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000055{
Jim Ingham513c6bb2012-09-01 01:02:41 +000056 if (prev_frames_sp)
57 {
58 m_current_inlined_depth = prev_frames_sp->m_current_inlined_depth;
59 m_current_inlined_pc = prev_frames_sp->m_current_inlined_pc;
60 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000061}
62
63//----------------------------------------------------------------------
64// Destructor
65//----------------------------------------------------------------------
66StackFrameList::~StackFrameList()
67{
Greg Claytonca5ce182013-03-28 18:41:44 +000068 // 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
70 Clear();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000071}
72
Jim Inghamb0c72a52012-02-29 03:40:22 +000073void
Jim Ingham513c6bb2012-09-01 01:02:41 +000074StackFrameList::CalculateCurrentInlinedDepth()
75{
76 uint32_t cur_inlined_depth = GetCurrentInlinedDepth();
77 if (cur_inlined_depth == UINT32_MAX)
78 {
79 ResetCurrentInlinedDepth();
80 }
81}
82
83uint32_t
84StackFrameList::GetCurrentInlinedDepth ()
85{
Jim Ingham6cd41da2012-09-07 23:35:54 +000086 if (m_show_inlined_frames && m_current_inlined_pc != LLDB_INVALID_ADDRESS)
Jim Ingham513c6bb2012-09-01 01:02:41 +000087 {
88 lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
89 if (cur_pc != m_current_inlined_pc)
90 {
91 m_current_inlined_pc = LLDB_INVALID_ADDRESS;
92 m_current_inlined_depth = UINT32_MAX;
Greg Clayton5160ce52013-03-27 23:08:40 +000093 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham6cd41da2012-09-07 23:35:54 +000094 if (log && log->GetVerbose())
95 log->Printf ("GetCurrentInlinedDepth: invalidating current inlined depth.\n");
Jim Ingham513c6bb2012-09-01 01:02:41 +000096 }
97 return m_current_inlined_depth;
98 }
99 else
100 {
101 return UINT32_MAX;
102 }
103}
104
Jim Ingham513c6bb2012-09-01 01:02:41 +0000105void
106StackFrameList::ResetCurrentInlinedDepth ()
107{
Jim Inghame7e6ffc2012-09-05 21:14:28 +0000108 if (m_show_inlined_frames)
Jim Ingham513c6bb2012-09-01 01:02:41 +0000109 {
110 GetFramesUpTo(0);
111 if (!m_frames[0]->IsInlined())
112 {
113 m_current_inlined_depth = UINT32_MAX;
114 m_current_inlined_pc = LLDB_INVALID_ADDRESS;
Greg Clayton5160ce52013-03-27 23:08:40 +0000115 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham6cd41da2012-09-07 23:35:54 +0000116 if (log && log->GetVerbose())
117 log->Printf ("ResetCurrentInlinedDepth: Invalidating current inlined depth.\n");
Jim Ingham513c6bb2012-09-01 01:02:41 +0000118 }
119 else
120 {
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.
126
127 lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC();
128 Block *block_ptr = m_frames[0]->GetFrameBlock();
129 if (block_ptr)
130 {
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))
135 {
136 if (pc_as_address == containing_range.GetBaseAddress())
137 {
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();
147 if (stop_info_sp)
148 {
149 switch (stop_info_sp->GetStopReason())
150 {
Jim Ingham513c6bb2012-09-01 01:02:41 +0000151 case eStopReasonWatchpoint:
152 case eStopReasonException:
Greg Clayton90ba8112012-12-05 00:16:59 +0000153 case eStopReasonExec:
Jim Ingham513c6bb2012-09-01 01:02:41 +0000154 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;
158 break;
Jim Ingham7da851a2012-09-07 01:11:08 +0000159 case eStopReasonBreakpoint:
160 {
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.
Jim Inghamc6355002012-09-08 00:26:49 +0000164 // 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;
171 if (bp_site_sp)
172 {
173 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
174 for (uint32_t i = 0; i < num_owners; i++)
175 {
176 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
177 if (!bp_ref.IsInternal())
178 {
179 all_internal = false;
180 }
181 }
182 }
183 if (!all_internal)
184 {
185 m_current_inlined_pc = curr_pc;
186 m_current_inlined_depth = 0;
187 break;
188 }
Jim Ingham7da851a2012-09-07 01:11:08 +0000189 }
Jim Ingham513c6bb2012-09-01 01:02:41 +0000190 default:
191 {
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;
196
197 for (Block *container_ptr = block_ptr->GetInlinedParent();
198 container_ptr != NULL;
199 container_ptr = container_ptr->GetInlinedParent())
200 {
201 if (!container_ptr->GetRangeContainingAddress(pc_as_address, containing_range))
202 break;
203 if (pc_as_address != containing_range.GetBaseAddress())
204 break;
205
206 num_inlined_functions++;
207 }
208 m_current_inlined_pc = curr_pc;
209 m_current_inlined_depth = num_inlined_functions + 1;
Greg Clayton5160ce52013-03-27 23:08:40 +0000210 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham6cd41da2012-09-07 23:35:54 +0000211 if (log && log->GetVerbose())
Daniel Malead01b2952012-11-29 21:49:15 +0000212 log->Printf ("ResetCurrentInlinedDepth: setting inlined depth: %d 0x%" PRIx64 ".\n", m_current_inlined_depth, curr_pc);
Jim Ingham513c6bb2012-09-01 01:02:41 +0000213
214 }
215 break;
216 }
217 }
218 }
219 }
220 }
221 }
222 }
223}
224
225bool
226StackFrameList::DecrementCurrentInlinedDepth ()
227{
228 if (m_show_inlined_frames)
229 {
230 uint32_t current_inlined_depth = GetCurrentInlinedDepth();
231 if (current_inlined_depth != UINT32_MAX)
232 {
233 if (current_inlined_depth > 0)
Jim Ingham9786eee2012-09-06 19:24:57 +0000234 {
Jim Ingham513c6bb2012-09-01 01:02:41 +0000235 m_current_inlined_depth--;
Jim Ingham9786eee2012-09-06 19:24:57 +0000236 return true;
237 }
Jim Ingham513c6bb2012-09-01 01:02:41 +0000238 }
239 }
240 return false;
241}
242
243void
Jim Ingham6cd41da2012-09-07 23:35:54 +0000244StackFrameList::SetCurrentInlinedDepth (uint32_t new_depth)
245{
246 m_current_inlined_depth = new_depth;
247 if (new_depth == UINT32_MAX)
248 m_current_inlined_pc = LLDB_INVALID_ADDRESS;
249 else
250 m_current_inlined_pc = m_thread.GetRegisterContext()->GetPC();
251}
252
253void
Jim Inghamb0c72a52012-02-29 03:40:22 +0000254StackFrameList::GetFramesUpTo(uint32_t end_idx)
255{
Enrico Granataebafd2f2013-03-15 17:25:04 +0000256 // this makes sure we do not fetch frames for an invalid thread
257 if (m_thread.IsValid() == false)
258 return;
259
Jim Inghamb0c72a52012-02-29 03:40:22 +0000260 // We've already gotten more frames than asked for, or we've already finished unwinding, return.
261 if (m_frames.size() > end_idx || GetAllFramesFetched())
262 return;
263
264 Unwind *unwinder = m_thread.GetUnwinder ();
265
266 if (m_show_inlined_frames)
267 {
268#if defined (DEBUG_STACK_FRAMES)
269 StreamFile s(stdout, false);
270#endif
Jim Ingham513c6bb2012-09-01 01:02:41 +0000271 // If we are hiding some frames from the outside world, we need to add those onto the total count of
Bruce Mitcheneraaa0ba32014-07-08 18:05:41 +0000272 // frames to fetch. However, we don't need to do that if end_idx is 0 since in that case we always
Jim Ingham6cd41da2012-09-07 23:35:54 +0000273 // 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...
Jim Ingham513c6bb2012-09-01 01:02:41 +0000275
276 uint32_t inlined_depth = 0;
Jim Ingham6cd41da2012-09-07 23:35:54 +0000277 if (end_idx > 0 && end_idx != UINT32_MAX)
Jim Ingham513c6bb2012-09-01 01:02:41 +0000278 {
279 inlined_depth = GetCurrentInlinedDepth();
280 if (inlined_depth != UINT32_MAX)
281 {
282 if (end_idx > 0)
283 end_idx += inlined_depth;
284 }
Jim Ingham513c6bb2012-09-01 01:02:41 +0000285 }
Jim Inghamb0c72a52012-02-29 03:40:22 +0000286
Jason Molendab57e4a12013-11-04 09:33:30 +0000287 StackFrameSP unwind_frame_sp;
Jim Inghamb0c72a52012-02-29 03:40:22 +0000288 do
289 {
290 uint32_t idx = m_concrete_frames_fetched++;
Greg Clayton8012cad2014-11-17 19:39:20 +0000291 lldb::addr_t pc = LLDB_INVALID_ADDRESS;
292 lldb::addr_t cfa = LLDB_INVALID_ADDRESS;
Jim Inghamb0c72a52012-02-29 03:40:22 +0000293 if (idx == 0)
294 {
295 // We might have already created frame zero, only create it
296 // if we need to
297 if (m_frames.empty())
298 {
Greg Claytonb3ae8762013-04-12 20:07:46 +0000299 RegisterContextSP reg_ctx_sp (m_thread.GetRegisterContext());
Jim Ingham376c4852012-03-01 02:53:40 +0000300
Greg Claytonb3ae8762013-04-12 20:07:46 +0000301 if (reg_ctx_sp)
302 {
303
Greg Claytonec6829e2013-11-22 21:03:42 +0000304 const bool success = unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
Greg Claytonb3ae8762013-04-12 20:07:46 +0000305 // 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.
308 if (!success)
309 {
310 cfa = reg_ctx_sp->GetSP();
311 pc = reg_ctx_sp->GetPC();
312 }
313
314 unwind_frame_sp.reset (new StackFrame (m_thread.shared_from_this(),
315 m_frames.size(),
316 idx,
317 reg_ctx_sp,
318 cfa,
319 pc,
320 NULL));
321 m_frames.push_back (unwind_frame_sp);
322 }
Jim Inghamb0c72a52012-02-29 03:40:22 +0000323 }
324 else
325 {
326 unwind_frame_sp = m_frames.front();
Jason Molendab57e4a12013-11-04 09:33:30 +0000327 cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
Jim Inghamb0c72a52012-02-29 03:40:22 +0000328 }
329 }
330 else
331 {
Greg Claytonec6829e2013-11-22 21:03:42 +0000332 const bool success = unwinder && unwinder->GetFrameInfoAtIndex(idx, cfa, pc);
Jim Inghamb0c72a52012-02-29 03:40:22 +0000333 if (!success)
334 {
335 // We've gotten to the end of the stack.
336 SetAllFramesFetched();
337 break;
338 }
Jason Molenda99618472013-11-04 11:02:52 +0000339 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));
Jim Inghamb0c72a52012-02-29 03:40:22 +0000343 m_frames.push_back (unwind_frame_sp);
344 }
345
Ed Masteff1b5c42015-02-23 18:12:20 +0000346 assert(unwind_frame_sp);
Jim Inghamb0c72a52012-02-29 03:40:22 +0000347 SymbolContext unwind_sc = unwind_frame_sp->GetSymbolContext (eSymbolContextBlock | eSymbolContextFunction);
348 Block *unwind_block = unwind_sc.block;
349 if (unwind_block)
350 {
351 Address curr_frame_address (unwind_frame_sp->GetFrameCodeAddress());
352 // Be sure to adjust the frame address to match the address
353 // that was used to lookup the symbol context above. If we are
354 // in the first concrete frame, then we lookup using the current
355 // address, else we decrement the address by one to get the correct
356 // location.
357 if (idx > 0)
Tamas Berghammer0f8452b2015-06-01 10:38:23 +0000358 {
359 if (curr_frame_address.GetOffset() == 0)
360 {
361 // If curr_frame_address points to the first address in a section then after
362 // adjustment it will point to an other section. In that case resolve the
363 // address again to the correct section plus offset form.
364 TargetSP target = m_thread.CalculateTarget();
Tamas Berghammer25b9f7e2015-09-07 09:58:09 +0000365 addr_t load_addr = curr_frame_address.GetOpcodeLoadAddress(target.get(), eAddressClassCode);
366 curr_frame_address.SetOpcodeLoadAddress(load_addr - 1, target.get(), eAddressClassCode);
Tamas Berghammer0f8452b2015-06-01 10:38:23 +0000367 }
368 else
369 {
370 curr_frame_address.Slide(-1);
371 }
372 }
Jim Inghamb0c72a52012-02-29 03:40:22 +0000373
374 SymbolContext next_frame_sc;
375 Address next_frame_address;
376
377 while (unwind_sc.GetParentOfInlinedScope(curr_frame_address, next_frame_sc, next_frame_address))
378 {
Jason Molendab57e4a12013-11-04 09:33:30 +0000379 StackFrameSP frame_sp(new StackFrame (m_thread.shared_from_this(),
Jim Inghamb0c72a52012-02-29 03:40:22 +0000380 m_frames.size(),
381 idx,
382 unwind_frame_sp->GetRegisterContextSP (),
383 cfa,
384 next_frame_address,
385 &next_frame_sc));
386
387 m_frames.push_back (frame_sp);
388 unwind_sc = next_frame_sc;
389 curr_frame_address = next_frame_address;
390 }
391 }
392 } while (m_frames.size() - 1 < end_idx);
393
394 // Don't try to merge till you've calculated all the frames in this stack.
395 if (GetAllFramesFetched() && m_prev_frames_sp)
396 {
397 StackFrameList *prev_frames = m_prev_frames_sp.get();
398 StackFrameList *curr_frames = this;
Jim Ingham9786eee2012-09-06 19:24:57 +0000399
Jim Ingham6cd41da2012-09-07 23:35:54 +0000400 //curr_frames->m_current_inlined_depth = prev_frames->m_current_inlined_depth;
401 //curr_frames->m_current_inlined_pc = prev_frames->m_current_inlined_pc;
Daniel Malead01b2952012-11-29 21:49:15 +0000402 //printf ("GetFramesUpTo: Copying current inlined depth: %d 0x%" PRIx64 ".\n", curr_frames->m_current_inlined_depth, curr_frames->m_current_inlined_pc);
Jim Inghamb0c72a52012-02-29 03:40:22 +0000403
404#if defined (DEBUG_STACK_FRAMES)
405 s.PutCString("\nprev_frames:\n");
406 prev_frames->Dump (&s);
407 s.PutCString("\ncurr_frames:\n");
408 curr_frames->Dump (&s);
409 s.EOL();
410#endif
411 size_t curr_frame_num, prev_frame_num;
412
413 for (curr_frame_num = curr_frames->m_frames.size(), prev_frame_num = prev_frames->m_frames.size();
414 curr_frame_num > 0 && prev_frame_num > 0;
415 --curr_frame_num, --prev_frame_num)
416 {
417 const size_t curr_frame_idx = curr_frame_num-1;
418 const size_t prev_frame_idx = prev_frame_num-1;
Jason Molendab57e4a12013-11-04 09:33:30 +0000419 StackFrameSP curr_frame_sp (curr_frames->m_frames[curr_frame_idx]);
420 StackFrameSP prev_frame_sp (prev_frames->m_frames[prev_frame_idx]);
Jim Inghamb0c72a52012-02-29 03:40:22 +0000421
422#if defined (DEBUG_STACK_FRAMES)
423 s.Printf("\n\nCurr frame #%u ", curr_frame_idx);
424 if (curr_frame_sp)
425 curr_frame_sp->Dump (&s, true, false);
426 else
427 s.PutCString("NULL");
428 s.Printf("\nPrev frame #%u ", prev_frame_idx);
429 if (prev_frame_sp)
430 prev_frame_sp->Dump (&s, true, false);
431 else
432 s.PutCString("NULL");
433#endif
434
Jason Molendab57e4a12013-11-04 09:33:30 +0000435 StackFrame *curr_frame = curr_frame_sp.get();
436 StackFrame *prev_frame = prev_frame_sp.get();
Jim Inghamb0c72a52012-02-29 03:40:22 +0000437
438 if (curr_frame == NULL || prev_frame == NULL)
439 break;
440
441 // Check the stack ID to make sure they are equal
442 if (curr_frame->GetStackID() != prev_frame->GetStackID())
443 break;
444
445 prev_frame->UpdatePreviousFrameFromCurrentFrame (*curr_frame);
446 // Now copy the fixed up previous frame into the current frames
447 // so the pointer doesn't change
448 m_frames[curr_frame_idx] = prev_frame_sp;
449 //curr_frame->UpdateCurrentFrameFromPreviousFrame (*prev_frame);
450
451#if defined (DEBUG_STACK_FRAMES)
452 s.Printf("\n Copying previous frame to current frame");
453#endif
454 }
455 // We are done with the old stack frame list, we can release it now
456 m_prev_frames_sp.reset();
457 }
458
459#if defined (DEBUG_STACK_FRAMES)
460 s.PutCString("\n\nNew frames:\n");
461 Dump (&s);
462 s.EOL();
463#endif
464 }
465 else
466 {
467 if (end_idx < m_concrete_frames_fetched)
468 return;
Greg Claytonec6829e2013-11-22 21:03:42 +0000469
470 if (unwinder)
Jim Inghamb0c72a52012-02-29 03:40:22 +0000471 {
Greg Claytonec6829e2013-11-22 21:03:42 +0000472 uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
473 if (num_frames <= end_idx + 1)
474 {
475 //Done unwinding.
476 m_concrete_frames_fetched = UINT32_MAX;
477 }
478 m_frames.resize(num_frames);
Jim Inghamb0c72a52012-02-29 03:40:22 +0000479 }
Jim Inghamb0c72a52012-02-29 03:40:22 +0000480 }
481}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000482
483uint32_t
Greg Clayton2cad65a2010-09-03 17:10:42 +0000484StackFrameList::GetNumFrames (bool can_create)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000485{
486 Mutex::Locker locker (m_mutex);
Greg Clayton12daf9462010-08-25 00:35:26 +0000487
Jim Inghamb0c72a52012-02-29 03:40:22 +0000488 if (can_create)
489 GetFramesUpTo (UINT32_MAX);
Jim Ingham513c6bb2012-09-01 01:02:41 +0000490
491 uint32_t inlined_depth = GetCurrentInlinedDepth();
492 if (inlined_depth == UINT32_MAX)
493 return m_frames.size();
494 else
495 return m_frames.size() - inlined_depth;
Greg Clayton5082c5f2010-08-27 18:24:16 +0000496}
497
498void
499StackFrameList::Dump (Stream *s)
500{
501 if (s == NULL)
502 return;
503 Mutex::Locker locker (m_mutex);
504
505 const_iterator pos, begin = m_frames.begin(), end = m_frames.end();
506 for (pos = begin; pos != end; ++pos)
Greg Clayton12daf9462010-08-25 00:35:26 +0000507 {
Jason Molendab57e4a12013-11-04 09:33:30 +0000508 StackFrame *frame = (*pos).get();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000509 s->Printf("%p: ", static_cast<void*>(frame));
Greg Clayton5082c5f2010-08-27 18:24:16 +0000510 if (frame)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000511 {
512 frame->GetStackID().Dump (s);
Greg Clayton0603aa92010-10-04 01:05:56 +0000513 frame->DumpUsingSettingsFormat (s);
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000514 }
Greg Clayton5082c5f2010-08-27 18:24:16 +0000515 else
Greg Claytondce502e2011-11-04 03:34:56 +0000516 s->Printf("frame #%u", (uint32_t)std::distance (begin, pos));
Greg Clayton5082c5f2010-08-27 18:24:16 +0000517 s->EOL();
Greg Clayton12daf9462010-08-25 00:35:26 +0000518 }
Greg Clayton5082c5f2010-08-27 18:24:16 +0000519 s->EOL();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000520}
521
Jason Molendab57e4a12013-11-04 09:33:30 +0000522StackFrameSP
Greg Clayton12daf9462010-08-25 00:35:26 +0000523StackFrameList::GetFrameAtIndex (uint32_t idx)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000524{
Jason Molendab57e4a12013-11-04 09:33:30 +0000525 StackFrameSP frame_sp;
Greg Clayton5082c5f2010-08-27 18:24:16 +0000526 Mutex::Locker locker (m_mutex);
Jim Ingham5cb9a182013-03-28 00:13:30 +0000527 uint32_t original_idx = idx;
528
Jim Ingham513c6bb2012-09-01 01:02:41 +0000529 uint32_t inlined_depth = GetCurrentInlinedDepth();
530 if (inlined_depth != UINT32_MAX)
531 idx += inlined_depth;
532
Greg Clayton5082c5f2010-08-27 18:24:16 +0000533 if (idx < m_frames.size())
534 frame_sp = m_frames[idx];
535
536 if (frame_sp)
537 return frame_sp;
Greg Clayton0445d8f2010-08-26 02:28:22 +0000538
Jim Ingham5cb9a182013-03-28 00:13:30 +0000539 // GetFramesUpTo will fill m_frames with as many frames as you asked for,
540 // if there are that many. If there weren't then you asked for too many
541 // frames.
542 GetFramesUpTo (idx);
543 if (idx < m_frames.size())
544 {
545 if (m_show_inlined_frames)
Greg Clayton5082c5f2010-08-27 18:24:16 +0000546 {
Jim Ingham5cb9a182013-03-28 00:13:30 +0000547 // When inline frames are enabled we actually create all the frames in GetFramesUpTo.
548 frame_sp = m_frames[idx];
549 }
550 else
551 {
552 Unwind *unwinder = m_thread.GetUnwinder ();
553 if (unwinder)
Greg Clayton5082c5f2010-08-27 18:24:16 +0000554 {
Jim Ingham5cb9a182013-03-28 00:13:30 +0000555 addr_t pc, cfa;
556 if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc))
Greg Clayton5082c5f2010-08-27 18:24:16 +0000557 {
Jason Molenda99618472013-11-04 11:02:52 +0000558 const bool cfa_is_valid = true;
559 const bool stop_id_is_valid = false;
560 const bool is_history_frame = false;
561 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));
Jim Ingham5cb9a182013-03-28 00:13:30 +0000562
563 Function *function = frame_sp->GetSymbolContext (eSymbolContextFunction).function;
564 if (function)
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000565 {
Jim Ingham5cb9a182013-03-28 00:13:30 +0000566 // When we aren't showing inline functions we always use
567 // the top most function block as the scope.
568 frame_sp->SetSymbolContextScope (&function->GetBlock(false));
Greg Clayton59e8fc1c2010-08-30 18:11:35 +0000569 }
Jim Ingham5cb9a182013-03-28 00:13:30 +0000570 else
571 {
572 // Set the symbol scope from the symbol regardless if it is NULL or valid.
573 frame_sp->SetSymbolContextScope (frame_sp->GetSymbolContext (eSymbolContextSymbol).symbol);
574 }
575 SetFrameAtIndex(idx, frame_sp);
Greg Clayton5082c5f2010-08-27 18:24:16 +0000576 }
577 }
Greg Clayton12daf9462010-08-25 00:35:26 +0000578 }
Jim Ingham5cb9a182013-03-28 00:13:30 +0000579 }
580 else if (original_idx == 0)
581 {
582 // There should ALWAYS be a frame at index 0. If something went wrong with the CurrentInlinedDepth such that
583 // there weren't as many frames as we thought taking that into account, then reset the current inlined depth
584 // and return the real zeroth frame.
585 if (m_frames.size() > 0)
586 {
587 ResetCurrentInlinedDepth();
588 frame_sp = m_frames[original_idx];
589 }
590 else
591 {
592 // Why do we have a thread with zero frames, that should not ever happen...
593 if (m_thread.IsValid())
594 assert ("A valid thread has no frames.");
595
596 }
597 }
598
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000599 return frame_sp;
600}
601
Jason Molendab57e4a12013-11-04 09:33:30 +0000602StackFrameSP
Greg Clayton5ccbd292011-01-06 22:15:06 +0000603StackFrameList::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
604{
605 // First try assuming the unwind index is the same as the frame index. The
606 // unwind index is always greater than or equal to the frame index, so it
607 // is a good place to start. If we have inlined frames we might have 5
608 // concrete frames (frame unwind indexes go from 0-4), but we might have 15
609 // frames after we make all the inlined frames. Most of the time the unwind
610 // frame index (or the concrete frame index) is the same as the frame index.
611 uint32_t frame_idx = unwind_idx;
Jason Molendab57e4a12013-11-04 09:33:30 +0000612 StackFrameSP frame_sp (GetFrameAtIndex (frame_idx));
Greg Clayton5ccbd292011-01-06 22:15:06 +0000613 while (frame_sp)
614 {
615 if (frame_sp->GetFrameIndex() == unwind_idx)
616 break;
617 frame_sp = GetFrameAtIndex (++frame_idx);
618 }
619 return frame_sp;
620}
621
Greg Clayton7bcb93d2013-05-24 00:58:29 +0000622static bool
Jason Molendab57e4a12013-11-04 09:33:30 +0000623CompareStackID (const StackFrameSP &stack_sp, const StackID &stack_id)
Greg Clayton7bcb93d2013-05-24 00:58:29 +0000624{
625 return stack_sp->GetStackID() < stack_id;
626}
627
Jason Molendab57e4a12013-11-04 09:33:30 +0000628StackFrameSP
Greg Claytoncc4d0142012-02-17 07:49:44 +0000629StackFrameList::GetFrameWithStackID (const StackID &stack_id)
Jim Ingham3a195b72011-03-31 00:15:49 +0000630{
Jason Molendab57e4a12013-11-04 09:33:30 +0000631 StackFrameSP frame_sp;
Greg Clayton7bcb93d2013-05-24 00:58:29 +0000632
633 if (stack_id.IsValid())
Jim Ingham3a195b72011-03-31 00:15:49 +0000634 {
Greg Clayton7bcb93d2013-05-24 00:58:29 +0000635 Mutex::Locker locker (m_mutex);
636 uint32_t frame_idx = 0;
637 // Do a binary search in case the stack frame is already in our cache
638 collection::const_iterator begin = m_frames.begin();
639 collection::const_iterator end = m_frames.end();
640 if (begin != end)
641 {
642 collection::const_iterator pos = std::lower_bound (begin, end, stack_id, CompareStackID);
Greg Clayton8012cad2014-11-17 19:39:20 +0000643 if (pos != end)
644 {
645 if ((*pos)->GetStackID() == stack_id)
646 return *pos;
647 }
Greg Clayton7bcb93d2013-05-24 00:58:29 +0000648
Greg Clayton8012cad2014-11-17 19:39:20 +0000649// if (m_frames.back()->GetStackID() < stack_id)
650// frame_idx = m_frames.size();
Greg Clayton7bcb93d2013-05-24 00:58:29 +0000651 }
652 do
653 {
654 frame_sp = GetFrameAtIndex (frame_idx);
655 if (frame_sp && frame_sp->GetStackID() == stack_id)
656 break;
657 frame_idx++;
658 }
659 while (frame_sp);
Jim Ingham3a195b72011-03-31 00:15:49 +0000660 }
Jim Ingham3a195b72011-03-31 00:15:49 +0000661 return frame_sp;
662}
Greg Clayton5ccbd292011-01-06 22:15:06 +0000663
Greg Clayton12daf9462010-08-25 00:35:26 +0000664bool
Jason Molendab57e4a12013-11-04 09:33:30 +0000665StackFrameList::SetFrameAtIndex (uint32_t idx, StackFrameSP &frame_sp)
Greg Clayton12daf9462010-08-25 00:35:26 +0000666{
Greg Clayton5082c5f2010-08-27 18:24:16 +0000667 if (idx >= m_frames.size())
668 m_frames.resize(idx + 1);
Greg Clayton12daf9462010-08-25 00:35:26 +0000669 // Make sure allocation succeeded by checking bounds again
Greg Clayton5082c5f2010-08-27 18:24:16 +0000670 if (idx < m_frames.size())
Greg Clayton12daf9462010-08-25 00:35:26 +0000671 {
Greg Clayton5082c5f2010-08-27 18:24:16 +0000672 m_frames[idx] = frame_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000673 return true;
674 }
675 return false; // resize failed, out of memory?
676}
677
678uint32_t
Jim Ingham2976d002010-08-26 21:32:51 +0000679StackFrameList::GetSelectedFrameIndex () const
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000680{
681 Mutex::Locker locker (m_mutex);
Jim Ingham2976d002010-08-26 21:32:51 +0000682 return m_selected_frame_idx;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000683}
684
685
686uint32_t
Jason Molendab57e4a12013-11-04 09:33:30 +0000687StackFrameList::SetSelectedFrame (lldb_private::StackFrame *frame)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000688{
689 Mutex::Locker locker (m_mutex);
Greg Clayton12daf9462010-08-25 00:35:26 +0000690 const_iterator pos;
Greg Clayton5082c5f2010-08-27 18:24:16 +0000691 const_iterator begin = m_frames.begin();
692 const_iterator end = m_frames.end();
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000693 m_selected_frame_idx = 0;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000694 for (pos = begin; pos != end; ++pos)
695 {
696 if (pos->get() == frame)
697 {
Jim Ingham2976d002010-08-26 21:32:51 +0000698 m_selected_frame_idx = std::distance (begin, pos);
Jim Ingham513c6bb2012-09-01 01:02:41 +0000699 uint32_t inlined_depth = GetCurrentInlinedDepth();
700 if (inlined_depth != UINT32_MAX)
701 m_selected_frame_idx -= inlined_depth;
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000702 break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000703 }
704 }
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000705 SetDefaultFileAndLineToSelectedFrame();
Jim Ingham2976d002010-08-26 21:32:51 +0000706 return m_selected_frame_idx;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000707}
708
709// Mark a stack frame as the current frame using the frame index
Jim Inghamb0c72a52012-02-29 03:40:22 +0000710bool
Jim Ingham2976d002010-08-26 21:32:51 +0000711StackFrameList::SetSelectedFrameByIndex (uint32_t idx)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000712{
713 Mutex::Locker locker (m_mutex);
Jason Molendab57e4a12013-11-04 09:33:30 +0000714 StackFrameSP frame_sp (GetFrameAtIndex (idx));
Jim Inghamb0c72a52012-02-29 03:40:22 +0000715 if (frame_sp)
716 {
717 SetSelectedFrame(frame_sp.get());
718 return true;
719 }
720 else
721 return false;
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000722}
723
724void
725StackFrameList::SetDefaultFileAndLineToSelectedFrame()
726{
Greg Clayton1ac04c32012-02-21 00:09:25 +0000727 if (m_thread.GetID() == m_thread.GetProcess()->GetThreadList().GetSelectedThread()->GetID())
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000728 {
Jason Molendab57e4a12013-11-04 09:33:30 +0000729 StackFrameSP frame_sp (GetFrameAtIndex (GetSelectedFrameIndex()));
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000730 if (frame_sp)
731 {
Greg Clayton252d0ed2011-10-05 03:14:31 +0000732 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextLineEntry);
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000733 if (sc.line_entry.file)
Greg Clayton1ac04c32012-02-21 00:09:25 +0000734 m_thread.CalculateTarget()->GetSourceManager().SetDefaultFileAndLine (sc.line_entry.file,
Greg Clayton252d0ed2011-10-05 03:14:31 +0000735 sc.line_entry.line);
Jim Inghamb7f6b2f2011-09-08 22:13:49 +0000736 }
737 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000738}
739
740// The thread has been run, reset the number stack frames to zero so we can
741// determine how many frames we have lazily.
742void
743StackFrameList::Clear ()
744{
745 Mutex::Locker locker (m_mutex);
Greg Clayton5082c5f2010-08-27 18:24:16 +0000746 m_frames.clear();
Jim Inghamb0c72a52012-02-29 03:40:22 +0000747 m_concrete_frames_fetched = 0;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000748}
749
750void
751StackFrameList::InvalidateFrames (uint32_t start_idx)
752{
753 Mutex::Locker locker (m_mutex);
Greg Clayton12daf9462010-08-25 00:35:26 +0000754 if (m_show_inlined_frames)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000755 {
Greg Clayton12daf9462010-08-25 00:35:26 +0000756 Clear();
757 }
758 else
759 {
Greg Clayton5082c5f2010-08-27 18:24:16 +0000760 const size_t num_frames = m_frames.size();
Greg Clayton12daf9462010-08-25 00:35:26 +0000761 while (start_idx < num_frames)
762 {
Greg Clayton5082c5f2010-08-27 18:24:16 +0000763 m_frames[start_idx].reset();
Greg Clayton12daf9462010-08-25 00:35:26 +0000764 ++start_idx;
765 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000766 }
767}
Greg Clayton2cad65a2010-09-03 17:10:42 +0000768
769void
Greg Clayton7b0992d2013-04-18 22:45:39 +0000770StackFrameList::Merge (std::unique_ptr<StackFrameList>& curr_ap, lldb::StackFrameListSP& prev_sp)
Greg Clayton2cad65a2010-09-03 17:10:42 +0000771{
Jim Ingham10ebffa2012-05-04 23:02:50 +0000772 Mutex::Locker curr_locker (curr_ap.get() ? &curr_ap->m_mutex : NULL);
773 Mutex::Locker prev_locker (prev_sp.get() ? &prev_sp->m_mutex : NULL);
Greg Clayton2cad65a2010-09-03 17:10:42 +0000774
775#if defined (DEBUG_STACK_FRAMES)
Johnny Chen2c595272011-08-25 17:27:02 +0000776 StreamFile s(stdout, false);
Greg Clayton2cad65a2010-09-03 17:10:42 +0000777 s.PutCString("\n\nStackFrameList::Merge():\nPrev:\n");
778 if (prev_sp.get())
779 prev_sp->Dump (&s);
780 else
781 s.PutCString ("NULL");
782 s.PutCString("\nCurr:\n");
783 if (curr_ap.get())
784 curr_ap->Dump (&s);
785 else
786 s.PutCString ("NULL");
787 s.EOL();
788#endif
789
790 if (curr_ap.get() == NULL || curr_ap->GetNumFrames (false) == 0)
791 {
792#if defined (DEBUG_STACK_FRAMES)
793 s.PutCString("No current frames, leave previous frames alone...\n");
794#endif
795 curr_ap.release();
796 return;
797 }
798
799 if (prev_sp.get() == NULL || prev_sp->GetNumFrames (false) == 0)
800 {
801#if defined (DEBUG_STACK_FRAMES)
802 s.PutCString("No previous frames, so use current frames...\n");
803#endif
804 // We either don't have any previous frames, or since we have more than
805 // one current frames it means we have all the frames and can safely
806 // replace our previous frames.
807 prev_sp.reset (curr_ap.release());
808 return;
809 }
810
811 const uint32_t num_curr_frames = curr_ap->GetNumFrames (false);
812
813 if (num_curr_frames > 1)
814 {
815#if defined (DEBUG_STACK_FRAMES)
816 s.PutCString("We have more than one current frame, so use current frames...\n");
817#endif
818 // We have more than one current frames it means we have all the frames
819 // and can safely replace our previous frames.
820 prev_sp.reset (curr_ap.release());
821
822#if defined (DEBUG_STACK_FRAMES)
823 s.PutCString("\nMerged:\n");
824 prev_sp->Dump (&s);
825#endif
826 return;
827 }
828
Jason Molendab57e4a12013-11-04 09:33:30 +0000829 StackFrameSP prev_frame_zero_sp(prev_sp->GetFrameAtIndex (0));
830 StackFrameSP curr_frame_zero_sp(curr_ap->GetFrameAtIndex (0));
Greg Clayton2cad65a2010-09-03 17:10:42 +0000831 StackID curr_stack_id (curr_frame_zero_sp->GetStackID());
832 StackID prev_stack_id (prev_frame_zero_sp->GetStackID());
833
Greg Clayton2cad65a2010-09-03 17:10:42 +0000834#if defined (DEBUG_STACK_FRAMES)
Johnny Chen2c595272011-08-25 17:27:02 +0000835 const uint32_t num_prev_frames = prev_sp->GetNumFrames (false);
Greg Clayton2cad65a2010-09-03 17:10:42 +0000836 s.Printf("\n%u previous frames with one current frame\n", num_prev_frames);
837#endif
838
839 // We have only a single current frame
840 // Our previous stack frames only had a single frame as well...
841 if (curr_stack_id == prev_stack_id)
842 {
843#if defined (DEBUG_STACK_FRAMES)
844 s.Printf("\nPrevious frame #0 is same as current frame #0, merge the cached data\n");
845#endif
846
847 curr_frame_zero_sp->UpdateCurrentFrameFromPreviousFrame (*prev_frame_zero_sp);
848// prev_frame_zero_sp->UpdatePreviousFrameFromCurrentFrame (*curr_frame_zero_sp);
849// prev_sp->SetFrameAtIndex (0, prev_frame_zero_sp);
850 }
851 else if (curr_stack_id < prev_stack_id)
852 {
853#if defined (DEBUG_STACK_FRAMES)
854 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");
855#endif
856 prev_sp->m_frames.insert (prev_sp->m_frames.begin(), curr_frame_zero_sp);
857 }
858
859 curr_ap.release();
860
861#if defined (DEBUG_STACK_FRAMES)
862 s.PutCString("\nMerged:\n");
863 prev_sp->Dump (&s);
864#endif
865
866
867}
Jim Inghame4284b72010-09-23 17:40:12 +0000868
Jason Molendab57e4a12013-11-04 09:33:30 +0000869lldb::StackFrameSP
870StackFrameList::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr)
Jim Inghame4284b72010-09-23 17:40:12 +0000871{
872 const_iterator pos;
873 const_iterator begin = m_frames.begin();
874 const_iterator end = m_frames.end();
Jason Molendab57e4a12013-11-04 09:33:30 +0000875 lldb::StackFrameSP ret_sp;
Jim Inghame4284b72010-09-23 17:40:12 +0000876
877 for (pos = begin; pos != end; ++pos)
878 {
879 if (pos->get() == stack_frame_ptr)
880 {
881 ret_sp = (*pos);
882 break;
883 }
884 }
885 return ret_sp;
886}
887
Greg Clayton7260f622011-04-18 08:33:37 +0000888size_t
889StackFrameList::GetStatus (Stream& strm,
890 uint32_t first_frame,
891 uint32_t num_frames,
892 bool show_frame_info,
Jim Ingham8ec10ef2013-10-18 17:38:31 +0000893 uint32_t num_frames_with_source,
894 const char *selected_frame_marker)
Greg Clayton7260f622011-04-18 08:33:37 +0000895{
896 size_t num_frames_displayed = 0;
897
898 if (num_frames == 0)
899 return 0;
900
Jason Molendab57e4a12013-11-04 09:33:30 +0000901 StackFrameSP frame_sp;
Greg Clayton7260f622011-04-18 08:33:37 +0000902 uint32_t frame_idx = 0;
903 uint32_t last_frame;
904
905 // Don't let the last frame wrap around...
906 if (num_frames == UINT32_MAX)
907 last_frame = UINT32_MAX;
908 else
909 last_frame = first_frame + num_frames;
910
Jason Molendab57e4a12013-11-04 09:33:30 +0000911 StackFrameSP selected_frame_sp = m_thread.GetSelectedFrame();
Jim Ingham8ec10ef2013-10-18 17:38:31 +0000912 const char *unselected_marker = NULL;
913 std::string buffer;
914 if (selected_frame_marker)
915 {
916 size_t len = strlen(selected_frame_marker);
917 buffer.insert(buffer.begin(), len, ' ');
918 unselected_marker = buffer.c_str();
919 }
920 const char *marker = NULL;
921
Greg Clayton7260f622011-04-18 08:33:37 +0000922 for (frame_idx = first_frame; frame_idx < last_frame; ++frame_idx)
923 {
924 frame_sp = GetFrameAtIndex(frame_idx);
925 if (frame_sp.get() == NULL)
926 break;
927
Jim Ingham8ec10ef2013-10-18 17:38:31 +0000928 if (selected_frame_marker != NULL)
929 {
930 if (frame_sp == selected_frame_sp)
931 marker = selected_frame_marker;
932 else
933 marker = unselected_marker;
934 }
935
Greg Clayton7260f622011-04-18 08:33:37 +0000936 if (!frame_sp->GetStatus (strm,
937 show_frame_info,
Jim Ingham8ec10ef2013-10-18 17:38:31 +0000938 num_frames_with_source > (first_frame - frame_idx), marker))
Greg Clayton7260f622011-04-18 08:33:37 +0000939 break;
940 ++num_frames_displayed;
941 }
942
943 strm.IndentLess();
944 return num_frames_displayed;
945}
946