blob: a01b5b725d830208699f69174382a4c37eaac307 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:241//===-- ThreadPlanCallFunction.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/ThreadPlanCallFunction.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
Sean Callanan6db73ca2010-11-03 01:37:5215#include "llvm/Support/MachO.h"
Chris Lattner30fdc8d2010-06-08 16:52:2416// Project includes
17#include "lldb/lldb-private-log.h"
Jim Ingham40d871f2010-10-26 00:27:4518#include "lldb/Breakpoint/Breakpoint.h"
19#include "lldb/Breakpoint/BreakpointLocation.h"
Chris Lattner30fdc8d2010-06-08 16:52:2420#include "lldb/Core/Address.h"
21#include "lldb/Core/Log.h"
22#include "lldb/Core/Stream.h"
Sean Callananf2115102010-11-03 22:19:3823#include "lldb/Target/LanguageRuntime.h"
Chris Lattner30fdc8d2010-06-08 16:52:2424#include "lldb/Target/Process.h"
25#include "lldb/Target/RegisterContext.h"
Jim Ingham40d871f2010-10-26 00:27:4526#include "lldb/Target/StopInfo.h"
Chris Lattner30fdc8d2010-06-08 16:52:2427#include "lldb/Target/Target.h"
28#include "lldb/Target/Thread.h"
29#include "lldb/Target/ThreadPlanRunToAddress.h"
30
31using namespace lldb;
32using namespace lldb_private;
33
34//----------------------------------------------------------------------
35// ThreadPlanCallFunction: Plan to call a single function
36//----------------------------------------------------------------------
37
38ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
39 Address &function,
Jim Inghamef651602011-12-22 19:12:4040 const ClangASTType &return_type,
Greg Clayton2a48f522011-05-14 01:50:3541 addr_t arg,
Chris Lattner30fdc8d2010-06-08 16:52:2442 bool stop_other_threads,
Sean Callananfc55f5d2010-09-21 00:44:1243 bool discard_on_error,
Greg Clayton2a48f522011-05-14 01:50:3544 addr_t *this_arg,
45 addr_t *cmd_arg) :
Jim Inghamb01e742a2010-06-19 04:45:3246 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
Benjamin Kramer1ee0d4f2010-07-16 12:32:3347 m_valid (false),
48 m_stop_other_threads (stop_other_threads),
Jim Ingham16e0c682011-08-12 23:34:3149 m_function_addr (function),
Peter Collingbourne6b5f17a2011-06-03 20:41:0950 m_function_sp (NULL),
Jim Inghamef651602011-12-22 19:12:4051 m_return_type (return_type),
Jim Inghamce553d82011-11-01 02:46:5452 m_takedown_done (false),
53 m_stop_address (LLDB_INVALID_ADDRESS)
Chris Lattner30fdc8d2010-06-08 16:52:2454{
Jim Inghamcf274f92012-04-09 22:37:3955 // Call function thread plans need to be master plans so that they can potentially stay on the stack when
56 // a breakpoint is hit during the function call.
57 SetIsMasterPlan (true);
Chris Lattner30fdc8d2010-06-08 16:52:2458 SetOkayToDiscard (discard_on_error);
59
Greg Clayton1ac04c32012-02-21 00:09:2560 ProcessSP process_sp (thread.GetProcess());
61 if (!process_sp)
62 return;
63
64 const ABI *abi = process_sp->GetABI().get();
Sean Callanan6db73ca2010-11-03 01:37:5265
Chris Lattner30fdc8d2010-06-08 16:52:2466 if (!abi)
67 return;
Sean Callanan6db73ca2010-11-03 01:37:5268
Greg Clayton1ac04c32012-02-21 00:09:2569 TargetSP target_sp (thread.CalculateTarget());
70
Jim Ingham77787032011-01-20 02:03:1871 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
72
Sean Callanan6db73ca2010-11-03 01:37:5273 SetBreakpoints();
74
Sean Callanane359d9b2011-05-09 22:04:3675 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
Chris Lattner30fdc8d2010-06-08 16:52:2476
Greg Clayton1ac04c32012-02-21 00:09:2577 Module *exe_module = target_sp->GetExecutableModulePointer();
Chris Lattner30fdc8d2010-06-08 16:52:2478
Greg Claytonaa149cb2011-08-11 02:48:4579 if (exe_module == NULL)
Jim Ingham672e6f52011-03-07 23:44:0880 {
Johnny Chen9e916e82011-08-10 17:58:1181 if (log)
82 log->Printf ("Can't execute code without an executable module.");
Chris Lattner30fdc8d2010-06-08 16:52:2483 return;
Jim Ingham672e6f52011-03-07 23:44:0884 }
85 else
86 {
Greg Claytonaa149cb2011-08-11 02:48:4587 ObjectFile *objectFile = exe_module->GetObjectFile();
Jim Ingham672e6f52011-03-07 23:44:0888 if (!objectFile)
89 {
Johnny Chen9e916e82011-08-10 17:58:1190 if (log)
91 log->Printf ("Could not find object file for module \"%s\".",
Greg Clayton0c02e4e2011-08-11 04:30:3992 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham672e6f52011-03-07 23:44:0893 return;
94 }
95 m_start_addr = objectFile->GetEntryPointAddress();
96 if (!m_start_addr.IsValid())
97 {
Johnny Chen9e916e82011-08-10 17:58:1198 if (log)
99 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Clayton0c02e4e2011-08-11 04:30:39100 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham672e6f52011-03-07 23:44:08101 return;
102 }
103 }
Chris Lattner30fdc8d2010-06-08 16:52:24104
Greg Clayton1ac04c32012-02-21 00:09:25105 addr_t start_load_addr = m_start_addr.GetLoadAddress (target_sp.get());
Jim Ingham672e6f52011-03-07 23:44:08106
Jim Ingham77787032011-01-20 02:03:18107 // Checkpoint the thread state so we can restore it later.
Jim Ingham9da36832011-01-22 01:27:23108 if (log && log->GetVerbose())
109 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
110
Jim Ingham77787032011-01-20 02:03:18111 if (!thread.CheckpointThreadState (m_stored_thread_state))
112 {
113 if (log)
114 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
Chris Lattner30fdc8d2010-06-08 16:52:24115 return;
Jim Ingham77787032011-01-20 02:03:18116 }
117 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
118 thread.SetStopInfoToNothing();
119
Greg Clayton1ac04c32012-02-21 00:09:25120 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress (target_sp.get());
Chris Lattner30fdc8d2010-06-08 16:52:24121
Greg Claytonfdeb1562011-05-12 02:14:56122 if (this_arg && cmd_arg)
123 {
124 if (!abi->PrepareTrivialCall (thread,
125 m_function_sp,
126 FunctionLoadAddr,
Greg Clayton2a48f522011-05-14 01:50:35127 start_load_addr,
Greg Claytonfdeb1562011-05-12 02:14:56128 this_arg,
129 cmd_arg,
Greg Clayton2a48f522011-05-14 01:50:35130 &arg))
Greg Claytonfdeb1562011-05-12 02:14:56131 return;
132 }
133 else if (this_arg)
134 {
135 if (!abi->PrepareTrivialCall (thread,
136 m_function_sp,
137 FunctionLoadAddr,
Greg Clayton2a48f522011-05-14 01:50:35138 start_load_addr,
Greg Claytonfdeb1562011-05-12 02:14:56139 this_arg,
Greg Clayton2a48f522011-05-14 01:50:35140 &arg))
Greg Claytonfdeb1562011-05-12 02:14:56141 return;
142 }
143 else
144 {
145 if (!abi->PrepareTrivialCall (thread,
146 m_function_sp,
147 FunctionLoadAddr,
Greg Clayton2a48f522011-05-14 01:50:35148 start_load_addr,
149 &arg))
150 return;
151 }
152
153 ReportRegisterState ("Function call was set up. Register state was:");
154
155 m_valid = true;
156}
157
158
159ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
160 Address &function,
Jim Inghamef651602011-12-22 19:12:40161 const ClangASTType &return_type,
Greg Clayton2a48f522011-05-14 01:50:35162 bool stop_other_threads,
163 bool discard_on_error,
164 addr_t *arg1_ptr,
165 addr_t *arg2_ptr,
166 addr_t *arg3_ptr,
167 addr_t *arg4_ptr,
168 addr_t *arg5_ptr,
169 addr_t *arg6_ptr) :
170 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
171 m_valid (false),
172 m_stop_other_threads (stop_other_threads),
Jim Ingham16e0c682011-08-12 23:34:31173 m_function_addr (function),
Peter Collingbourne6b5f17a2011-06-03 20:41:09174 m_function_sp(NULL),
Jim Inghamef651602011-12-22 19:12:40175 m_return_type (return_type),
Peter Collingbourne6b5f17a2011-06-03 20:41:09176 m_takedown_done (false)
Greg Clayton2a48f522011-05-14 01:50:35177{
Jim Inghamcf274f92012-04-09 22:37:39178 // Call function thread plans need to be master plans so that they can potentially stay on the stack when
179 // a breakpoint is hit during the function call.
180 SetIsMasterPlan (true);
Greg Clayton2a48f522011-05-14 01:50:35181 SetOkayToDiscard (discard_on_error);
182
Greg Clayton1ac04c32012-02-21 00:09:25183 ProcessSP process_sp (thread.GetProcess());
184 if (!process_sp)
185 return;
186
187 const ABI *abi = process_sp->GetABI().get();
Greg Clayton2a48f522011-05-14 01:50:35188
189 if (!abi)
190 return;
Greg Clayton1ac04c32012-02-21 00:09:25191
192 TargetSP target_sp (thread.CalculateTarget());
193
Greg Clayton2a48f522011-05-14 01:50:35194 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
195
196 SetBreakpoints();
197
198 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
199
Greg Clayton1ac04c32012-02-21 00:09:25200 Module *exe_module = target_sp->GetExecutableModulePointer();
Greg Clayton2a48f522011-05-14 01:50:35201
Greg Claytonaa149cb2011-08-11 02:48:45202 if (exe_module == NULL)
Greg Clayton2a48f522011-05-14 01:50:35203 {
Johnny Chen9e916e82011-08-10 17:58:11204 if (log)
205 log->Printf ("Can't execute code without an executable module.");
Greg Clayton2a48f522011-05-14 01:50:35206 return;
207 }
208 else
209 {
Greg Claytonaa149cb2011-08-11 02:48:45210 ObjectFile *objectFile = exe_module->GetObjectFile();
Greg Clayton2a48f522011-05-14 01:50:35211 if (!objectFile)
212 {
Johnny Chen9e916e82011-08-10 17:58:11213 if (log)
214 log->Printf ("Could not find object file for module \"%s\".",
Greg Clayton0c02e4e2011-08-11 04:30:39215 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton2a48f522011-05-14 01:50:35216 return;
217 }
218 m_start_addr = objectFile->GetEntryPointAddress();
219 if (!m_start_addr.IsValid())
220 {
Greg Claytonaf247d72011-05-19 03:54:16221 if (log)
222 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Claytonaa149cb2011-08-11 02:48:45223 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton2a48f522011-05-14 01:50:35224 return;
225 }
226 }
227
Greg Clayton1ac04c32012-02-21 00:09:25228 addr_t start_load_addr = m_start_addr.GetLoadAddress(target_sp.get());
Greg Clayton2a48f522011-05-14 01:50:35229
230 // Checkpoint the thread state so we can restore it later.
231 if (log && log->GetVerbose())
232 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
233
234 if (!thread.CheckpointThreadState (m_stored_thread_state))
235 {
236 if (log)
237 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
238 return;
239 }
240 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
241 thread.SetStopInfoToNothing();
242
Greg Clayton1ac04c32012-02-21 00:09:25243 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(target_sp.get());
Greg Clayton2a48f522011-05-14 01:50:35244
245 if (!abi->PrepareTrivialCall (thread,
246 m_function_sp,
247 FunctionLoadAddr,
248 start_load_addr,
249 arg1_ptr,
250 arg2_ptr,
251 arg3_ptr,
252 arg4_ptr,
253 arg5_ptr,
254 arg6_ptr))
255 {
Greg Claytonfdeb1562011-05-12 02:14:56256 return;
257 }
Chris Lattner30fdc8d2010-06-08 16:52:24258
Jim Ingham9da36832011-01-22 01:27:23259 ReportRegisterState ("Function call was set up. Register state was:");
260
261 m_valid = true;
262}
263
264ThreadPlanCallFunction::~ThreadPlanCallFunction ()
265{
Jim Ingham718583f2012-04-13 18:27:58266 DoTakedown();
Jim Ingham9da36832011-01-22 01:27:23267}
268
269void
270ThreadPlanCallFunction::ReportRegisterState (const char *message)
271{
Greg Claytonaf247d72011-05-19 03:54:16272 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
Sean Callananece96492010-11-08 03:49:50273 if (log)
274 {
Greg Claytonaf247d72011-05-19 03:54:16275 StreamString strm;
Greg Clayton5ccbd292011-01-06 22:15:06276 RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
Jim Ingham9da36832011-01-22 01:27:23277
278 log->PutCString(message);
279
Greg Claytonaf247d72011-05-19 03:54:16280 RegisterValue reg_value;
281
282 for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
283 reg_idx < num_registers;
284 ++reg_idx)
Sean Callananece96492010-11-08 03:49:50285 {
Greg Claytonaf247d72011-05-19 03:54:16286 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
287 if (reg_ctx->ReadRegister(reg_info, reg_value))
288 {
289 reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
290 strm.EOL();
291 }
Sean Callananece96492010-11-08 03:49:50292 }
Greg Claytonaf247d72011-05-19 03:54:16293 log->PutCString(strm.GetData());
Sean Callananece96492010-11-08 03:49:50294 }
Sean Callanan10af7c42010-11-04 01:51:38295}
296
297void
298ThreadPlanCallFunction::DoTakedown ()
299{
Jim Ingham9da36832011-01-22 01:27:23300 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
301 if (!m_takedown_done)
Jim Ingham77787032011-01-20 02:03:18302 {
Greg Clayton1ac04c32012-02-21 00:09:25303 ProcessSP process_sp (m_thread.GetProcess());
304 const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
Jim Inghamef651602011-12-22 19:12:40305 if (abi && m_return_type.IsValid())
Greg Clayton70b57652011-05-15 01:25:55306 {
Sean Callanan6153c512012-04-10 18:16:59307 const bool persistent = false;
308 m_return_valobj_sp = abi->GetReturnValueObject (m_thread, m_return_type, persistent);
Greg Clayton70b57652011-05-15 01:25:55309 }
Jim Inghamef651602011-12-22 19:12:40310
Jim Ingham9da36832011-01-22 01:27:23311 if (log)
Greg Clayton81c22f62011-10-19 18:09:39312 log->Printf ("DoTakedown called for thread 0x%4.4llx, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete());
Jim Ingham9da36832011-01-22 01:27:23313 m_takedown_done = true;
Jim Inghamce553d82011-11-01 02:46:54314 m_stop_address = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
Jim Ingham160f78c2011-05-17 01:10:11315 m_real_stop_info_sp = GetPrivateStopReason();
Jim Ingham77787032011-01-20 02:03:18316 m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state);
317 SetPlanComplete();
318 ClearBreakpoints();
Jim Ingham9da36832011-01-22 01:27:23319 if (log && log->GetVerbose())
320 ReportRegisterState ("Restoring thread state after function call. Restored register state:");
Jim Ingham2c364392011-01-26 19:13:09321
Jim Ingham9da36832011-01-22 01:27:23322 }
323 else
324 {
325 if (log)
Greg Clayton81c22f62011-10-19 18:09:39326 log->Printf ("DoTakedown called as no-op for thread 0x%4.4llx, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete());
Jim Ingham77787032011-01-20 02:03:18327 }
Chris Lattner30fdc8d2010-06-08 16:52:24328}
329
330void
Jim Inghambda4e5eb2011-01-18 01:58:06331ThreadPlanCallFunction::WillPop ()
332{
Jim Ingham77787032011-01-20 02:03:18333 DoTakedown();
Jim Inghambda4e5eb2011-01-18 01:58:06334}
335
336void
Greg Clayton2a48f522011-05-14 01:50:35337ThreadPlanCallFunction::GetDescription (Stream *s, DescriptionLevel level)
Chris Lattner30fdc8d2010-06-08 16:52:24338{
Greg Clayton2a48f522011-05-14 01:50:35339 if (level == eDescriptionLevelBrief)
Chris Lattner30fdc8d2010-06-08 16:52:24340 {
341 s->Printf("Function call thread plan");
342 }
343 else
344 {
Greg Clayton1ac04c32012-02-21 00:09:25345 TargetSP target_sp (m_thread.CalculateTarget());
346 s->Printf("Thread plan to call 0x%llx", m_function_addr.GetLoadAddress(target_sp.get()));
Chris Lattner30fdc8d2010-06-08 16:52:24347 }
348}
349
350bool
351ThreadPlanCallFunction::ValidatePlan (Stream *error)
352{
353 if (!m_valid)
354 return false;
355
356 return true;
357}
358
359bool
360ThreadPlanCallFunction::PlanExplainsStop ()
Sean Callanan6db73ca2010-11-03 01:37:52361{
Jim Ingham160f78c2011-05-17 01:10:11362 m_real_stop_info_sp = GetPrivateStopReason();
363
Jim Ingham40d871f2010-10-26 00:27:45364 // If our subplan knows why we stopped, even if it's done (which would forward the question to us)
365 // we answer yes.
Enrico Granata20edcdb2011-07-19 18:03:25366 if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
Jim Ingham40d871f2010-10-26 00:27:45367 return true;
Sean Callanan3e6fedc2010-10-19 22:24:06368
Sean Callananc98aca62010-11-03 19:36:28369 // Check if the breakpoint is one of ours.
370
371 if (BreakpointsExplainStop())
372 return true;
373
Jim Ingham40d871f2010-10-26 00:27:45374 // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
375 if (!OkayToDiscard())
376 return false;
377
378 // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on.
379 // If it is not an internal breakpoint, consult OkayToDiscard.
Sean Callanan6db73ca2010-11-03 01:37:52380
Jim Ingham160f78c2011-05-17 01:10:11381 if (m_real_stop_info_sp && m_real_stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
Jim Ingham40d871f2010-10-26 00:27:45382 {
Greg Clayton1ac04c32012-02-21 00:09:25383 ProcessSP process_sp (m_thread.CalculateProcess());
Jim Ingham160f78c2011-05-17 01:10:11384 uint64_t break_site_id = m_real_stop_info_sp->GetValue();
Greg Clayton1ac04c32012-02-21 00:09:25385 BreakpointSiteSP bp_site_sp;
386 if (process_sp)
387 bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
Jim Ingham40d871f2010-10-26 00:27:45388 if (bp_site_sp)
389 {
390 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
391 bool is_internal = true;
392 for (uint32_t i = 0; i < num_owners; i++)
393 {
Sean Callanan6db73ca2010-11-03 01:37:52394 Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
Sean Callanan6db73ca2010-11-03 01:37:52395
396 if (!bp.IsInternal())
Jim Ingham40d871f2010-10-26 00:27:45397 {
398 is_internal = false;
399 break;
400 }
401 }
402 if (is_internal)
403 return false;
404 }
405
406 return OkayToDiscard();
407 }
408 else
409 {
410 // If the subplan is running, any crashes are attributable to us.
Jim Ingham2c364392011-01-26 19:13:09411 // If we want to discard the plan, then we say we explain the stop
412 // but if we are going to be discarded, let whoever is above us
413 // explain the stop.
414 return ((m_subplan_sp.get() != NULL) && !OkayToDiscard());
Jim Ingham40d871f2010-10-26 00:27:45415 }
Chris Lattner30fdc8d2010-06-08 16:52:24416}
417
418bool
419ThreadPlanCallFunction::ShouldStop (Event *event_ptr)
420{
421 if (PlanExplainsStop())
422 {
Jim Ingham9da36832011-01-22 01:27:23423 ReportRegisterState ("Function completed. Register state was:");
Sean Callanan5300d372010-07-31 01:32:05424
Sean Callanan10af7c42010-11-04 01:51:38425 DoTakedown();
Sean Callanan6db73ca2010-11-03 01:37:52426
Chris Lattner30fdc8d2010-06-08 16:52:24427 return true;
428 }
429 else
430 {
431 return false;
432 }
433}
434
435bool
436ThreadPlanCallFunction::StopOthers ()
437{
438 return m_stop_other_threads;
439}
440
441void
442ThreadPlanCallFunction::SetStopOthers (bool new_value)
443{
444 if (m_subplan_sp)
445 {
446 ThreadPlanRunToAddress *address_plan = static_cast<ThreadPlanRunToAddress *>(m_subplan_sp.get());
447 address_plan->SetStopOthers(new_value);
448 }
449 m_stop_other_threads = new_value;
450}
451
452StateType
Jim Ingham06e827c2010-11-11 19:26:09453ThreadPlanCallFunction::GetPlanRunState ()
Chris Lattner30fdc8d2010-06-08 16:52:24454{
455 return eStateRunning;
456}
457
458void
459ThreadPlanCallFunction::DidPush ()
460{
Sean Callananbe3a1b12010-10-26 00:31:56461//#define SINGLE_STEP_EXPRESSIONS
462
463#ifndef SINGLE_STEP_EXPRESSIONS
Chris Lattner30fdc8d2010-06-08 16:52:24464 m_subplan_sp.reset(new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
465
466 m_thread.QueueThreadPlan(m_subplan_sp, false);
Jim Ingham77787032011-01-20 02:03:18467 m_subplan_sp->SetPrivate (true);
Sean Callananbe3a1b12010-10-26 00:31:56468#endif
Chris Lattner30fdc8d2010-06-08 16:52:24469}
470
471bool
472ThreadPlanCallFunction::WillStop ()
473{
474 return true;
475}
476
477bool
478ThreadPlanCallFunction::MischiefManaged ()
479{
480 if (IsPlanComplete())
481 {
Greg Clayton2d4edfb2010-11-06 01:53:30482 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner30fdc8d2010-06-08 16:52:24483
484 if (log)
485 log->Printf("Completed call function plan.");
486
487 ThreadPlan::MischiefManaged ();
488 return true;
489 }
490 else
491 {
492 return false;
493 }
494}
Sean Callanan6db73ca2010-11-03 01:37:52495
496void
497ThreadPlanCallFunction::SetBreakpoints ()
498{
Greg Clayton1ac04c32012-02-21 00:09:25499 ProcessSP process_sp (m_thread.CalculateProcess());
500 if (process_sp)
501 {
502 m_cxx_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeC_plus_plus);
503 m_objc_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeObjC);
Sean Callanan6db73ca2010-11-03 01:37:52504
Greg Clayton1ac04c32012-02-21 00:09:25505 if (m_cxx_language_runtime)
506 m_cxx_language_runtime->SetExceptionBreakpoints();
507 if (m_objc_language_runtime)
508 m_objc_language_runtime->SetExceptionBreakpoints();
509 }
Sean Callanan6db73ca2010-11-03 01:37:52510}
511
512void
513ThreadPlanCallFunction::ClearBreakpoints ()
514{
Sean Callananf2115102010-11-03 22:19:38515 if (m_cxx_language_runtime)
516 m_cxx_language_runtime->ClearExceptionBreakpoints();
517 if (m_objc_language_runtime)
518 m_objc_language_runtime->ClearExceptionBreakpoints();
Sean Callanan6db73ca2010-11-03 01:37:52519}
Sean Callananc98aca62010-11-03 19:36:28520
521bool
522ThreadPlanCallFunction::BreakpointsExplainStop()
523{
Greg Clayton2a48f522011-05-14 01:50:35524 StopInfoSP stop_info_sp = GetPrivateStopReason();
Sean Callananc98aca62010-11-03 19:36:28525
Sean Callananf2115102010-11-03 22:19:38526 if (m_cxx_language_runtime &&
527 m_cxx_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
528 return true;
Sean Callananc98aca62010-11-03 19:36:28529
Sean Callananf2115102010-11-03 22:19:38530 if (m_objc_language_runtime &&
531 m_objc_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
532 return true;
Sean Callananc98aca62010-11-03 19:36:28533
534 return false;
535}