blob: e2820790e717faa46062b7cde99ccbf6ba593186 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- ThreadPlanStepRange.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
10#include "lldb/Target/ThreadPlanStepRange.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16
17#include "lldb/lldb-private-log.h"
Jim Ingham0c61dee2013-03-13 01:56:41 +000018#include "lldb/Breakpoint/BreakpointLocation.h"
19#include "lldb/Breakpoint/BreakpointSite.h"
Jim Ingham564d8bc22012-03-09 04:10:47 +000020#include "lldb/Core/Disassembler.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021#include "lldb/Core/Log.h"
22#include "lldb/Core/Stream.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000023#include "lldb/Symbol/Function.h"
24#include "lldb/Symbol/Symbol.h"
Jim Ingham564d8bc22012-03-09 04:10:47 +000025#include "lldb/Target/ExecutionContext.h"
Greg Claytonf4b47e12010-08-04 01:40:35 +000026#include "lldb/Target/Process.h"
27#include "lldb/Target/RegisterContext.h"
28#include "lldb/Target/StopInfo.h"
Jim Ingham564d8bc22012-03-09 04:10:47 +000029#include "lldb/Target/Target.h"
Greg Claytonf4b47e12010-08-04 01:40:35 +000030#include "lldb/Target/Thread.h"
Jim Ingham564d8bc22012-03-09 04:10:47 +000031#include "lldb/Target/ThreadPlanRunToAddress.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000032
33using namespace lldb;
34using namespace lldb_private;
35
36
37//----------------------------------------------------------------------
38// ThreadPlanStepRange: Step through a stack range, either stepping over or into
39// based on the value of \a type.
40//----------------------------------------------------------------------
41
Jim Ingham242e0ad2011-02-08 04:27:50 +000042ThreadPlanStepRange::ThreadPlanStepRange (ThreadPlanKind kind,
43 const char *name,
44 Thread &thread,
45 const AddressRange &range,
46 const SymbolContext &addr_context,
47 lldb::RunMode stop_others) :
Jim Ingham35b21fe2010-07-10 02:23:31 +000048 ThreadPlan (kind, name, thread, eVoteNoOpinion, eVoteNoOpinion),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000049 m_addr_context (addr_context),
Jim Inghamc4c9fed2011-10-15 00:24:48 +000050 m_address_ranges (),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000051 m_stop_others (stop_others),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000052 m_stack_id (),
Greg Claytonc982c762010-07-09 20:39:50 +000053 m_no_more_plans (false),
Jim Ingham0c61dee2013-03-13 01:56:41 +000054 m_first_run_event (true),
55 m_use_fast_step(false)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000056{
Jim Ingham63c5c2a2013-07-19 02:18:31 +000057 llvm::Triple::ArchType arch_type = GetTarget().GetArchitecture().GetMachine();
58 if (arch_type == llvm::Triple::arm || arch_type == llvm::Triple::thumb)
59 m_use_fast_step = false;
60 else
61 m_use_fast_step = GetTarget().GetUseFastStepping();
Jim Inghamc4c9fed2011-10-15 00:24:48 +000062 AddRange(range);
Chris Lattner30fdc8d2010-06-08 16:52:24 +000063 m_stack_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
64}
65
66ThreadPlanStepRange::~ThreadPlanStepRange ()
67{
Jim Ingham564d8bc22012-03-09 04:10:47 +000068 ClearNextBranchBreakpoint();
69}
70
71void
72ThreadPlanStepRange::DidPush ()
73{
74 // See if we can find a "next range" breakpoint:
75 SetNextBranchBreakpoint();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000076}
77
78bool
79ThreadPlanStepRange::ValidatePlan (Stream *error)
80{
81 return true;
82}
83
Chris Lattner30fdc8d2010-06-08 16:52:24 +000084Vote
85ThreadPlanStepRange::ShouldReportStop (Event *event_ptr)
86{
Greg Clayton5160ce52013-03-27 23:08:40 +000087 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Greg Clayton2cad65a2010-09-03 17:10:42 +000088
89 const Vote vote = IsPlanComplete() ? eVoteYes : eVoteNo;
90 if (log)
Greg Clayton411c0ce2011-01-18 21:44:45 +000091 log->Printf ("ThreadPlanStepRange::ShouldReportStop() returning vote %i\n", vote);
Greg Clayton2cad65a2010-09-03 17:10:42 +000092 return vote;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000093}
94
Jim Inghamc4c9fed2011-10-15 00:24:48 +000095void
96ThreadPlanStepRange::AddRange(const AddressRange &new_range)
97{
98 // For now I'm just adding the ranges. At some point we may want to
99 // condense the ranges if they overlap, though I don't think it is likely
100 // to be very important.
101 m_address_ranges.push_back (new_range);
Jim Ingham564d8bc22012-03-09 04:10:47 +0000102 m_instruction_ranges.push_back (DisassemblerSP());
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000103}
104
105void
106ThreadPlanStepRange::DumpRanges(Stream *s)
107{
108 size_t num_ranges = m_address_ranges.size();
109 if (num_ranges == 1)
110 {
Greg Clayton1ac04c32012-02-21 00:09:25 +0000111 m_address_ranges[0].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000112 }
113 else
114 {
115 for (size_t i = 0; i < num_ranges; i++)
116 {
117 s->PutCString("%d: ");
Greg Clayton1ac04c32012-02-21 00:09:25 +0000118 m_address_ranges[i].Dump (s, m_thread.CalculateTarget().get(), Address::DumpStyleLoadAddress);
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000119 }
120 }
121}
122
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000123bool
124ThreadPlanStepRange::InRange ()
125{
Greg Clayton5160ce52013-03-27 23:08:40 +0000126 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000127 bool ret_value = false;
128
129 lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC();
130
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000131 size_t num_ranges = m_address_ranges.size();
132 for (size_t i = 0; i < num_ranges; i++)
133 {
Greg Clayton1ac04c32012-02-21 00:09:25 +0000134 ret_value = m_address_ranges[i].ContainsLoadAddress(pc_load_addr, m_thread.CalculateTarget().get());
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000135 if (ret_value)
136 break;
137 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000138
139 if (!ret_value)
140 {
141 // See if we've just stepped to another part of the same line number...
142 StackFrame *frame = m_thread.GetStackFrameAtIndex(0).get();
143
144 SymbolContext new_context(frame->GetSymbolContext(eSymbolContextEverything));
145 if (m_addr_context.line_entry.IsValid() && new_context.line_entry.IsValid())
146 {
Jim Ingham843bfb22011-09-23 21:08:11 +0000147 if (m_addr_context.line_entry.file == new_context.line_entry.file)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000148 {
Jim Ingham843bfb22011-09-23 21:08:11 +0000149 if (m_addr_context.line_entry.line == new_context.line_entry.line)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000150 {
Jim Ingham843bfb22011-09-23 21:08:11 +0000151 m_addr_context = new_context;
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000152 AddRange(m_addr_context.line_entry.range);
Jim Ingham843bfb22011-09-23 21:08:11 +0000153 ret_value = true;
154 if (log)
155 {
156 StreamString s;
Jim Ingham927bfa32012-09-10 23:42:44 +0000157 m_addr_context.line_entry.Dump (&s,
158 m_thread.CalculateTarget().get(),
159 true,
160 Address::DumpStyleLoadAddress,
161 Address::DumpStyleLoadAddress,
162 true);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000163
Jim Ingham843bfb22011-09-23 21:08:11 +0000164 log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData());
165 }
166 }
Greg Clayton1ac04c32012-02-21 00:09:25 +0000167 else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(m_thread.CalculateTarget().get())
Jim Ingham843bfb22011-09-23 21:08:11 +0000168 != pc_load_addr)
169 {
170 // Another thing that sometimes happens here is that we step out of one line into the MIDDLE of another
171 // line. So far I mostly see this due to bugs in the debug information.
172 // But we probably don't want to be in the middle of a line range, so in that case reset the stepping
173 // range to the line we've stepped into the middle of and continue.
174 m_addr_context = new_context;
Jim Inghamc4c9fed2011-10-15 00:24:48 +0000175 m_address_ranges.clear();
176 AddRange(m_addr_context.line_entry.range);
Jim Ingham843bfb22011-09-23 21:08:11 +0000177 ret_value = true;
178 if (log)
179 {
180 StreamString s;
Jim Ingham927bfa32012-09-10 23:42:44 +0000181 m_addr_context.line_entry.Dump (&s,
182 m_thread.CalculateTarget().get(),
183 true,
184 Address::DumpStyleLoadAddress,
185 Address::DumpStyleLoadAddress,
186 true);
Jim Ingham843bfb22011-09-23 21:08:11 +0000187
188 log->Printf ("Step range plan stepped to the middle of new line(%d): %s, continuing to clear this line.",
189 new_context.line_entry.line,
190 s.GetData());
191 }
192
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000193 }
194 }
Jim Ingham843bfb22011-09-23 21:08:11 +0000195
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000196 }
197
198 }
199
200 if (!ret_value && log)
Daniel Malead01b2952012-11-29 21:49:15 +0000201 log->Printf ("Step range plan out of range to 0x%" PRIx64, pc_load_addr);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000202
203 return ret_value;
204}
205
206bool
207ThreadPlanStepRange::InSymbol()
208{
209 lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000210 if (m_addr_context.function != NULL)
211 {
Greg Clayton1ac04c32012-02-21 00:09:25 +0000212 return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000213 }
Greg Claytone7612132012-03-07 21:03:09 +0000214 else if (m_addr_context.symbol)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000215 {
Greg Claytone7612132012-03-07 21:03:09 +0000216 AddressRange range(m_addr_context.symbol->GetAddress(), m_addr_context.symbol->GetByteSize());
217 return range.ContainsLoadAddress (cur_pc, m_thread.CalculateTarget().get());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000218 }
219 return false;
220}
221
222// FIXME: This should also handle inlining if we aren't going to do inlining in the
223// main stack.
224//
225// Ideally we should remember the whole stack frame list, and then compare that
226// to the current list.
227
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000228lldb::FrameComparison
229ThreadPlanStepRange::CompareCurrentFrameToStartFrame()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000230{
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000231 FrameComparison frame_order;
Jim Ingham7ce490c2010-09-16 00:58:09 +0000232
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000233 StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
Jim Ingham7ce490c2010-09-16 00:58:09 +0000234
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000235 if (cur_frame_id == m_stack_id)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000236 {
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000237 frame_order = eFrameCompareEqual;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000238 }
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000239 else if (cur_frame_id < m_stack_id)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000240 {
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000241 frame_order = eFrameCompareYounger;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000242 }
243 else
244 {
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000245 frame_order = eFrameCompareOlder;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000246 }
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000247 return frame_order;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000248}
249
250bool
251ThreadPlanStepRange::StopOthers ()
252{
253 if (m_stop_others == lldb::eOnlyThisThread
254 || m_stop_others == lldb::eOnlyDuringStepping)
255 return true;
256 else
257 return false;
258}
259
Jim Ingham564d8bc22012-03-09 04:10:47 +0000260InstructionList *
261ThreadPlanStepRange::GetInstructionsForAddress(lldb::addr_t addr, size_t &range_index, size_t &insn_offset)
262{
263 size_t num_ranges = m_address_ranges.size();
264 for (size_t i = 0; i < num_ranges; i++)
265 {
266 if (m_address_ranges[i].ContainsLoadAddress(addr, &GetTarget()))
267 {
268 // Some joker added a zero size range to the stepping range...
269 if (m_address_ranges[i].GetByteSize() == 0)
270 return NULL;
271
272 if (!m_instruction_ranges[i])
273 {
274 //Disassemble the address range given:
275 ExecutionContext exe_ctx (m_thread.GetProcess());
Jim Ingham0f063ba2013-03-02 00:26:47 +0000276 const char *plugin_name = NULL;
277 const char *flavor = NULL;
Jim Ingham564d8bc22012-03-09 04:10:47 +0000278 m_instruction_ranges[i] = Disassembler::DisassembleRange(GetTarget().GetArchitecture(),
Jim Ingham0f063ba2013-03-02 00:26:47 +0000279 plugin_name,
280 flavor,
Jim Ingham564d8bc22012-03-09 04:10:47 +0000281 exe_ctx,
282 m_address_ranges[i]);
283
284 }
285 if (!m_instruction_ranges[i])
286 return NULL;
287 else
288 {
289 // Find where we are in the instruction list as well. If we aren't at an instruction,
290 // return NULL. In this case, we're probably lost, and shouldn't try to do anything fancy.
291
292 insn_offset = m_instruction_ranges[i]->GetInstructionList().GetIndexOfInstructionAtLoadAddress(addr, GetTarget());
293 if (insn_offset == UINT32_MAX)
294 return NULL;
295 else
296 {
297 range_index = i;
298 return &m_instruction_ranges[i]->GetInstructionList();
299 }
300 }
301 }
302 }
303 return NULL;
304}
305
306void
307ThreadPlanStepRange::ClearNextBranchBreakpoint()
308{
309 if (m_next_branch_bp_sp)
310 {
Greg Clayton5160ce52013-03-27 23:08:40 +0000311 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham0c61dee2013-03-13 01:56:41 +0000312 if (log)
313 log->Printf ("Removing next branch breakpoint: %d.", m_next_branch_bp_sp->GetID());
Jim Ingham564d8bc22012-03-09 04:10:47 +0000314 GetTarget().RemoveBreakpointByID (m_next_branch_bp_sp->GetID());
315 m_next_branch_bp_sp.reset();
316 }
317}
318
319bool
320ThreadPlanStepRange::SetNextBranchBreakpoint ()
321{
Jim Ingham0c61dee2013-03-13 01:56:41 +0000322 if (m_next_branch_bp_sp)
323 return true;
324
Greg Clayton5160ce52013-03-27 23:08:40 +0000325 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham564d8bc22012-03-09 04:10:47 +0000326 // Stepping through ranges using breakpoints doesn't work yet, but with this off we fall back to instruction
327 // single stepping.
Jim Ingham0c61dee2013-03-13 01:56:41 +0000328 if (!m_use_fast_step)
329 return false;
330
Jim Ingham564d8bc22012-03-09 04:10:47 +0000331 lldb::addr_t cur_addr = GetThread().GetRegisterContext()->GetPC();
332 // Find the current address in our address ranges, and fetch the disassembly if we haven't already:
333 size_t pc_index;
334 size_t range_index;
335 InstructionList *instructions = GetInstructionsForAddress (cur_addr, range_index, pc_index);
336 if (instructions == NULL)
337 return false;
338 else
339 {
340 uint32_t branch_index;
341 branch_index = instructions->GetIndexOfNextBranchInstruction (pc_index);
342
343 Address run_to_address;
344
345 // If we didn't find a branch, run to the end of the range.
346 if (branch_index == UINT32_MAX)
347 {
Jim Ingham0c61dee2013-03-13 01:56:41 +0000348 branch_index = instructions->GetSize() - 1;
Jim Ingham564d8bc22012-03-09 04:10:47 +0000349 }
Jim Ingham0c61dee2013-03-13 01:56:41 +0000350
Jim Ingham564d8bc22012-03-09 04:10:47 +0000351 if (branch_index - pc_index > 1)
352 {
353 const bool is_internal = true;
354 run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress();
355 m_next_branch_bp_sp = GetTarget().CreateBreakpoint(run_to_address, is_internal);
Jim Ingham29950772013-01-26 02:19:28 +0000356 if (m_next_branch_bp_sp)
357 {
Jim Ingham0c61dee2013-03-13 01:56:41 +0000358 if (log)
359 {
360 lldb::break_id_t bp_site_id = LLDB_INVALID_BREAK_ID;
361 BreakpointLocationSP bp_loc = m_next_branch_bp_sp->GetLocationAtIndex(0);
362 if (bp_loc)
363 {
364 BreakpointSiteSP bp_site = bp_loc->GetBreakpointSite();
365 if (bp_site)
366 {
367 bp_site_id = bp_site->GetID();
368 }
369 }
370 log->Printf ("ThreadPlanStepRange::SetNextBranchBreakpoint - Setting breakpoint %d (site %d) to run to address 0x%" PRIx64,
371 m_next_branch_bp_sp->GetID(),
372 bp_site_id,
373 run_to_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget()));
374 }
Jim Ingham29950772013-01-26 02:19:28 +0000375 m_next_branch_bp_sp->SetThreadID(m_thread.GetID());
376 m_next_branch_bp_sp->SetBreakpointKind ("next-branch-location");
Jim Ingham0c61dee2013-03-13 01:56:41 +0000377 return true;
Jim Ingham29950772013-01-26 02:19:28 +0000378 }
379 else
380 return false;
Jim Ingham564d8bc22012-03-09 04:10:47 +0000381 }
382 }
383 return false;
384}
385
386bool
387ThreadPlanStepRange::NextRangeBreakpointExplainsStop (lldb::StopInfoSP stop_info_sp)
388{
Greg Clayton5160ce52013-03-27 23:08:40 +0000389 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham564d8bc22012-03-09 04:10:47 +0000390 if (!m_next_branch_bp_sp)
391 return false;
392
393 break_id_t bp_site_id = stop_info_sp->GetValue();
394 BreakpointSiteSP bp_site_sp = m_thread.GetProcess()->GetBreakpointSiteList().FindByID(bp_site_id);
Jim Ingham0c61dee2013-03-13 01:56:41 +0000395 if (!bp_site_sp)
396 return false;
397 else if (!bp_site_sp->IsBreakpointAtThisSite (m_next_branch_bp_sp->GetID()))
Jim Ingham564d8bc22012-03-09 04:10:47 +0000398 return false;
399 else
Jim Ingham0c61dee2013-03-13 01:56:41 +0000400 {
401 // If we've hit the next branch breakpoint, then clear it.
402 size_t num_owners = bp_site_sp->GetNumberOfOwners();
403 bool explains_stop = true;
404 // If all the owners are internal, then we are probably just stepping over this range from multiple threads,
405 // or multiple frames, so we want to continue. If one is not internal, then we should not explain the stop,
406 // and let the user breakpoint handle the stop.
407 for (size_t i = 0; i < num_owners; i++)
408 {
409 if (!bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint().IsInternal())
410 {
411 explains_stop = false;
412 break;
413 }
414 }
415 if (log)
416 log->Printf ("ThreadPlanStepRange::NextRangeBreakpointExplainsStop - Hit next range breakpoint which has %zu owners - explains stop: %u.",
417 num_owners,
418 explains_stop);
419 ClearNextBranchBreakpoint();
420 return explains_stop;
421 }
Jim Ingham564d8bc22012-03-09 04:10:47 +0000422}
423
424bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000425ThreadPlanStepRange::WillStop ()
426{
427 return true;
428}
429
430StateType
Jim Ingham06e827c2010-11-11 19:26:09 +0000431ThreadPlanStepRange::GetPlanRunState ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000432{
Jim Ingham564d8bc22012-03-09 04:10:47 +0000433 if (m_next_branch_bp_sp)
434 return eStateRunning;
435 else
436 return eStateStepping;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000437}
438
439bool
440ThreadPlanStepRange::MischiefManaged ()
441{
Jim Ingham927bfa32012-09-10 23:42:44 +0000442 // If we have pushed some plans between ShouldStop & MischiefManaged, then we're not done...
443 // I do this check first because we might have stepped somewhere that will fool InRange into
444 // thinking it needs to step past the end of that line. This happens, for instance, when stepping
445 // over inlined code that is in the middle of the current line.
446
447 if (!m_no_more_plans)
448 return false;
449
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000450 bool done = true;
451 if (!IsPlanComplete())
452 {
453 if (InRange())
454 {
455 done = false;
456 }
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000457 else
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000458 {
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000459 FrameComparison frame_order = CompareCurrentFrameToStartFrame();
460 if (frame_order != eFrameCompareOlder)
461 {
462 if (m_no_more_plans)
463 done = true;
464 else
465 done = false;
466 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000467 else
Jim Inghamb5c0d1c2012-03-01 00:50:50 +0000468 done = true;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000469 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000470 }
471
472 if (done)
473 {
Greg Clayton5160ce52013-03-27 23:08:40 +0000474 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000475 if (log)
476 log->Printf("Completed step through range plan.");
Jim Ingham0c61dee2013-03-13 01:56:41 +0000477 ClearNextBranchBreakpoint();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000478 ThreadPlan::MischiefManaged ();
479 return true;
480 }
481 else
482 {
483 return false;
484 }
485
486}
Jim Ingham64e7ead2012-05-03 21:19:36 +0000487
488bool
489ThreadPlanStepRange::IsPlanStale ()
490{
Greg Clayton5160ce52013-03-27 23:08:40 +0000491 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham64e7ead2012-05-03 21:19:36 +0000492 FrameComparison frame_order = CompareCurrentFrameToStartFrame();
493
494 if (frame_order == eFrameCompareOlder)
495 {
496 if (log)
497 {
498 log->Printf("ThreadPlanStepRange::IsPlanStale returning true, we've stepped out.");
499 }
500 return true;
501 }
502 else if (frame_order == eFrameCompareEqual && InSymbol())
503 {
504 // If we are not in a place we should step through, we've gotten stale.
505 // One tricky bit here is that some stubs don't push a frame, so we should.
506 // check that we are in the same symbol.
507 if (!InRange())
508 {
509 return true;
510 }
511 }
512 return false;
513}