blob: a5eb4b96a067079bebfd1fffbf9edce6457e33d3 [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,
Greg Clayton989816b2011-05-14 01:50:35 +000040 addr_t arg,
Chris Lattner24943d22010-06-08 16:52:24 +000041 bool stop_other_threads,
Sean Callanan3c9c5eb2010-09-21 00:44:12 +000042 bool discard_on_error,
Greg Clayton989816b2011-05-14 01:50:35 +000043 addr_t *this_arg,
44 addr_t *cmd_arg) :
Jim Ingham5a47e8b2010-06-19 04:45:32 +000045 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
Benjamin Kramer36a08102010-07-16 12:32:33 +000046 m_valid (false),
47 m_stop_other_threads (stop_other_threads),
Jim Ingham574c3d62011-08-12 23:34:31 +000048 m_function_addr (function),
Peter Collingbourneabb53e52011-06-03 20:41:09 +000049 m_function_sp (NULL),
Benjamin Kramer36a08102010-07-16 12:32:33 +000050 m_process (thread.GetProcess()),
Jim Ingham2f6267f2011-01-22 01:27:23 +000051 m_thread (thread),
Peter Collingbourneabb53e52011-06-03 20:41:09 +000052 m_takedown_done (false)
Chris Lattner24943d22010-06-08 16:52:24 +000053{
Chris Lattner24943d22010-06-08 16:52:24 +000054 SetOkayToDiscard (discard_on_error);
55
56 Process& process = thread.GetProcess();
57 Target& target = process.GetTarget();
Greg Clayton75906e42011-05-11 18:39:18 +000058 const ABI *abi = process.GetABI().get();
Sean Callanan07f3d8d2010-11-03 01:37:52 +000059
Chris Lattner24943d22010-06-08 16:52:24 +000060 if (!abi)
61 return;
Sean Callanan07f3d8d2010-11-03 01:37:52 +000062
Jim Ingham15dcb7c2011-01-20 02:03:18 +000063 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
64
Sean Callanan07f3d8d2010-11-03 01:37:52 +000065 SetBreakpoints();
66
Sean Callanan0ddf8062011-05-09 22:04:36 +000067 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
Chris Lattner24943d22010-06-08 16:52:24 +000068
Greg Clayton5beb99d2011-08-11 02:48:45 +000069 Module *exe_module = target.GetExecutableModulePointer();
Chris Lattner24943d22010-06-08 16:52:24 +000070
Greg Clayton5beb99d2011-08-11 02:48:45 +000071 if (exe_module == NULL)
Jim Ingham28775942011-03-07 23:44:08 +000072 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000073 if (log)
74 log->Printf ("Can't execute code without an executable module.");
Chris Lattner24943d22010-06-08 16:52:24 +000075 return;
Jim Ingham28775942011-03-07 23:44:08 +000076 }
77 else
78 {
Greg Clayton5beb99d2011-08-11 02:48:45 +000079 ObjectFile *objectFile = exe_module->GetObjectFile();
Jim Ingham28775942011-03-07 23:44:08 +000080 if (!objectFile)
81 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000082 if (log)
83 log->Printf ("Could not find object file for module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +000084 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham28775942011-03-07 23:44:08 +000085 return;
86 }
87 m_start_addr = objectFile->GetEntryPointAddress();
88 if (!m_start_addr.IsValid())
89 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000090 if (log)
91 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +000092 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham28775942011-03-07 23:44:08 +000093 return;
94 }
95 }
Chris Lattner24943d22010-06-08 16:52:24 +000096
Greg Clayton989816b2011-05-14 01:50:35 +000097 addr_t start_load_addr = m_start_addr.GetLoadAddress(&target);
Jim Ingham28775942011-03-07 23:44:08 +000098
Jim Ingham15dcb7c2011-01-20 02:03:18 +000099 // Checkpoint the thread state so we can restore it later.
Jim Ingham2f6267f2011-01-22 01:27:23 +0000100 if (log && log->GetVerbose())
101 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
102
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000103 if (!thread.CheckpointThreadState (m_stored_thread_state))
104 {
105 if (log)
106 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
Chris Lattner24943d22010-06-08 16:52:24 +0000107 return;
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000108 }
109 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
110 thread.SetStopInfoToNothing();
111
Greg Clayton989816b2011-05-14 01:50:35 +0000112 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
Chris Lattner24943d22010-06-08 16:52:24 +0000113
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000114 if (this_arg && cmd_arg)
115 {
116 if (!abi->PrepareTrivialCall (thread,
117 m_function_sp,
118 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000119 start_load_addr,
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000120 this_arg,
121 cmd_arg,
Greg Clayton989816b2011-05-14 01:50:35 +0000122 &arg))
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000123 return;
124 }
125 else if (this_arg)
126 {
127 if (!abi->PrepareTrivialCall (thread,
128 m_function_sp,
129 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000130 start_load_addr,
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000131 this_arg,
Greg Clayton989816b2011-05-14 01:50:35 +0000132 &arg))
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000133 return;
134 }
135 else
136 {
137 if (!abi->PrepareTrivialCall (thread,
138 m_function_sp,
139 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000140 start_load_addr,
141 &arg))
142 return;
143 }
144
145 ReportRegisterState ("Function call was set up. Register state was:");
146
147 m_valid = true;
148}
149
150
151ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
152 Address &function,
153 bool stop_other_threads,
154 bool discard_on_error,
155 addr_t *arg1_ptr,
156 addr_t *arg2_ptr,
157 addr_t *arg3_ptr,
158 addr_t *arg4_ptr,
159 addr_t *arg5_ptr,
160 addr_t *arg6_ptr) :
161 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
162 m_valid (false),
163 m_stop_other_threads (stop_other_threads),
Jim Ingham574c3d62011-08-12 23:34:31 +0000164 m_function_addr (function),
Peter Collingbourneabb53e52011-06-03 20:41:09 +0000165 m_function_sp(NULL),
Greg Clayton989816b2011-05-14 01:50:35 +0000166 m_process (thread.GetProcess()),
167 m_thread (thread),
Peter Collingbourneabb53e52011-06-03 20:41:09 +0000168 m_takedown_done (false)
Greg Clayton989816b2011-05-14 01:50:35 +0000169{
170 SetOkayToDiscard (discard_on_error);
171
172 Process& process = thread.GetProcess();
173 Target& target = process.GetTarget();
174 const ABI *abi = process.GetABI().get();
175
176 if (!abi)
177 return;
178
179 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
180
181 SetBreakpoints();
182
183 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
184
Greg Clayton5beb99d2011-08-11 02:48:45 +0000185 Module *exe_module = target.GetExecutableModulePointer();
Greg Clayton989816b2011-05-14 01:50:35 +0000186
Greg Clayton5beb99d2011-08-11 02:48:45 +0000187 if (exe_module == NULL)
Greg Clayton989816b2011-05-14 01:50:35 +0000188 {
Johnny Chen9d56ba92011-08-10 17:58:11 +0000189 if (log)
190 log->Printf ("Can't execute code without an executable module.");
Greg Clayton989816b2011-05-14 01:50:35 +0000191 return;
192 }
193 else
194 {
Greg Clayton5beb99d2011-08-11 02:48:45 +0000195 ObjectFile *objectFile = exe_module->GetObjectFile();
Greg Clayton989816b2011-05-14 01:50:35 +0000196 if (!objectFile)
197 {
Johnny Chen9d56ba92011-08-10 17:58:11 +0000198 if (log)
199 log->Printf ("Could not find object file for module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +0000200 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton989816b2011-05-14 01:50:35 +0000201 return;
202 }
203 m_start_addr = objectFile->GetEntryPointAddress();
204 if (!m_start_addr.IsValid())
205 {
Greg Clayton628cead2011-05-19 03:54:16 +0000206 if (log)
207 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Clayton5beb99d2011-08-11 02:48:45 +0000208 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton989816b2011-05-14 01:50:35 +0000209 return;
210 }
211 }
212
213 addr_t start_load_addr = m_start_addr.GetLoadAddress(&target);
214
215 // Checkpoint the thread state so we can restore it later.
216 if (log && log->GetVerbose())
217 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
218
219 if (!thread.CheckpointThreadState (m_stored_thread_state))
220 {
221 if (log)
222 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
223 return;
224 }
225 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
226 thread.SetStopInfoToNothing();
227
Greg Clayton989816b2011-05-14 01:50:35 +0000228 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
229
230 if (!abi->PrepareTrivialCall (thread,
231 m_function_sp,
232 FunctionLoadAddr,
233 start_load_addr,
234 arg1_ptr,
235 arg2_ptr,
236 arg3_ptr,
237 arg4_ptr,
238 arg5_ptr,
239 arg6_ptr))
240 {
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000241 return;
242 }
Chris Lattner24943d22010-06-08 16:52:24 +0000243
Jim Ingham2f6267f2011-01-22 01:27:23 +0000244 ReportRegisterState ("Function call was set up. Register state was:");
245
246 m_valid = true;
247}
248
249ThreadPlanCallFunction::~ThreadPlanCallFunction ()
250{
251}
252
253void
254ThreadPlanCallFunction::ReportRegisterState (const char *message)
255{
Greg Clayton628cead2011-05-19 03:54:16 +0000256 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
Sean Callanan6dff8272010-11-08 03:49:50 +0000257 if (log)
258 {
Greg Clayton628cead2011-05-19 03:54:16 +0000259 StreamString strm;
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000260 RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
Jim Ingham2f6267f2011-01-22 01:27:23 +0000261
262 log->PutCString(message);
263
Greg Clayton628cead2011-05-19 03:54:16 +0000264 RegisterValue reg_value;
265
266 for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
267 reg_idx < num_registers;
268 ++reg_idx)
Sean Callanan6dff8272010-11-08 03:49:50 +0000269 {
Greg Clayton628cead2011-05-19 03:54:16 +0000270 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
271 if (reg_ctx->ReadRegister(reg_info, reg_value))
272 {
273 reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
274 strm.EOL();
275 }
Sean Callanan6dff8272010-11-08 03:49:50 +0000276 }
Greg Clayton628cead2011-05-19 03:54:16 +0000277 log->PutCString(strm.GetData());
Sean Callanan6dff8272010-11-08 03:49:50 +0000278 }
Sean Callanan14a97ff2010-11-04 01:51:38 +0000279}
280
281void
282ThreadPlanCallFunction::DoTakedown ()
283{
Jim Ingham2f6267f2011-01-22 01:27:23 +0000284 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
285 if (!m_takedown_done)
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000286 {
Greg Clayton2f085c62011-05-15 01:25:55 +0000287 // TODO: how do we tell if all went well?
288 if (m_return_value_sp)
289 {
290 const ABI *abi = m_thread.GetProcess().GetABI().get();
291 if (abi)
292 abi->GetReturnValue(m_thread, *m_return_value_sp);
293 }
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 Ingham2370a972011-05-17 01:10:11 +0000297 m_real_stop_info_sp = GetPrivateStopReason();
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000298 m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state);
299 SetPlanComplete();
300 ClearBreakpoints();
Jim Ingham2f6267f2011-01-22 01:27:23 +0000301 if (log && log->GetVerbose())
302 ReportRegisterState ("Restoring thread state after function call. Restored register state:");
Jim Ingham78108e62011-01-26 19:13:09 +0000303
Jim Ingham2f6267f2011-01-22 01:27:23 +0000304 }
305 else
306 {
307 if (log)
Greg Clayton444e35b2011-10-19 18:09:39 +0000308 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 +0000309 }
Chris Lattner24943d22010-06-08 16:52:24 +0000310}
311
312void
Jim Ingham6c9662e2011-01-18 01:58:06 +0000313ThreadPlanCallFunction::WillPop ()
314{
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000315 DoTakedown();
Jim Ingham6c9662e2011-01-18 01:58:06 +0000316}
317
318void
Greg Clayton989816b2011-05-14 01:50:35 +0000319ThreadPlanCallFunction::GetDescription (Stream *s, DescriptionLevel level)
Chris Lattner24943d22010-06-08 16:52:24 +0000320{
Greg Clayton989816b2011-05-14 01:50:35 +0000321 if (level == eDescriptionLevelBrief)
Chris Lattner24943d22010-06-08 16:52:24 +0000322 {
323 s->Printf("Function call thread plan");
324 }
325 else
326 {
Greg Clayton989816b2011-05-14 01:50:35 +0000327 s->Printf("Thread plan to call 0x%llx", m_function_addr.GetLoadAddress(&m_process.GetTarget()));
Chris Lattner24943d22010-06-08 16:52:24 +0000328 }
329}
330
331bool
332ThreadPlanCallFunction::ValidatePlan (Stream *error)
333{
334 if (!m_valid)
335 return false;
336
337 return true;
338}
339
340bool
341ThreadPlanCallFunction::PlanExplainsStop ()
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000342{
Jim Ingham2370a972011-05-17 01:10:11 +0000343 m_real_stop_info_sp = GetPrivateStopReason();
344
Jim Ingham988ddbc2010-10-26 00:27:45 +0000345 // If our subplan knows why we stopped, even if it's done (which would forward the question to us)
346 // we answer yes.
Enrico Granata4c3fb4b2011-07-19 18:03:25 +0000347 if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
Jim Ingham988ddbc2010-10-26 00:27:45 +0000348 return true;
Sean Callananba8547d2010-10-19 22:24:06 +0000349
Sean Callanan94fb5432010-11-03 19:36:28 +0000350 // Check if the breakpoint is one of ours.
351
352 if (BreakpointsExplainStop())
353 return true;
354
Jim Ingham988ddbc2010-10-26 00:27:45 +0000355 // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
356 if (!OkayToDiscard())
357 return false;
358
359 // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on.
360 // If it is not an internal breakpoint, consult OkayToDiscard.
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000361
Jim Ingham2370a972011-05-17 01:10:11 +0000362 if (m_real_stop_info_sp && m_real_stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
Jim Ingham988ddbc2010-10-26 00:27:45 +0000363 {
Jim Ingham2370a972011-05-17 01:10:11 +0000364 uint64_t break_site_id = m_real_stop_info_sp->GetValue();
Greg Clayton989816b2011-05-14 01:50:35 +0000365 BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id);
Jim Ingham988ddbc2010-10-26 00:27:45 +0000366 if (bp_site_sp)
367 {
368 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
369 bool is_internal = true;
370 for (uint32_t i = 0; i < num_owners; i++)
371 {
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000372 Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000373
374 if (!bp.IsInternal())
Jim Ingham988ddbc2010-10-26 00:27:45 +0000375 {
376 is_internal = false;
377 break;
378 }
379 }
380 if (is_internal)
381 return false;
382 }
383
384 return OkayToDiscard();
385 }
386 else
387 {
388 // If the subplan is running, any crashes are attributable to us.
Jim Ingham78108e62011-01-26 19:13:09 +0000389 // If we want to discard the plan, then we say we explain the stop
390 // but if we are going to be discarded, let whoever is above us
391 // explain the stop.
392 return ((m_subplan_sp.get() != NULL) && !OkayToDiscard());
Jim Ingham988ddbc2010-10-26 00:27:45 +0000393 }
Chris Lattner24943d22010-06-08 16:52:24 +0000394}
395
396bool
397ThreadPlanCallFunction::ShouldStop (Event *event_ptr)
398{
399 if (PlanExplainsStop())
400 {
Jim Ingham2f6267f2011-01-22 01:27:23 +0000401 ReportRegisterState ("Function completed. Register state was:");
Sean Callananf5857a02010-07-31 01:32:05 +0000402
Sean Callanan14a97ff2010-11-04 01:51:38 +0000403 DoTakedown();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000404
Chris Lattner24943d22010-06-08 16:52:24 +0000405 return true;
406 }
407 else
408 {
409 return false;
410 }
411}
412
413bool
414ThreadPlanCallFunction::StopOthers ()
415{
416 return m_stop_other_threads;
417}
418
419void
420ThreadPlanCallFunction::SetStopOthers (bool new_value)
421{
422 if (m_subplan_sp)
423 {
424 ThreadPlanRunToAddress *address_plan = static_cast<ThreadPlanRunToAddress *>(m_subplan_sp.get());
425 address_plan->SetStopOthers(new_value);
426 }
427 m_stop_other_threads = new_value;
428}
429
430StateType
Jim Ingham745ac7a2010-11-11 19:26:09 +0000431ThreadPlanCallFunction::GetPlanRunState ()
Chris Lattner24943d22010-06-08 16:52:24 +0000432{
433 return eStateRunning;
434}
435
436void
437ThreadPlanCallFunction::DidPush ()
438{
Sean Callananc2c6f772010-10-26 00:31:56 +0000439//#define SINGLE_STEP_EXPRESSIONS
440
441#ifndef SINGLE_STEP_EXPRESSIONS
Chris Lattner24943d22010-06-08 16:52:24 +0000442 m_subplan_sp.reset(new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
443
444 m_thread.QueueThreadPlan(m_subplan_sp, false);
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000445 m_subplan_sp->SetPrivate (true);
Sean Callananc2c6f772010-10-26 00:31:56 +0000446#endif
Chris Lattner24943d22010-06-08 16:52:24 +0000447}
448
449bool
450ThreadPlanCallFunction::WillStop ()
451{
452 return true;
453}
454
455bool
456ThreadPlanCallFunction::MischiefManaged ()
457{
458 if (IsPlanComplete())
459 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000460 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner24943d22010-06-08 16:52:24 +0000461
462 if (log)
463 log->Printf("Completed call function plan.");
464
465 ThreadPlan::MischiefManaged ();
466 return true;
467 }
468 else
469 {
470 return false;
471 }
472}
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000473
474void
475ThreadPlanCallFunction::SetBreakpoints ()
476{
Sean Callanan29756d42010-11-03 22:19:38 +0000477 m_cxx_language_runtime = m_process.GetLanguageRuntime(eLanguageTypeC_plus_plus);
478 m_objc_language_runtime = m_process.GetLanguageRuntime(eLanguageTypeObjC);
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000479
Sean Callanan29756d42010-11-03 22:19:38 +0000480 if (m_cxx_language_runtime)
481 m_cxx_language_runtime->SetExceptionBreakpoints();
482 if (m_objc_language_runtime)
483 m_objc_language_runtime->SetExceptionBreakpoints();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000484}
485
486void
487ThreadPlanCallFunction::ClearBreakpoints ()
488{
Sean Callanan29756d42010-11-03 22:19:38 +0000489 if (m_cxx_language_runtime)
490 m_cxx_language_runtime->ClearExceptionBreakpoints();
491 if (m_objc_language_runtime)
492 m_objc_language_runtime->ClearExceptionBreakpoints();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000493}
Sean Callanan94fb5432010-11-03 19:36:28 +0000494
495bool
496ThreadPlanCallFunction::BreakpointsExplainStop()
497{
Greg Clayton989816b2011-05-14 01:50:35 +0000498 StopInfoSP stop_info_sp = GetPrivateStopReason();
Sean Callanan94fb5432010-11-03 19:36:28 +0000499
Sean Callanan29756d42010-11-03 22:19:38 +0000500 if (m_cxx_language_runtime &&
501 m_cxx_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
502 return true;
Sean Callanan94fb5432010-11-03 19:36:28 +0000503
Sean Callanan29756d42010-11-03 22:19:38 +0000504 if (m_objc_language_runtime &&
505 m_objc_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
506 return true;
Sean Callanan94fb5432010-11-03 19:36:28 +0000507
508 return false;
509}