blob: c1f14bd216de4157c6547bba7ae1ed6c2eb24c8b [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- ThreadPlanStepInRange.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/ThreadPlanStepInRange.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"
18#include "lldb/Core/Log.h"
19#include "lldb/Core/Stream.h"
Jim Inghama56c8002010-07-10 02:27:39 +000020#include "lldb/Symbol/Symbol.h"
Jim Ingham7ce490c2010-09-16 00:58:09 +000021#include "lldb/Symbol/Function.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022#include "lldb/Target/Process.h"
23#include "lldb/Target/RegisterContext.h"
Greg Clayton514487e2011-02-15 21:59:32 +000024#include "lldb/Target/Target.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000025#include "lldb/Target/Thread.h"
26#include "lldb/Target/ThreadPlanStepOut.h"
27#include "lldb/Target/ThreadPlanStepThrough.h"
Jim Inghama56c8002010-07-10 02:27:39 +000028#include "lldb/Core/RegularExpression.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029
30using namespace lldb;
31using namespace lldb_private;
32
33uint32_t ThreadPlanStepInRange::s_default_flag_values = ThreadPlanShouldStopHere::eAvoidNoDebug;
34
35//----------------------------------------------------------------------
36// ThreadPlanStepInRange: Step through a stack range, either stepping over or into
37// based on the value of \a type.
38//----------------------------------------------------------------------
39
40ThreadPlanStepInRange::ThreadPlanStepInRange
41(
42 Thread &thread,
43 const AddressRange &range,
44 const SymbolContext &addr_context,
45 lldb::RunMode stop_others
46) :
Jim Inghamb01e7422010-06-19 04:45:32 +000047 ThreadPlanStepRange (ThreadPlan::eKindStepInRange, "Step Range stepping in", thread, range, addr_context, stop_others),
Jim Ingham7ce490c2010-09-16 00:58:09 +000048 ThreadPlanShouldStopHere (this, ThreadPlanStepInRange::DefaultShouldStopHereCallback, NULL),
Jim Inghamf02a2e92012-09-07 01:11:44 +000049 m_step_past_prologue (true),
50 m_virtual_step (false)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000051{
52 SetFlagsToDefault ();
53}
54
Jim Inghamc6276822012-12-12 19:58:40 +000055ThreadPlanStepInRange::ThreadPlanStepInRange
56(
57 Thread &thread,
58 const AddressRange &range,
59 const SymbolContext &addr_context,
60 const char *step_into_target,
61 lldb::RunMode stop_others
62) :
63 ThreadPlanStepRange (ThreadPlan::eKindStepInRange, "Step Range stepping in", thread, range, addr_context, stop_others),
64 ThreadPlanShouldStopHere (this, ThreadPlanStepInRange::DefaultShouldStopHereCallback, NULL),
65 m_step_past_prologue (true),
66 m_virtual_step (false),
67 m_step_into_target (step_into_target)
68{
69 SetFlagsToDefault ();
70}
71
Chris Lattner30fdc8d2010-06-08 16:52:24 +000072ThreadPlanStepInRange::~ThreadPlanStepInRange ()
73{
74}
75
76void
77ThreadPlanStepInRange::GetDescription (Stream *s, lldb::DescriptionLevel level)
78{
79 if (level == lldb::eDescriptionLevelBrief)
80 s->Printf("step in");
81 else
82 {
83 s->Printf ("Stepping through range (stepping into functions): ");
Jim Inghamc4c9fed2011-10-15 00:24:48 +000084 DumpRanges(s);
Jim Ingham4d56e9c2013-07-18 21:48:26 +000085 const char *step_into_target = m_step_into_target.AsCString();
86 if (step_into_target && step_into_target[0] != '\0')
87 s->Printf (" targeting %s.", m_step_into_target.AsCString());
88 else
89 s->PutChar('.');
Chris Lattner30fdc8d2010-06-08 16:52:24 +000090 }
91}
92
93bool
94ThreadPlanStepInRange::ShouldStop (Event *event_ptr)
95{
Greg Clayton5160ce52013-03-27 23:08:40 +000096 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner30fdc8d2010-06-08 16:52:24 +000097
98 if (log)
99 {
100 StreamString s;
Greg Clayton514487e2011-02-15 21:59:32 +0000101 s.Address (m_thread.GetRegisterContext()->GetPC(),
Greg Clayton1ac04c32012-02-21 00:09:25 +0000102 m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000103 log->Printf("ThreadPlanStepInRange reached %s.", s.GetData());
104 }
105
Jim Ingham25f66702011-12-03 01:52:59 +0000106 if (IsPlanComplete())
107 return true;
108
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000109 m_no_more_plans = false;
110 if (m_sub_plan_sp && m_sub_plan_sp->IsPlanComplete())
111 {
112 if (!m_sub_plan_sp->PlanSucceeded())
113 {
114 SetPlanComplete();
115 m_no_more_plans = true;
116 return true;
117 }
118 else
119 m_sub_plan_sp.reset();
120 }
121
Jim Inghamf02a2e92012-09-07 01:11:44 +0000122 if (m_virtual_step)
Jim Ingham58221732010-11-05 00:18:21 +0000123 {
Jim Inghamf02a2e92012-09-07 01:11:44 +0000124 // If we've just completed a virtual step, all we need to do is check for a ShouldStopHere plan, and otherwise
125 // we're done.
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000126 m_sub_plan_sp = InvokeShouldStopHereCallback();
Jim Inghamf02a2e92012-09-07 01:11:44 +0000127 }
128 else
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000129 {
Jim Ingham4a58e962012-10-25 22:30:09 +0000130 // Stepping through should be done running other threads in general, since we're setting a breakpoint and
131 // continuing. So only stop others if we are explicitly told to do so.
Jim Inghamf02a2e92012-09-07 01:11:44 +0000132
133 bool stop_others;
Jim Ingham4a58e962012-10-25 22:30:09 +0000134 if (m_stop_others == lldb::eOnlyThisThread)
Jim Inghamf02a2e92012-09-07 01:11:44 +0000135 stop_others = false;
Jim Ingham4a58e962012-10-25 22:30:09 +0000136 else
137 stop_others = true;
Jim Inghamf02a2e92012-09-07 01:11:44 +0000138
139 FrameComparison frame_order = CompareCurrentFrameToStartFrame();
140
141 if (frame_order == eFrameCompareOlder)
Jim Ingham7ce490c2010-09-16 00:58:09 +0000142 {
Jim Inghamf02a2e92012-09-07 01:11:44 +0000143 // If we're in an older frame then we should stop.
144 //
145 // A caveat to this is if we think the frame is older but we're actually in a trampoline.
146 // I'm going to make the assumption that you wouldn't RETURN to a trampoline. So if we are
147 // in a trampoline we think the frame is older because the trampoline confused the backtracer.
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000148 m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
149 if (!m_sub_plan_sp)
Jim Inghamf02a2e92012-09-07 01:11:44 +0000150 return true;
151 else if (log)
Jim Ingham7ce490c2010-09-16 00:58:09 +0000152 {
Jim Inghamf02a2e92012-09-07 01:11:44 +0000153 log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
Jim Ingham7ce490c2010-09-16 00:58:09 +0000154 }
Jim Inghamf02a2e92012-09-07 01:11:44 +0000155
156 }
157 else if (frame_order == eFrameCompareEqual && InSymbol())
158 {
159 // If we are not in a place we should step through, we're done.
160 // One tricky bit here is that some stubs don't push a frame, so we have to check
161 // both the case of a frame that is younger, or the same as this frame.
162 // However, if the frame is the same, and we are still in the symbol we started
163 // in, the we don't need to do this. This first check isn't strictly necessary,
164 // but it is more efficient.
Jim Ingham7ce490c2010-09-16 00:58:09 +0000165
Jim Inghamf02a2e92012-09-07 01:11:44 +0000166 // If we're still in the range, keep going, either by running to the next branch breakpoint, or by
167 // stepping.
168 if (InRange())
Jim Ingham7ce490c2010-09-16 00:58:09 +0000169 {
Jim Inghamf02a2e92012-09-07 01:11:44 +0000170 SetNextBranchBreakpoint();
171 return false;
172 }
173
174 SetPlanComplete();
Jim Inghamc6276822012-12-12 19:58:40 +0000175 m_no_more_plans = true;
Jim Inghamf02a2e92012-09-07 01:11:44 +0000176 return true;
177 }
178
179 // If we get to this point, we're not going to use a previously set "next branch" breakpoint, so delete it:
180 ClearNextBranchBreakpoint();
181
182 // We may have set the plan up above in the FrameIsOlder section:
183
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000184 if (!m_sub_plan_sp)
185 m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
Jim Inghamf02a2e92012-09-07 01:11:44 +0000186
187 if (log)
188 {
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000189 if (m_sub_plan_sp)
190 log->Printf ("Found a step through plan: %s", m_sub_plan_sp->GetName());
Jim Inghamf02a2e92012-09-07 01:11:44 +0000191 else
192 log->Printf ("No step through plan found.");
193 }
194
195 // If not, give the "should_stop" callback a chance to push a plan to get us out of here.
196 // But only do that if we actually have stepped in.
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000197 if (!m_sub_plan_sp && frame_order == eFrameCompareYounger)
198 m_sub_plan_sp = InvokeShouldStopHereCallback();
Jim Inghamf02a2e92012-09-07 01:11:44 +0000199
200 // If we've stepped in and we are going to stop here, check to see if we were asked to
201 // run past the prologue, and if so do that.
202
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000203 if (!m_sub_plan_sp && frame_order == eFrameCompareYounger && m_step_past_prologue)
Jim Inghamf02a2e92012-09-07 01:11:44 +0000204 {
205 lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0);
206 if (curr_frame)
207 {
208 size_t bytes_to_skip = 0;
209 lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC();
210 Address func_start_address;
211
212 SymbolContext sc = curr_frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextSymbol);
213
214 if (sc.function)
215 {
216 func_start_address = sc.function->GetAddressRange().GetBaseAddress();
217 if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget().get()))
218 bytes_to_skip = sc.function->GetPrologueByteSize();
219 }
220 else if (sc.symbol)
221 {
222 func_start_address = sc.symbol->GetAddress();
223 if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget().get()))
224 bytes_to_skip = sc.symbol->GetPrologueByteSize();
225 }
226
227 if (bytes_to_skip != 0)
228 {
229 func_start_address.Slide (bytes_to_skip);
230 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
231 if (log)
232 log->Printf ("Pushing past prologue ");
233
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000234 m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress(false, func_start_address,true);
Jim Inghamf02a2e92012-09-07 01:11:44 +0000235 }
Jim Ingham7ce490c2010-09-16 00:58:09 +0000236 }
237 }
Jim Inghamf02a2e92012-09-07 01:11:44 +0000238 }
Jim Ingham7ce490c2010-09-16 00:58:09 +0000239
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000240 if (!m_sub_plan_sp)
Jim Ingham7ce490c2010-09-16 00:58:09 +0000241 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000242 m_no_more_plans = true;
243 SetPlanComplete();
244 return true;
245 }
246 else
247 {
248 m_no_more_plans = false;
249 return false;
250 }
251}
252
253void
254ThreadPlanStepInRange::SetFlagsToDefault ()
255{
256 GetFlags().Set(ThreadPlanStepInRange::s_default_flag_values);
257}
258
Jim Inghama56c8002010-07-10 02:27:39 +0000259void
260ThreadPlanStepInRange::SetAvoidRegexp(const char *name)
261{
262 if (m_avoid_regexp_ap.get() == NULL)
263 m_avoid_regexp_ap.reset (new RegularExpression(name));
264
265 m_avoid_regexp_ap->Compile (name);
266}
267
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000268void
269ThreadPlanStepInRange::SetDefaultFlagValue (uint32_t new_value)
270{
271 // TODO: Should we test this for sanity?
272 ThreadPlanStepInRange::s_default_flag_values = new_value;
273}
274
Jim Inghama56c8002010-07-10 02:27:39 +0000275bool
276ThreadPlanStepInRange::FrameMatchesAvoidRegexp ()
277{
278 StackFrame *frame = GetThread().GetStackFrameAtIndex(0).get();
279
Greg Clayton67cc0632012-08-22 17:17:09 +0000280 const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
Jim Inghamee8aea12010-09-08 03:14:33 +0000281 if (avoid_regexp_to_use == NULL)
282 avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
283
284 if (avoid_regexp_to_use != NULL)
Jim Inghama56c8002010-07-10 02:27:39 +0000285 {
Greg Clayton4592cbc2012-07-13 00:19:40 +0000286 SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
Jim Inghama56c8002010-07-10 02:27:39 +0000287 if (sc.symbol != NULL)
288 {
Greg Clayton4592cbc2012-07-13 00:19:40 +0000289 const char *frame_function_name = sc.GetFunctionName().GetCString();
290 if (frame_function_name)
Jim Ingham3101ba32013-03-14 21:44:36 +0000291 {
Jim Inghamcf2667c2013-03-14 22:00:18 +0000292 size_t num_matches = 0;
Greg Clayton5160ce52013-03-27 23:08:40 +0000293 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Inghamcf2667c2013-03-14 22:00:18 +0000294 if (log)
295 num_matches = 1;
Greg Claytonbc43cab2013-04-03 21:37:16 +0000296
297 RegularExpression::Match regex_match(num_matches);
298
299 bool return_value = avoid_regexp_to_use->Execute(frame_function_name, &regex_match);
Jim Ingham3101ba32013-03-14 21:44:36 +0000300 if (return_value)
301 {
Jim Ingham3101ba32013-03-14 21:44:36 +0000302 if (log)
Jim Inghamcf2667c2013-03-14 22:00:18 +0000303 {
304 std::string match;
Greg Claytonbc43cab2013-04-03 21:37:16 +0000305 regex_match.GetMatchAtIndex(frame_function_name,0, match);
Jim Inghamcf2667c2013-03-14 22:00:18 +0000306 log->Printf ("Stepping out of function \"%s\" because it matches the avoid regexp \"%s\" - match substring: \"%s\".",
Jim Ingham3101ba32013-03-14 21:44:36 +0000307 frame_function_name,
Jim Inghamcf2667c2013-03-14 22:00:18 +0000308 avoid_regexp_to_use->GetText(),
309 match.c_str());
310 }
Jim Ingham3101ba32013-03-14 21:44:36 +0000311
312 }
313 return return_value;
314 }
Jim Inghama56c8002010-07-10 02:27:39 +0000315 }
316 }
317 return false;
318}
319
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000320ThreadPlanSP
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000321ThreadPlanStepInRange::DefaultShouldStopHereCallback (ThreadPlan *current_plan, Flags &flags, void *baton)
322{
Jim Inghama56c8002010-07-10 02:27:39 +0000323 bool should_step_out = false;
324 StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get();
Greg Clayton5160ce52013-03-27 23:08:40 +0000325 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Inghama56c8002010-07-10 02:27:39 +0000326
Greg Clayton73b472d2010-10-27 03:32:59 +0000327 if (flags.Test(eAvoidNoDebug))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000328 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000329 if (!frame->HasDebugInformation())
Jim Inghamaf0f1752010-09-15 00:06:51 +0000330 {
331 if (log)
332 log->Printf ("Stepping out of frame with no debug info");
333
Jim Inghama56c8002010-07-10 02:27:39 +0000334 should_step_out = true;
Jim Inghamaf0f1752010-09-15 00:06:51 +0000335 }
Jim Inghama56c8002010-07-10 02:27:39 +0000336 }
337
Jim Inghamc6276822012-12-12 19:58:40 +0000338 if (current_plan->GetKind() == eKindStepInRange)
Jim Inghama56c8002010-07-10 02:27:39 +0000339 {
Jim Inghamc6276822012-12-12 19:58:40 +0000340 ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
341 if (step_in_range_plan->m_step_into_target)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000342 {
Jim Inghamc6276822012-12-12 19:58:40 +0000343 SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction|eSymbolContextBlock|eSymbolContextSymbol);
344 if (sc.symbol != NULL)
345 {
346 // First try an exact match, since that's cheap with ConstStrings. Then do a strstr compare.
347 if (step_in_range_plan->m_step_into_target == sc.GetFunctionName())
348 {
349 should_step_out = false;
350 }
351 else
352 {
353 const char *target_name = step_in_range_plan->m_step_into_target.AsCString();
354 const char *function_name = sc.GetFunctionName().AsCString();
355
356 if (function_name == NULL)
357 should_step_out = true;
358 else if (strstr (function_name, target_name) == NULL)
359 should_step_out = true;
360 }
Jim Ingham3101ba32013-03-14 21:44:36 +0000361 if (log && should_step_out)
362 log->Printf("Stepping out of frame %s which did not match step into target %s.",
363 sc.GetFunctionName().AsCString(),
364 step_in_range_plan->m_step_into_target.AsCString());
Jim Inghamc6276822012-12-12 19:58:40 +0000365 }
366 }
367
368 if (!should_step_out)
369 {
Jim Ingham3101ba32013-03-14 21:44:36 +0000370 ThreadPlanStepInRange *step_in_range_plan = static_cast<ThreadPlanStepInRange *> (current_plan);
371 // Don't log the should_step_out here, it's easier to do it in FrameMatchesAvoidRegexp.
372 should_step_out = step_in_range_plan->FrameMatchesAvoidRegexp ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000373 }
374 }
Jim Inghama56c8002010-07-10 02:27:39 +0000375
Jim Inghamc6276822012-12-12 19:58:40 +0000376
Jim Inghama56c8002010-07-10 02:27:39 +0000377 if (should_step_out)
378 {
379 // FIXME: Make sure the ThreadPlanForStepOut does the right thing with inlined functions.
Jim Ingham4a58e962012-10-25 22:30:09 +0000380 // We really should have all plans take the tri-state for "stop others" so we can do the right
381 // thing. For now let's be safe and always run others when we are likely to run arbitrary code.
382 const bool stop_others = false;
Greg Clayton481cef22011-01-21 06:11:58 +0000383 return current_plan->GetThread().QueueThreadPlanForStepOut (false,
384 NULL,
385 true,
Jim Ingham4a58e962012-10-25 22:30:09 +0000386 stop_others,
Greg Clayton481cef22011-01-21 06:11:58 +0000387 eVoteNo,
388 eVoteNoOpinion,
389 0); // Frame index
Jim Inghama56c8002010-07-10 02:27:39 +0000390 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000391
Jim Ingham4d56e9c2013-07-18 21:48:26 +0000392 return ThreadPlanSP();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000393}
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000394
395bool
Jim Ingham221d51c2013-05-08 00:35:16 +0000396ThreadPlanStepInRange::DoPlanExplainsStop (Event *event_ptr)
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000397{
398 // We always explain a stop. Either we've just done a single step, in which
399 // case we'll do our ordinary processing, or we stopped for some
400 // reason that isn't handled by our sub-plans, in which case we want to just stop right
401 // away.
Jim Inghamc6276822012-12-12 19:58:40 +0000402 // In general, we don't want to mark the plan as complete for unexplained stops.
403 // For instance, if you step in to some code with no debug info, so you step out
404 // and in the course of that hit a breakpoint, then you want to stop & show the user
405 // the breakpoint, but not unship the step in plan, since you still may want to complete that
406 // plan when you continue. This is particularly true when doing "step in to target function."
407 // stepping.
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000408 //
409 // The only variation is that if we are doing "step by running to next branch" in which case
410 // if we hit our branch breakpoint we don't set the plan to complete.
Jim Ingham221d51c2013-05-08 00:35:16 +0000411
412 bool return_value;
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000413
Jim Inghamf02a2e92012-09-07 01:11:44 +0000414 if (m_virtual_step)
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000415 {
Jim Ingham221d51c2013-05-08 00:35:16 +0000416 return_value = true;
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000417 }
Jim Ingham221d51c2013-05-08 00:35:16 +0000418 else
419 {
Jim Ingham60c41182013-06-04 01:40:51 +0000420 StopInfoSP stop_info_sp = GetPrivateStopInfo ();
Jim Ingham221d51c2013-05-08 00:35:16 +0000421 if (stop_info_sp)
422 {
423 StopReason reason = stop_info_sp->GetStopReason();
424
425 switch (reason)
426 {
427 case eStopReasonBreakpoint:
428 if (NextRangeBreakpointExplainsStop(stop_info_sp))
429 {
430 return_value = true;
431 break;
432 }
433 case eStopReasonWatchpoint:
434 case eStopReasonSignal:
435 case eStopReasonException:
436 case eStopReasonExec:
437 case eStopReasonThreadExiting:
438 {
439 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
440 if (log)
441 log->PutCString ("ThreadPlanStepInRange got asked if it explains the stop for some reason other than step.");
442 }
443 return_value = false;
444 break;
445 default:
446 return_value = true;
447 break;
448 }
449 }
450 else
451 return_value = true;
452 }
453
454 return return_value;
Jim Inghamfbbfe6e2012-05-01 18:38:37 +0000455}
Jim Ingham513c6bb2012-09-01 01:02:41 +0000456
457bool
Jim Ingham221d51c2013-05-08 00:35:16 +0000458ThreadPlanStepInRange::DoWillResume (lldb::StateType resume_state, bool current_plan)
Jim Ingham513c6bb2012-09-01 01:02:41 +0000459{
460 if (resume_state == eStateStepping && current_plan)
461 {
462 // See if we are about to step over a virtual inlined call.
463 bool step_without_resume = m_thread.DecrementCurrentInlinedDepth();
464 if (step_without_resume)
465 {
Greg Clayton5160ce52013-03-27 23:08:40 +0000466 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Jim Ingham513c6bb2012-09-01 01:02:41 +0000467 if (log)
Jim Ingham221d51c2013-05-08 00:35:16 +0000468 log->Printf ("ThreadPlanStepInRange::DoWillResume: returning false, inline_depth: %d",
Jim Ingham513c6bb2012-09-01 01:02:41 +0000469 m_thread.GetCurrentInlinedDepth());
470 SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread));
Jim Inghamf02a2e92012-09-07 01:11:44 +0000471
472 // FIXME: Maybe it would be better to create a InlineStep stop reason, but then
473 // the whole rest of the world would have to handle that stop reason.
474 m_virtual_step = true;
Jim Ingham513c6bb2012-09-01 01:02:41 +0000475 }
476 return !step_without_resume;
477 }
Jim Ingham221d51c2013-05-08 00:35:16 +0000478 return true;
Jim Ingham513c6bb2012-09-01 01:02:41 +0000479}
Daniel Malea246cb612013-05-14 15:20:12 +0000480
481bool
482ThreadPlanStepInRange::IsVirtualStep()
483{
484 return m_virtual_step;
485}