blob: a5180613f9e0105940f5f9855f317300c707f2d7 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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 Callanan07f3d8d2010-11-03 01:37:52 +000015#include "llvm/Support/MachO.h"
Chris Lattner24943d22010-06-08 16:52:24 +000016// Project includes
17#include "lldb/lldb-private-log.h"
Jim Ingham988ddbc2010-10-26 00:27:45 +000018#include "lldb/Breakpoint/Breakpoint.h"
19#include "lldb/Breakpoint/BreakpointLocation.h"
Chris Lattner24943d22010-06-08 16:52:24 +000020#include "lldb/Core/Address.h"
21#include "lldb/Core/Log.h"
22#include "lldb/Core/Stream.h"
Sean Callanan29756d42010-11-03 22:19:38 +000023#include "lldb/Target/LanguageRuntime.h"
Chris Lattner24943d22010-06-08 16:52:24 +000024#include "lldb/Target/Process.h"
25#include "lldb/Target/RegisterContext.h"
Jim Ingham988ddbc2010-10-26 00:27:45 +000026#include "lldb/Target/StopInfo.h"
Chris Lattner24943d22010-06-08 16:52:24 +000027#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 Ingham016ef882011-12-22 19:12:40 +000040 const ClangASTType &return_type,
Greg Clayton989816b2011-05-14 01:50:35 +000041 addr_t arg,
Chris Lattner24943d22010-06-08 16:52:24 +000042 bool stop_other_threads,
Sean Callanan3c9c5eb2010-09-21 00:44:12 +000043 bool discard_on_error,
Greg Clayton989816b2011-05-14 01:50:35 +000044 addr_t *this_arg,
45 addr_t *cmd_arg) :
Jim Ingham5a47e8b2010-06-19 04:45:32 +000046 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
Benjamin Kramer36a08102010-07-16 12:32:33 +000047 m_valid (false),
48 m_stop_other_threads (stop_other_threads),
Jim Ingham574c3d62011-08-12 23:34:31 +000049 m_function_addr (function),
Peter Collingbourneabb53e52011-06-03 20:41:09 +000050 m_function_sp (NULL),
Jim Ingham016ef882011-12-22 19:12:40 +000051 m_return_type (return_type),
Jim Inghamba560cc2011-11-01 02:46:54 +000052 m_takedown_done (false),
53 m_stop_address (LLDB_INVALID_ADDRESS)
Chris Lattner24943d22010-06-08 16:52:24 +000054{
Chris Lattner24943d22010-06-08 16:52:24 +000055 SetOkayToDiscard (discard_on_error);
56
57 Process& process = thread.GetProcess();
58 Target& target = process.GetTarget();
Greg Clayton75906e42011-05-11 18:39:18 +000059 const ABI *abi = process.GetABI().get();
Sean Callanan07f3d8d2010-11-03 01:37:52 +000060
Chris Lattner24943d22010-06-08 16:52:24 +000061 if (!abi)
62 return;
Sean Callanan07f3d8d2010-11-03 01:37:52 +000063
Jim Ingham15dcb7c2011-01-20 02:03:18 +000064 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
65
Sean Callanan07f3d8d2010-11-03 01:37:52 +000066 SetBreakpoints();
67
Sean Callanan0ddf8062011-05-09 22:04:36 +000068 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
Chris Lattner24943d22010-06-08 16:52:24 +000069
Greg Clayton5beb99d2011-08-11 02:48:45 +000070 Module *exe_module = target.GetExecutableModulePointer();
Chris Lattner24943d22010-06-08 16:52:24 +000071
Greg Clayton5beb99d2011-08-11 02:48:45 +000072 if (exe_module == NULL)
Jim Ingham28775942011-03-07 23:44:08 +000073 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000074 if (log)
75 log->Printf ("Can't execute code without an executable module.");
Chris Lattner24943d22010-06-08 16:52:24 +000076 return;
Jim Ingham28775942011-03-07 23:44:08 +000077 }
78 else
79 {
Greg Clayton5beb99d2011-08-11 02:48:45 +000080 ObjectFile *objectFile = exe_module->GetObjectFile();
Jim Ingham28775942011-03-07 23:44:08 +000081 if (!objectFile)
82 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000083 if (log)
84 log->Printf ("Could not find object file for module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +000085 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham28775942011-03-07 23:44:08 +000086 return;
87 }
88 m_start_addr = objectFile->GetEntryPointAddress();
89 if (!m_start_addr.IsValid())
90 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000091 if (log)
92 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +000093 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham28775942011-03-07 23:44:08 +000094 return;
95 }
96 }
Chris Lattner24943d22010-06-08 16:52:24 +000097
Greg Clayton989816b2011-05-14 01:50:35 +000098 addr_t start_load_addr = m_start_addr.GetLoadAddress(&target);
Jim Ingham28775942011-03-07 23:44:08 +000099
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000100 // Checkpoint the thread state so we can restore it later.
Jim Ingham2f6267f2011-01-22 01:27:23 +0000101 if (log && log->GetVerbose())
102 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
103
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000104 if (!thread.CheckpointThreadState (m_stored_thread_state))
105 {
106 if (log)
107 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
Chris Lattner24943d22010-06-08 16:52:24 +0000108 return;
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000109 }
110 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
111 thread.SetStopInfoToNothing();
112
Greg Clayton989816b2011-05-14 01:50:35 +0000113 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
Chris Lattner24943d22010-06-08 16:52:24 +0000114
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000115 if (this_arg && cmd_arg)
116 {
117 if (!abi->PrepareTrivialCall (thread,
118 m_function_sp,
119 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000120 start_load_addr,
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000121 this_arg,
122 cmd_arg,
Greg Clayton989816b2011-05-14 01:50:35 +0000123 &arg))
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000124 return;
125 }
126 else if (this_arg)
127 {
128 if (!abi->PrepareTrivialCall (thread,
129 m_function_sp,
130 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000131 start_load_addr,
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000132 this_arg,
Greg Clayton989816b2011-05-14 01:50:35 +0000133 &arg))
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000134 return;
135 }
136 else
137 {
138 if (!abi->PrepareTrivialCall (thread,
139 m_function_sp,
140 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000141 start_load_addr,
142 &arg))
143 return;
144 }
145
146 ReportRegisterState ("Function call was set up. Register state was:");
147
148 m_valid = true;
149}
150
151
152ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
153 Address &function,
Jim Ingham016ef882011-12-22 19:12:40 +0000154 const ClangASTType &return_type,
Greg Clayton989816b2011-05-14 01:50:35 +0000155 bool stop_other_threads,
156 bool discard_on_error,
157 addr_t *arg1_ptr,
158 addr_t *arg2_ptr,
159 addr_t *arg3_ptr,
160 addr_t *arg4_ptr,
161 addr_t *arg5_ptr,
162 addr_t *arg6_ptr) :
163 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
164 m_valid (false),
165 m_stop_other_threads (stop_other_threads),
Jim Ingham574c3d62011-08-12 23:34:31 +0000166 m_function_addr (function),
Peter Collingbourneabb53e52011-06-03 20:41:09 +0000167 m_function_sp(NULL),
Jim Ingham016ef882011-12-22 19:12:40 +0000168 m_return_type (return_type),
Peter Collingbourneabb53e52011-06-03 20:41:09 +0000169 m_takedown_done (false)
Greg Clayton989816b2011-05-14 01:50:35 +0000170{
171 SetOkayToDiscard (discard_on_error);
172
173 Process& process = thread.GetProcess();
174 Target& target = process.GetTarget();
175 const ABI *abi = process.GetABI().get();
176
177 if (!abi)
178 return;
179
180 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
181
182 SetBreakpoints();
183
184 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
185
Greg Clayton5beb99d2011-08-11 02:48:45 +0000186 Module *exe_module = target.GetExecutableModulePointer();
Greg Clayton989816b2011-05-14 01:50:35 +0000187
Greg Clayton5beb99d2011-08-11 02:48:45 +0000188 if (exe_module == NULL)
Greg Clayton989816b2011-05-14 01:50:35 +0000189 {
Johnny Chen9d56ba92011-08-10 17:58:11 +0000190 if (log)
191 log->Printf ("Can't execute code without an executable module.");
Greg Clayton989816b2011-05-14 01:50:35 +0000192 return;
193 }
194 else
195 {
Greg Clayton5beb99d2011-08-11 02:48:45 +0000196 ObjectFile *objectFile = exe_module->GetObjectFile();
Greg Clayton989816b2011-05-14 01:50:35 +0000197 if (!objectFile)
198 {
Johnny Chen9d56ba92011-08-10 17:58:11 +0000199 if (log)
200 log->Printf ("Could not find object file for module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +0000201 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton989816b2011-05-14 01:50:35 +0000202 return;
203 }
204 m_start_addr = objectFile->GetEntryPointAddress();
205 if (!m_start_addr.IsValid())
206 {
Greg Clayton628cead2011-05-19 03:54:16 +0000207 if (log)
208 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Clayton5beb99d2011-08-11 02:48:45 +0000209 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton989816b2011-05-14 01:50:35 +0000210 return;
211 }
212 }
213
214 addr_t start_load_addr = m_start_addr.GetLoadAddress(&target);
215
216 // Checkpoint the thread state so we can restore it later.
217 if (log && log->GetVerbose())
218 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
219
220 if (!thread.CheckpointThreadState (m_stored_thread_state))
221 {
222 if (log)
223 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
224 return;
225 }
226 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
227 thread.SetStopInfoToNothing();
228
Greg Clayton989816b2011-05-14 01:50:35 +0000229 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
230
231 if (!abi->PrepareTrivialCall (thread,
232 m_function_sp,
233 FunctionLoadAddr,
234 start_load_addr,
235 arg1_ptr,
236 arg2_ptr,
237 arg3_ptr,
238 arg4_ptr,
239 arg5_ptr,
240 arg6_ptr))
241 {
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000242 return;
243 }
Chris Lattner24943d22010-06-08 16:52:24 +0000244
Jim Ingham2f6267f2011-01-22 01:27:23 +0000245 ReportRegisterState ("Function call was set up. Register state was:");
246
247 m_valid = true;
248}
249
250ThreadPlanCallFunction::~ThreadPlanCallFunction ()
251{
252}
253
254void
255ThreadPlanCallFunction::ReportRegisterState (const char *message)
256{
Greg Clayton628cead2011-05-19 03:54:16 +0000257 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
Sean Callanan6dff8272010-11-08 03:49:50 +0000258 if (log)
259 {
Greg Clayton628cead2011-05-19 03:54:16 +0000260 StreamString strm;
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000261 RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
Jim Ingham2f6267f2011-01-22 01:27:23 +0000262
263 log->PutCString(message);
264
Greg Clayton628cead2011-05-19 03:54:16 +0000265 RegisterValue reg_value;
266
267 for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
268 reg_idx < num_registers;
269 ++reg_idx)
Sean Callanan6dff8272010-11-08 03:49:50 +0000270 {
Greg Clayton628cead2011-05-19 03:54:16 +0000271 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
272 if (reg_ctx->ReadRegister(reg_info, reg_value))
273 {
274 reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
275 strm.EOL();
276 }
Sean Callanan6dff8272010-11-08 03:49:50 +0000277 }
Greg Clayton628cead2011-05-19 03:54:16 +0000278 log->PutCString(strm.GetData());
Sean Callanan6dff8272010-11-08 03:49:50 +0000279 }
Sean Callanan14a97ff2010-11-04 01:51:38 +0000280}
281
282void
283ThreadPlanCallFunction::DoTakedown ()
284{
Jim Ingham2f6267f2011-01-22 01:27:23 +0000285 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
286 if (!m_takedown_done)
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000287 {
Jim Ingham016ef882011-12-22 19:12:40 +0000288 const ABI *abi = m_thread.GetProcess().GetABI().get();
289 if (abi && m_return_type.IsValid())
Greg Clayton2f085c62011-05-15 01:25:55 +0000290 {
Jim Ingham016ef882011-12-22 19:12:40 +0000291 m_return_valobj_sp = abi->GetReturnValueObject (m_thread, m_return_type);
Greg Clayton2f085c62011-05-15 01:25:55 +0000292 }
Jim Ingham016ef882011-12-22 19:12:40 +0000293
Jim Ingham2f6267f2011-01-22 01:27:23 +0000294 if (log)
Greg Clayton444e35b2011-10-19 18:09:39 +0000295 log->Printf ("DoTakedown called for thread 0x%4.4llx, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete());
Jim Ingham2f6267f2011-01-22 01:27:23 +0000296 m_takedown_done = true;
Jim Inghamba560cc2011-11-01 02:46:54 +0000297 m_stop_address = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
Jim Ingham2370a972011-05-17 01:10:11 +0000298 m_real_stop_info_sp = GetPrivateStopReason();
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000299 m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state);
300 SetPlanComplete();
301 ClearBreakpoints();
Jim Ingham2f6267f2011-01-22 01:27:23 +0000302 if (log && log->GetVerbose())
303 ReportRegisterState ("Restoring thread state after function call. Restored register state:");
Jim Ingham78108e62011-01-26 19:13:09 +0000304
Jim Ingham2f6267f2011-01-22 01:27:23 +0000305 }
306 else
307 {
308 if (log)
Greg Clayton444e35b2011-10-19 18:09:39 +0000309 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 Ingham15dcb7c2011-01-20 02:03:18 +0000310 }
Chris Lattner24943d22010-06-08 16:52:24 +0000311}
312
313void
Jim Ingham6c9662e2011-01-18 01:58:06 +0000314ThreadPlanCallFunction::WillPop ()
315{
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000316 DoTakedown();
Jim Ingham6c9662e2011-01-18 01:58:06 +0000317}
318
319void
Greg Clayton989816b2011-05-14 01:50:35 +0000320ThreadPlanCallFunction::GetDescription (Stream *s, DescriptionLevel level)
Chris Lattner24943d22010-06-08 16:52:24 +0000321{
Greg Clayton989816b2011-05-14 01:50:35 +0000322 if (level == eDescriptionLevelBrief)
Chris Lattner24943d22010-06-08 16:52:24 +0000323 {
324 s->Printf("Function call thread plan");
325 }
326 else
327 {
Jim Inghamba560cc2011-11-01 02:46:54 +0000328 s->Printf("Thread plan to call 0x%llx", m_function_addr.GetLoadAddress(&m_thread.GetProcess().GetTarget()));
Chris Lattner24943d22010-06-08 16:52:24 +0000329 }
330}
331
332bool
333ThreadPlanCallFunction::ValidatePlan (Stream *error)
334{
335 if (!m_valid)
336 return false;
337
338 return true;
339}
340
341bool
342ThreadPlanCallFunction::PlanExplainsStop ()
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000343{
Jim Ingham2370a972011-05-17 01:10:11 +0000344 m_real_stop_info_sp = GetPrivateStopReason();
345
Jim Ingham988ddbc2010-10-26 00:27:45 +0000346 // If our subplan knows why we stopped, even if it's done (which would forward the question to us)
347 // we answer yes.
Enrico Granata4c3fb4b2011-07-19 18:03:25 +0000348 if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
Jim Ingham988ddbc2010-10-26 00:27:45 +0000349 return true;
Sean Callananba8547d2010-10-19 22:24:06 +0000350
Sean Callanan94fb5432010-11-03 19:36:28 +0000351 // Check if the breakpoint is one of ours.
352
353 if (BreakpointsExplainStop())
354 return true;
355
Jim Ingham988ddbc2010-10-26 00:27:45 +0000356 // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
357 if (!OkayToDiscard())
358 return false;
359
360 // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on.
361 // If it is not an internal breakpoint, consult OkayToDiscard.
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000362
Jim Ingham2370a972011-05-17 01:10:11 +0000363 if (m_real_stop_info_sp && m_real_stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
Jim Ingham988ddbc2010-10-26 00:27:45 +0000364 {
Jim Ingham2370a972011-05-17 01:10:11 +0000365 uint64_t break_site_id = m_real_stop_info_sp->GetValue();
Greg Clayton989816b2011-05-14 01:50:35 +0000366 BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id);
Jim Ingham988ddbc2010-10-26 00:27:45 +0000367 if (bp_site_sp)
368 {
369 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
370 bool is_internal = true;
371 for (uint32_t i = 0; i < num_owners; i++)
372 {
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000373 Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000374
375 if (!bp.IsInternal())
Jim Ingham988ddbc2010-10-26 00:27:45 +0000376 {
377 is_internal = false;
378 break;
379 }
380 }
381 if (is_internal)
382 return false;
383 }
384
385 return OkayToDiscard();
386 }
387 else
388 {
389 // If the subplan is running, any crashes are attributable to us.
Jim Ingham78108e62011-01-26 19:13:09 +0000390 // If we want to discard the plan, then we say we explain the stop
391 // but if we are going to be discarded, let whoever is above us
392 // explain the stop.
393 return ((m_subplan_sp.get() != NULL) && !OkayToDiscard());
Jim Ingham988ddbc2010-10-26 00:27:45 +0000394 }
Chris Lattner24943d22010-06-08 16:52:24 +0000395}
396
397bool
398ThreadPlanCallFunction::ShouldStop (Event *event_ptr)
399{
400 if (PlanExplainsStop())
401 {
Jim Ingham2f6267f2011-01-22 01:27:23 +0000402 ReportRegisterState ("Function completed. Register state was:");
Sean Callananf5857a02010-07-31 01:32:05 +0000403
Sean Callanan14a97ff2010-11-04 01:51:38 +0000404 DoTakedown();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000405
Chris Lattner24943d22010-06-08 16:52:24 +0000406 return true;
407 }
408 else
409 {
410 return false;
411 }
412}
413
414bool
415ThreadPlanCallFunction::StopOthers ()
416{
417 return m_stop_other_threads;
418}
419
420void
421ThreadPlanCallFunction::SetStopOthers (bool new_value)
422{
423 if (m_subplan_sp)
424 {
425 ThreadPlanRunToAddress *address_plan = static_cast<ThreadPlanRunToAddress *>(m_subplan_sp.get());
426 address_plan->SetStopOthers(new_value);
427 }
428 m_stop_other_threads = new_value;
429}
430
431StateType
Jim Ingham745ac7a2010-11-11 19:26:09 +0000432ThreadPlanCallFunction::GetPlanRunState ()
Chris Lattner24943d22010-06-08 16:52:24 +0000433{
434 return eStateRunning;
435}
436
437void
438ThreadPlanCallFunction::DidPush ()
439{
Sean Callananc2c6f772010-10-26 00:31:56 +0000440//#define SINGLE_STEP_EXPRESSIONS
441
442#ifndef SINGLE_STEP_EXPRESSIONS
Chris Lattner24943d22010-06-08 16:52:24 +0000443 m_subplan_sp.reset(new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
444
445 m_thread.QueueThreadPlan(m_subplan_sp, false);
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000446 m_subplan_sp->SetPrivate (true);
Sean Callananc2c6f772010-10-26 00:31:56 +0000447#endif
Chris Lattner24943d22010-06-08 16:52:24 +0000448}
449
450bool
451ThreadPlanCallFunction::WillStop ()
452{
453 return true;
454}
455
456bool
457ThreadPlanCallFunction::MischiefManaged ()
458{
459 if (IsPlanComplete())
460 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000461 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner24943d22010-06-08 16:52:24 +0000462
463 if (log)
464 log->Printf("Completed call function plan.");
465
466 ThreadPlan::MischiefManaged ();
467 return true;
468 }
469 else
470 {
471 return false;
472 }
473}
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000474
475void
476ThreadPlanCallFunction::SetBreakpoints ()
477{
Jim Inghamba560cc2011-11-01 02:46:54 +0000478 m_cxx_language_runtime = m_thread.GetProcess().GetLanguageRuntime(eLanguageTypeC_plus_plus);
479 m_objc_language_runtime = m_thread.GetProcess().GetLanguageRuntime(eLanguageTypeObjC);
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000480
Sean Callanan29756d42010-11-03 22:19:38 +0000481 if (m_cxx_language_runtime)
482 m_cxx_language_runtime->SetExceptionBreakpoints();
483 if (m_objc_language_runtime)
484 m_objc_language_runtime->SetExceptionBreakpoints();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000485}
486
487void
488ThreadPlanCallFunction::ClearBreakpoints ()
489{
Sean Callanan29756d42010-11-03 22:19:38 +0000490 if (m_cxx_language_runtime)
491 m_cxx_language_runtime->ClearExceptionBreakpoints();
492 if (m_objc_language_runtime)
493 m_objc_language_runtime->ClearExceptionBreakpoints();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000494}
Sean Callanan94fb5432010-11-03 19:36:28 +0000495
496bool
497ThreadPlanCallFunction::BreakpointsExplainStop()
498{
Greg Clayton989816b2011-05-14 01:50:35 +0000499 StopInfoSP stop_info_sp = GetPrivateStopReason();
Sean Callanan94fb5432010-11-03 19:36:28 +0000500
Sean Callanan29756d42010-11-03 22:19:38 +0000501 if (m_cxx_language_runtime &&
502 m_cxx_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
503 return true;
Sean Callanan94fb5432010-11-03 19:36:28 +0000504
Sean Callanan29756d42010-11-03 22:19:38 +0000505 if (m_objc_language_runtime &&
506 m_objc_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
507 return true;
Sean Callanan94fb5432010-11-03 19:36:28 +0000508
509 return false;
510}