blob: 2494c7cacfd233df4e851403c90427821e48059f [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),
Jim Inghamba560cc2011-11-01 02:46:54 +000050 m_takedown_done (false),
51 m_stop_address (LLDB_INVALID_ADDRESS)
Chris Lattner24943d22010-06-08 16:52:24 +000052{
Chris Lattner24943d22010-06-08 16:52:24 +000053 SetOkayToDiscard (discard_on_error);
54
55 Process& process = thread.GetProcess();
56 Target& target = process.GetTarget();
Greg Clayton75906e42011-05-11 18:39:18 +000057 const ABI *abi = process.GetABI().get();
Sean Callanan07f3d8d2010-11-03 01:37:52 +000058
Chris Lattner24943d22010-06-08 16:52:24 +000059 if (!abi)
60 return;
Sean Callanan07f3d8d2010-11-03 01:37:52 +000061
Jim Ingham15dcb7c2011-01-20 02:03:18 +000062 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
63
Sean Callanan07f3d8d2010-11-03 01:37:52 +000064 SetBreakpoints();
65
Sean Callanan0ddf8062011-05-09 22:04:36 +000066 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
Chris Lattner24943d22010-06-08 16:52:24 +000067
Greg Clayton5beb99d2011-08-11 02:48:45 +000068 Module *exe_module = target.GetExecutableModulePointer();
Chris Lattner24943d22010-06-08 16:52:24 +000069
Greg Clayton5beb99d2011-08-11 02:48:45 +000070 if (exe_module == NULL)
Jim Ingham28775942011-03-07 23:44:08 +000071 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000072 if (log)
73 log->Printf ("Can't execute code without an executable module.");
Chris Lattner24943d22010-06-08 16:52:24 +000074 return;
Jim Ingham28775942011-03-07 23:44:08 +000075 }
76 else
77 {
Greg Clayton5beb99d2011-08-11 02:48:45 +000078 ObjectFile *objectFile = exe_module->GetObjectFile();
Jim Ingham28775942011-03-07 23:44:08 +000079 if (!objectFile)
80 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000081 if (log)
82 log->Printf ("Could not find object file for module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +000083 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham28775942011-03-07 23:44:08 +000084 return;
85 }
86 m_start_addr = objectFile->GetEntryPointAddress();
87 if (!m_start_addr.IsValid())
88 {
Johnny Chen9d56ba92011-08-10 17:58:11 +000089 if (log)
90 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +000091 exe_module->GetFileSpec().GetFilename().AsCString());
Jim Ingham28775942011-03-07 23:44:08 +000092 return;
93 }
94 }
Chris Lattner24943d22010-06-08 16:52:24 +000095
Greg Clayton989816b2011-05-14 01:50:35 +000096 addr_t start_load_addr = m_start_addr.GetLoadAddress(&target);
Jim Ingham28775942011-03-07 23:44:08 +000097
Jim Ingham15dcb7c2011-01-20 02:03:18 +000098 // Checkpoint the thread state so we can restore it later.
Jim Ingham2f6267f2011-01-22 01:27:23 +000099 if (log && log->GetVerbose())
100 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
101
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000102 if (!thread.CheckpointThreadState (m_stored_thread_state))
103 {
104 if (log)
105 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
Chris Lattner24943d22010-06-08 16:52:24 +0000106 return;
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000107 }
108 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
109 thread.SetStopInfoToNothing();
110
Greg Clayton989816b2011-05-14 01:50:35 +0000111 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
Chris Lattner24943d22010-06-08 16:52:24 +0000112
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000113 if (this_arg && cmd_arg)
114 {
115 if (!abi->PrepareTrivialCall (thread,
116 m_function_sp,
117 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000118 start_load_addr,
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000119 this_arg,
120 cmd_arg,
Greg Clayton989816b2011-05-14 01:50:35 +0000121 &arg))
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000122 return;
123 }
124 else if (this_arg)
125 {
126 if (!abi->PrepareTrivialCall (thread,
127 m_function_sp,
128 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000129 start_load_addr,
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000130 this_arg,
Greg Clayton989816b2011-05-14 01:50:35 +0000131 &arg))
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000132 return;
133 }
134 else
135 {
136 if (!abi->PrepareTrivialCall (thread,
137 m_function_sp,
138 FunctionLoadAddr,
Greg Clayton989816b2011-05-14 01:50:35 +0000139 start_load_addr,
140 &arg))
141 return;
142 }
143
144 ReportRegisterState ("Function call was set up. Register state was:");
145
146 m_valid = true;
147}
148
149
150ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
151 Address &function,
152 bool stop_other_threads,
153 bool discard_on_error,
154 addr_t *arg1_ptr,
155 addr_t *arg2_ptr,
156 addr_t *arg3_ptr,
157 addr_t *arg4_ptr,
158 addr_t *arg5_ptr,
159 addr_t *arg6_ptr) :
160 ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion),
161 m_valid (false),
162 m_stop_other_threads (stop_other_threads),
Jim Ingham574c3d62011-08-12 23:34:31 +0000163 m_function_addr (function),
Peter Collingbourneabb53e52011-06-03 20:41:09 +0000164 m_function_sp(NULL),
Peter Collingbourneabb53e52011-06-03 20:41:09 +0000165 m_takedown_done (false)
Greg Clayton989816b2011-05-14 01:50:35 +0000166{
167 SetOkayToDiscard (discard_on_error);
168
169 Process& process = thread.GetProcess();
170 Target& target = process.GetTarget();
171 const ABI *abi = process.GetABI().get();
172
173 if (!abi)
174 return;
175
176 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
177
178 SetBreakpoints();
179
180 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
181
Greg Clayton5beb99d2011-08-11 02:48:45 +0000182 Module *exe_module = target.GetExecutableModulePointer();
Greg Clayton989816b2011-05-14 01:50:35 +0000183
Greg Clayton5beb99d2011-08-11 02:48:45 +0000184 if (exe_module == NULL)
Greg Clayton989816b2011-05-14 01:50:35 +0000185 {
Johnny Chen9d56ba92011-08-10 17:58:11 +0000186 if (log)
187 log->Printf ("Can't execute code without an executable module.");
Greg Clayton989816b2011-05-14 01:50:35 +0000188 return;
189 }
190 else
191 {
Greg Clayton5beb99d2011-08-11 02:48:45 +0000192 ObjectFile *objectFile = exe_module->GetObjectFile();
Greg Clayton989816b2011-05-14 01:50:35 +0000193 if (!objectFile)
194 {
Johnny Chen9d56ba92011-08-10 17:58:11 +0000195 if (log)
196 log->Printf ("Could not find object file for module \"%s\".",
Greg Claytonb01760c2011-08-11 04:30:39 +0000197 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton989816b2011-05-14 01:50:35 +0000198 return;
199 }
200 m_start_addr = objectFile->GetEntryPointAddress();
201 if (!m_start_addr.IsValid())
202 {
Greg Clayton628cead2011-05-19 03:54:16 +0000203 if (log)
204 log->Printf ("Could not find entry point address for executable module \"%s\".",
Greg Clayton5beb99d2011-08-11 02:48:45 +0000205 exe_module->GetFileSpec().GetFilename().AsCString());
Greg Clayton989816b2011-05-14 01:50:35 +0000206 return;
207 }
208 }
209
210 addr_t start_load_addr = m_start_addr.GetLoadAddress(&target);
211
212 // Checkpoint the thread state so we can restore it later.
213 if (log && log->GetVerbose())
214 ReportRegisterState ("About to checkpoint thread before function call. Original register state was:");
215
216 if (!thread.CheckpointThreadState (m_stored_thread_state))
217 {
218 if (log)
219 log->Printf ("Setting up ThreadPlanCallFunction, failed to checkpoint thread state.");
220 return;
221 }
222 // Now set the thread state to "no reason" so we don't run with whatever signal was outstanding...
223 thread.SetStopInfoToNothing();
224
Greg Clayton989816b2011-05-14 01:50:35 +0000225 addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target);
226
227 if (!abi->PrepareTrivialCall (thread,
228 m_function_sp,
229 FunctionLoadAddr,
230 start_load_addr,
231 arg1_ptr,
232 arg2_ptr,
233 arg3_ptr,
234 arg4_ptr,
235 arg5_ptr,
236 arg6_ptr))
237 {
Greg Clayton61d4f7a2011-05-12 02:14:56 +0000238 return;
239 }
Chris Lattner24943d22010-06-08 16:52:24 +0000240
Jim Ingham2f6267f2011-01-22 01:27:23 +0000241 ReportRegisterState ("Function call was set up. Register state was:");
242
243 m_valid = true;
244}
245
246ThreadPlanCallFunction::~ThreadPlanCallFunction ()
247{
248}
249
250void
251ThreadPlanCallFunction::ReportRegisterState (const char *message)
252{
Greg Clayton628cead2011-05-19 03:54:16 +0000253 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
Sean Callanan6dff8272010-11-08 03:49:50 +0000254 if (log)
255 {
Greg Clayton628cead2011-05-19 03:54:16 +0000256 StreamString strm;
Greg Clayton08d7d3a2011-01-06 22:15:06 +0000257 RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
Jim Ingham2f6267f2011-01-22 01:27:23 +0000258
259 log->PutCString(message);
260
Greg Clayton628cead2011-05-19 03:54:16 +0000261 RegisterValue reg_value;
262
263 for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
264 reg_idx < num_registers;
265 ++reg_idx)
Sean Callanan6dff8272010-11-08 03:49:50 +0000266 {
Greg Clayton628cead2011-05-19 03:54:16 +0000267 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
268 if (reg_ctx->ReadRegister(reg_info, reg_value))
269 {
270 reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
271 strm.EOL();
272 }
Sean Callanan6dff8272010-11-08 03:49:50 +0000273 }
Greg Clayton628cead2011-05-19 03:54:16 +0000274 log->PutCString(strm.GetData());
Sean Callanan6dff8272010-11-08 03:49:50 +0000275 }
Sean Callanan14a97ff2010-11-04 01:51:38 +0000276}
277
278void
279ThreadPlanCallFunction::DoTakedown ()
280{
Jim Ingham2f6267f2011-01-22 01:27:23 +0000281 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
282 if (!m_takedown_done)
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000283 {
Greg Clayton2f085c62011-05-15 01:25:55 +0000284 // TODO: how do we tell if all went well?
285 if (m_return_value_sp)
286 {
287 const ABI *abi = m_thread.GetProcess().GetABI().get();
288 if (abi)
289 abi->GetReturnValue(m_thread, *m_return_value_sp);
290 }
Jim Ingham2f6267f2011-01-22 01:27:23 +0000291 if (log)
Greg Clayton444e35b2011-10-19 18:09:39 +0000292 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 +0000293 m_takedown_done = true;
Jim Inghamba560cc2011-11-01 02:46:54 +0000294 m_stop_address = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
Jim Ingham2370a972011-05-17 01:10:11 +0000295 m_real_stop_info_sp = GetPrivateStopReason();
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000296 m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state);
297 SetPlanComplete();
298 ClearBreakpoints();
Jim Ingham2f6267f2011-01-22 01:27:23 +0000299 if (log && log->GetVerbose())
300 ReportRegisterState ("Restoring thread state after function call. Restored register state:");
Jim Ingham78108e62011-01-26 19:13:09 +0000301
Jim Ingham2f6267f2011-01-22 01:27:23 +0000302 }
303 else
304 {
305 if (log)
Greg Clayton444e35b2011-10-19 18:09:39 +0000306 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 +0000307 }
Chris Lattner24943d22010-06-08 16:52:24 +0000308}
309
310void
Jim Ingham6c9662e2011-01-18 01:58:06 +0000311ThreadPlanCallFunction::WillPop ()
312{
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000313 DoTakedown();
Jim Ingham6c9662e2011-01-18 01:58:06 +0000314}
315
316void
Greg Clayton989816b2011-05-14 01:50:35 +0000317ThreadPlanCallFunction::GetDescription (Stream *s, DescriptionLevel level)
Chris Lattner24943d22010-06-08 16:52:24 +0000318{
Greg Clayton989816b2011-05-14 01:50:35 +0000319 if (level == eDescriptionLevelBrief)
Chris Lattner24943d22010-06-08 16:52:24 +0000320 {
321 s->Printf("Function call thread plan");
322 }
323 else
324 {
Jim Inghamba560cc2011-11-01 02:46:54 +0000325 s->Printf("Thread plan to call 0x%llx", m_function_addr.GetLoadAddress(&m_thread.GetProcess().GetTarget()));
Chris Lattner24943d22010-06-08 16:52:24 +0000326 }
327}
328
329bool
330ThreadPlanCallFunction::ValidatePlan (Stream *error)
331{
332 if (!m_valid)
333 return false;
334
335 return true;
336}
337
338bool
339ThreadPlanCallFunction::PlanExplainsStop ()
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000340{
Jim Ingham2370a972011-05-17 01:10:11 +0000341 m_real_stop_info_sp = GetPrivateStopReason();
342
Jim Ingham988ddbc2010-10-26 00:27:45 +0000343 // If our subplan knows why we stopped, even if it's done (which would forward the question to us)
344 // we answer yes.
Enrico Granata4c3fb4b2011-07-19 18:03:25 +0000345 if (m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop())
Jim Ingham988ddbc2010-10-26 00:27:45 +0000346 return true;
Sean Callananba8547d2010-10-19 22:24:06 +0000347
Sean Callanan94fb5432010-11-03 19:36:28 +0000348 // Check if the breakpoint is one of ours.
349
350 if (BreakpointsExplainStop())
351 return true;
352
Jim Ingham988ddbc2010-10-26 00:27:45 +0000353 // If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
354 if (!OkayToDiscard())
355 return false;
356
357 // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on.
358 // If it is not an internal breakpoint, consult OkayToDiscard.
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000359
Jim Ingham2370a972011-05-17 01:10:11 +0000360 if (m_real_stop_info_sp && m_real_stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
Jim Ingham988ddbc2010-10-26 00:27:45 +0000361 {
Jim Ingham2370a972011-05-17 01:10:11 +0000362 uint64_t break_site_id = m_real_stop_info_sp->GetValue();
Greg Clayton989816b2011-05-14 01:50:35 +0000363 BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id);
Jim Ingham988ddbc2010-10-26 00:27:45 +0000364 if (bp_site_sp)
365 {
366 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
367 bool is_internal = true;
368 for (uint32_t i = 0; i < num_owners; i++)
369 {
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000370 Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000371
372 if (!bp.IsInternal())
Jim Ingham988ddbc2010-10-26 00:27:45 +0000373 {
374 is_internal = false;
375 break;
376 }
377 }
378 if (is_internal)
379 return false;
380 }
381
382 return OkayToDiscard();
383 }
384 else
385 {
386 // If the subplan is running, any crashes are attributable to us.
Jim Ingham78108e62011-01-26 19:13:09 +0000387 // If we want to discard the plan, then we say we explain the stop
388 // but if we are going to be discarded, let whoever is above us
389 // explain the stop.
390 return ((m_subplan_sp.get() != NULL) && !OkayToDiscard());
Jim Ingham988ddbc2010-10-26 00:27:45 +0000391 }
Chris Lattner24943d22010-06-08 16:52:24 +0000392}
393
394bool
395ThreadPlanCallFunction::ShouldStop (Event *event_ptr)
396{
397 if (PlanExplainsStop())
398 {
Jim Ingham2f6267f2011-01-22 01:27:23 +0000399 ReportRegisterState ("Function completed. Register state was:");
Sean Callananf5857a02010-07-31 01:32:05 +0000400
Sean Callanan14a97ff2010-11-04 01:51:38 +0000401 DoTakedown();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000402
Chris Lattner24943d22010-06-08 16:52:24 +0000403 return true;
404 }
405 else
406 {
407 return false;
408 }
409}
410
411bool
412ThreadPlanCallFunction::StopOthers ()
413{
414 return m_stop_other_threads;
415}
416
417void
418ThreadPlanCallFunction::SetStopOthers (bool new_value)
419{
420 if (m_subplan_sp)
421 {
422 ThreadPlanRunToAddress *address_plan = static_cast<ThreadPlanRunToAddress *>(m_subplan_sp.get());
423 address_plan->SetStopOthers(new_value);
424 }
425 m_stop_other_threads = new_value;
426}
427
428StateType
Jim Ingham745ac7a2010-11-11 19:26:09 +0000429ThreadPlanCallFunction::GetPlanRunState ()
Chris Lattner24943d22010-06-08 16:52:24 +0000430{
431 return eStateRunning;
432}
433
434void
435ThreadPlanCallFunction::DidPush ()
436{
Sean Callananc2c6f772010-10-26 00:31:56 +0000437//#define SINGLE_STEP_EXPRESSIONS
438
439#ifndef SINGLE_STEP_EXPRESSIONS
Chris Lattner24943d22010-06-08 16:52:24 +0000440 m_subplan_sp.reset(new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
441
442 m_thread.QueueThreadPlan(m_subplan_sp, false);
Jim Ingham15dcb7c2011-01-20 02:03:18 +0000443 m_subplan_sp->SetPrivate (true);
Sean Callananc2c6f772010-10-26 00:31:56 +0000444#endif
Chris Lattner24943d22010-06-08 16:52:24 +0000445}
446
447bool
448ThreadPlanCallFunction::WillStop ()
449{
450 return true;
451}
452
453bool
454ThreadPlanCallFunction::MischiefManaged ()
455{
456 if (IsPlanComplete())
457 {
Greg Claytone005f2c2010-11-06 01:53:30 +0000458 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
Chris Lattner24943d22010-06-08 16:52:24 +0000459
460 if (log)
461 log->Printf("Completed call function plan.");
462
463 ThreadPlan::MischiefManaged ();
464 return true;
465 }
466 else
467 {
468 return false;
469 }
470}
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000471
472void
473ThreadPlanCallFunction::SetBreakpoints ()
474{
Jim Inghamba560cc2011-11-01 02:46:54 +0000475 m_cxx_language_runtime = m_thread.GetProcess().GetLanguageRuntime(eLanguageTypeC_plus_plus);
476 m_objc_language_runtime = m_thread.GetProcess().GetLanguageRuntime(eLanguageTypeObjC);
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000477
Sean Callanan29756d42010-11-03 22:19:38 +0000478 if (m_cxx_language_runtime)
479 m_cxx_language_runtime->SetExceptionBreakpoints();
480 if (m_objc_language_runtime)
481 m_objc_language_runtime->SetExceptionBreakpoints();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000482}
483
484void
485ThreadPlanCallFunction::ClearBreakpoints ()
486{
Sean Callanan29756d42010-11-03 22:19:38 +0000487 if (m_cxx_language_runtime)
488 m_cxx_language_runtime->ClearExceptionBreakpoints();
489 if (m_objc_language_runtime)
490 m_objc_language_runtime->ClearExceptionBreakpoints();
Sean Callanan07f3d8d2010-11-03 01:37:52 +0000491}
Sean Callanan94fb5432010-11-03 19:36:28 +0000492
493bool
494ThreadPlanCallFunction::BreakpointsExplainStop()
495{
Greg Clayton989816b2011-05-14 01:50:35 +0000496 StopInfoSP stop_info_sp = GetPrivateStopReason();
Sean Callanan94fb5432010-11-03 19:36:28 +0000497
Sean Callanan29756d42010-11-03 22:19:38 +0000498 if (m_cxx_language_runtime &&
499 m_cxx_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
500 return true;
Sean Callanan94fb5432010-11-03 19:36:28 +0000501
Sean Callanan29756d42010-11-03 22:19:38 +0000502 if (m_objc_language_runtime &&
503 m_objc_language_runtime->ExceptionBreakpointsExplainStop(stop_info_sp))
504 return true;
Sean Callanan94fb5432010-11-03 19:36:28 +0000505
506 return false;
507}