blob: 0a0bee3787b47f3f8c4e06bcf84fa49f52ca7b7e [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
Chris Lattner30fdc8d2010-06-08 16:52:2410// C Includes
11// C++ Includes
12// Other libraries and framework includes
Chris Lattner30fdc8d2010-06-08 16:52:2413// Project includes
Eugene Zelenkoe65b2cf2015-12-15 01:33:1914#include "lldb/Target/ThreadPlanCallFunction.h"
Jim Ingham40d871f2010-10-26 00:27:4515#include "lldb/Breakpoint/Breakpoint.h"
16#include "lldb/Breakpoint/BreakpointLocation.h"
Chris Lattner30fdc8d2010-06-08 16:52:2417#include "lldb/Core/Address.h"
18#include "lldb/Core/Log.h"
Greg Clayton1f746072012-08-29 21:13:0619#include "lldb/Core/Module.h"
Greg Clayton1f746072012-08-29 21:13:0620#include "lldb/Symbol/ObjectFile.h"
Zachary Turner32abc6e2015-03-03 19:23:0921#include "lldb/Target/ABI.h"
Sean Callananf2115102010-11-03 22:19:3822#include "lldb/Target/LanguageRuntime.h"
Chris Lattner30fdc8d2010-06-08 16:52:2423#include "lldb/Target/Process.h"
24#include "lldb/Target/RegisterContext.h"
Jim Ingham40d871f2010-10-26 00:27:4525#include "lldb/Target/StopInfo.h"
Chris Lattner30fdc8d2010-06-08 16:52:2426#include "lldb/Target/Target.h"
27#include "lldb/Target/Thread.h"
28#include "lldb/Target/ThreadPlanRunToAddress.h"
Zachary Turnerbf9a7732017-02-02 21:39:5029#include "lldb/Utility/Stream.h"
Chris Lattner30fdc8d2010-06-08 16:52:2430
31using namespace lldb;
32using namespace lldb_private;
33
34//----------------------------------------------------------------------
35// ThreadPlanCallFunction: Plan to call a single function
36//----------------------------------------------------------------------
Kate Stoneb9c1b512016-09-06 20:57:5037bool ThreadPlanCallFunction::ConstructorSetup(
38 Thread &thread, ABI *&abi, lldb::addr_t &start_load_addr,
39 lldb::addr_t &function_load_addr) {
40 SetIsMasterPlan(true);
41 SetOkayToDiscard(false);
42 SetPrivate(true);
Jim Ingham0092c8e2012-04-13 20:38:1343
Kate Stoneb9c1b512016-09-06 20:57:5044 ProcessSP process_sp(thread.GetProcess());
45 if (!process_sp)
46 return false;
Saleem Abdulrasool324a1032014-04-04 04:06:1047
Kate Stoneb9c1b512016-09-06 20:57:5048 abi = process_sp->GetABI().get();
Saleem Abdulrasool324a1032014-04-04 04:06:1049
Kate Stoneb9c1b512016-09-06 20:57:5050 if (!abi)
51 return false;
Saleem Abdulrasool324a1032014-04-04 04:06:1052
Kate Stoneb9c1b512016-09-06 20:57:5053 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
Saleem Abdulrasool324a1032014-04-04 04:06:1054
Kate Stoneb9c1b512016-09-06 20:57:5055 SetBreakpoints();
Saleem Abdulrasool324a1032014-04-04 04:06:1056
Kate Stoneb9c1b512016-09-06 20:57:5057 m_function_sp = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize();
58 // If we can't read memory at the point of the process where we are planning
59 // to put our function, we're
60 // not going to get any further...
61 Error error;
62 process_sp->ReadUnsignedIntegerFromMemory(m_function_sp, 4, 0, error);
63 if (!error.Success()) {
64 m_constructor_errors.Printf(
65 "Trying to put the stack in unreadable memory at: 0x%" PRIx64 ".",
66 m_function_sp);
67 if (log)
68 log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
69 m_constructor_errors.GetData());
70 return false;
71 }
72
73 Module *exe_module = GetTarget().GetExecutableModulePointer();
74
75 if (exe_module == nullptr) {
76 m_constructor_errors.Printf(
77 "Can't execute code without an executable module.");
78 if (log)
79 log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
80 m_constructor_errors.GetData());
81 return false;
82 } else {
83 ObjectFile *objectFile = exe_module->GetObjectFile();
84 if (!objectFile) {
85 m_constructor_errors.Printf(
86 "Could not find object file for module \"%s\".",
87 exe_module->GetFileSpec().GetFilename().AsCString());
88
89 if (log)
90 log->Printf("ThreadPlanCallFunction(%p): %s.",
91 static_cast<void *>(this), m_constructor_errors.GetData());
92 return false;
Jim Ingham0092c8e2012-04-13 20:38:1393 }
Saleem Abdulrasool324a1032014-04-04 04:06:1094
Kate Stoneb9c1b512016-09-06 20:57:5095 m_start_addr = objectFile->GetEntryPointAddress();
96 if (!m_start_addr.IsValid()) {
97 m_constructor_errors.Printf(
98 "Could not find entry point address for executable module \"%s\".",
99 exe_module->GetFileSpec().GetFilename().AsCString());
100 if (log)
101 log->Printf("ThreadPlanCallFunction(%p): %s.",
102 static_cast<void *>(this), m_constructor_errors.GetData());
103 return false;
Jim Ingham0092c8e2012-04-13 20:38:13104 }
Kate Stoneb9c1b512016-09-06 20:57:50105 }
Jim Inghamea06f3b2013-03-28 00:04:05106
Kate Stoneb9c1b512016-09-06 20:57:50107 start_load_addr = m_start_addr.GetLoadAddress(&GetTarget());
Saleem Abdulrasool324a1032014-04-04 04:06:10108
Kate Stoneb9c1b512016-09-06 20:57:50109 // Checkpoint the thread state so we can restore it later.
110 if (log && log->GetVerbose())
111 ReportRegisterState("About to checkpoint thread before function call. "
112 "Original register state was:");
113
114 if (!thread.CheckpointThreadState(m_stored_thread_state)) {
115 m_constructor_errors.Printf("Setting up ThreadPlanCallFunction, failed to "
116 "checkpoint thread state.");
117 if (log)
118 log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast<void *>(this),
119 m_constructor_errors.GetData());
120 return false;
121 }
122 function_load_addr = m_function_addr.GetLoadAddress(&GetTarget());
123
124 return true;
125}
126
127ThreadPlanCallFunction::ThreadPlanCallFunction(
128 Thread &thread, const Address &function, const CompilerType &return_type,
129 llvm::ArrayRef<addr_t> args, const EvaluateExpressionOptions &options)
130 : ThreadPlan(ThreadPlan::eKindCallFunction, "Call function plan", thread,
131 eVoteNoOpinion, eVoteNoOpinion),
132 m_valid(false), m_stop_other_threads(options.GetStopOthers()),
133 m_unwind_on_error(options.DoesUnwindOnError()),
134 m_ignore_breakpoints(options.DoesIgnoreBreakpoints()),
135 m_debug_execution(options.GetDebug()),
136 m_trap_exceptions(options.GetTrapExceptions()), m_function_addr(function),
137 m_function_sp(0), m_takedown_done(false),
138 m_should_clear_objc_exception_bp(false),
139 m_should_clear_cxx_exception_bp(false),
140 m_stop_address(LLDB_INVALID_ADDRESS), m_return_type(return_type) {
141 lldb::addr_t start_load_addr = LLDB_INVALID_ADDRESS;
142 lldb::addr_t function_load_addr = LLDB_INVALID_ADDRESS;
143 ABI *abi = nullptr;
144
145 if (!ConstructorSetup(thread, abi, start_load_addr, function_load_addr))
146 return;
147
148 if (!abi->PrepareTrivialCall(thread, m_function_sp, function_load_addr,
149 start_load_addr, args))
150 return;
151
152 ReportRegisterState("Function call was set up. Register state was:");
153
154 m_valid = true;
155}
156
157ThreadPlanCallFunction::ThreadPlanCallFunction(
158 Thread &thread, const Address &function,
159 const EvaluateExpressionOptions &options)
160 : ThreadPlan(ThreadPlan::eKindCallFunction, "Call function plan", thread,
161 eVoteNoOpinion, eVoteNoOpinion),
162 m_valid(false), m_stop_other_threads(options.GetStopOthers()),
163 m_unwind_on_error(options.DoesUnwindOnError()),
164 m_ignore_breakpoints(options.DoesIgnoreBreakpoints()),
165 m_debug_execution(options.GetDebug()),
166 m_trap_exceptions(options.GetTrapExceptions()), m_function_addr(function),
167 m_function_sp(0), m_takedown_done(false),
168 m_should_clear_objc_exception_bp(false),
169 m_should_clear_cxx_exception_bp(false),
170 m_stop_address(LLDB_INVALID_ADDRESS), m_return_type(CompilerType()) {}
171
172ThreadPlanCallFunction::~ThreadPlanCallFunction() {
173 DoTakedown(PlanSucceeded());
174}
175
176void ThreadPlanCallFunction::ReportRegisterState(const char *message) {
177 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP |
178 LIBLLDB_LOG_VERBOSE));
179 if (log) {
180 StreamString strm;
181 RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
182
183 log->PutCString(message);
184
185 RegisterValue reg_value;
186
187 for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
188 reg_idx < num_registers; ++reg_idx) {
189 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx);
190 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
191 reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
192 strm.EOL();
193 }
Jim Ingham0092c8e2012-04-13 20:38:13194 }
Zachary Turnerc1564272016-11-16 21:15:24195 log->PutString(strm.GetString());
Kate Stoneb9c1b512016-09-06 20:57:50196 }
197}
Saleem Abdulrasool324a1032014-04-04 04:06:10198
Kate Stoneb9c1b512016-09-06 20:57:50199void ThreadPlanCallFunction::DoTakedown(bool success) {
200 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
Saleem Abdulrasool324a1032014-04-04 04:06:10201
Kate Stoneb9c1b512016-09-06 20:57:50202 if (!m_valid) {
203 // Don't call DoTakedown if we were never valid to begin with.
204 if (log)
205 log->Printf("ThreadPlanCallFunction(%p): Log called on "
206 "ThreadPlanCallFunction that was never valid.",
207 static_cast<void *>(this));
208 return;
209 }
210
211 if (!m_takedown_done) {
212 if (success) {
213 SetReturnValue();
214 }
215 if (log)
216 log->Printf("ThreadPlanCallFunction(%p): DoTakedown called for thread "
217 "0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
218 static_cast<void *>(this), m_thread.GetID(), m_valid,
219 IsPlanComplete());
220 m_takedown_done = true;
221 m_stop_address =
222 m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
223 m_real_stop_info_sp = GetPrivateStopInfo();
224 if (!m_thread.RestoreRegisterStateFromCheckpoint(m_stored_thread_state)) {
225 if (log)
226 log->Printf("ThreadPlanCallFunction(%p): DoTakedown failed to restore "
227 "register state",
228 static_cast<void *>(this));
229 }
230 SetPlanComplete(success);
231 ClearBreakpoints();
Jim Ingham0092c8e2012-04-13 20:38:13232 if (log && log->GetVerbose())
Kate Stoneb9c1b512016-09-06 20:57:50233 ReportRegisterState("Restoring thread state after function call. "
234 "Restored register state:");
235 } else {
Sean Callananece96492010-11-08 03:49:50236 if (log)
Kate Stoneb9c1b512016-09-06 20:57:50237 log->Printf("ThreadPlanCallFunction(%p): DoTakedown called as no-op for "
238 "thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
239 static_cast<void *>(this), m_thread.GetID(), m_valid,
240 IsPlanComplete());
241 }
Sean Callanan10af7c42010-11-04 01:51:38242}
243
Kate Stoneb9c1b512016-09-06 20:57:50244void ThreadPlanCallFunction::WillPop() { DoTakedown(PlanSucceeded()); }
Saleem Abdulrasool324a1032014-04-04 04:06:10245
Kate Stoneb9c1b512016-09-06 20:57:50246void ThreadPlanCallFunction::GetDescription(Stream *s, DescriptionLevel level) {
247 if (level == eDescriptionLevelBrief) {
248 s->Printf("Function call thread plan");
249 } else {
250 TargetSP target_sp(m_thread.CalculateTarget());
251 s->Printf("Thread plan to call 0x%" PRIx64,
252 m_function_addr.GetLoadAddress(target_sp.get()));
253 }
Chris Lattner30fdc8d2010-06-08 16:52:24254}
255
Kate Stoneb9c1b512016-09-06 20:57:50256bool ThreadPlanCallFunction::ValidatePlan(Stream *error) {
257 if (!m_valid) {
258 if (error) {
259 if (m_constructor_errors.GetSize() > 0)
Zachary Turnerc1564272016-11-16 21:15:24260 error->PutCString(m_constructor_errors.GetString());
Kate Stoneb9c1b512016-09-06 20:57:50261 else
262 error->PutCString("Unknown error");
263 }
264 return false;
265 }
266
267 return true;
Jim Inghambda4e5eb2011-01-18 01:58:06268}
269
Kate Stoneb9c1b512016-09-06 20:57:50270Vote ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr) {
271 if (m_takedown_done || IsPlanComplete())
272 return eVoteYes;
273 else
274 return ThreadPlan::ShouldReportStop(event_ptr);
Chris Lattner30fdc8d2010-06-08 16:52:24275}
276
Kate Stoneb9c1b512016-09-06 20:57:50277bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
278 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
279 LIBLLDB_LOG_PROCESS));
280 m_real_stop_info_sp = GetPrivateStopInfo();
Chris Lattner30fdc8d2010-06-08 16:52:24281
Kate Stoneb9c1b512016-09-06 20:57:50282 // If our subplan knows why we stopped, even if it's done (which would forward
283 // the question to us)
284 // we answer yes.
285 if (m_subplan_sp && m_subplan_sp->PlanExplainsStop(event_ptr)) {
286 SetPlanComplete();
Chris Lattner30fdc8d2010-06-08 16:52:24287 return true;
Kate Stoneb9c1b512016-09-06 20:57:50288 }
Chris Lattner30fdc8d2010-06-08 16:52:24289
Kate Stoneb9c1b512016-09-06 20:57:50290 // Check if the breakpoint is one of ours.
Jim Ingham0161b492013-02-09 01:29:05291
Kate Stoneb9c1b512016-09-06 20:57:50292 StopReason stop_reason;
293 if (!m_real_stop_info_sp)
294 stop_reason = eStopReasonNone;
295 else
296 stop_reason = m_real_stop_info_sp->GetStopReason();
297 if (log)
298 log->Printf(
299 "ThreadPlanCallFunction::PlanExplainsStop: Got stop reason - %s.",
300 Thread::StopReasonAsCString(stop_reason));
301
302 if (stop_reason == eStopReasonBreakpoint && BreakpointsExplainStop())
303 return true;
304
305 // One more quirk here. If this event was from Halt interrupting the target,
306 // then we should not consider
307 // ourselves complete. Return true to acknowledge the stop.
308 if (Process::ProcessEventData::GetInterruptedFromEvent(event_ptr)) {
Jim Ingham0161b492013-02-09 01:29:05309 if (log)
Kate Stoneb9c1b512016-09-06 20:57:50310 log->Printf("ThreadPlanCallFunction::PlanExplainsStop: The event is an "
311 "Interrupt, returning true.");
312 return true;
313 }
314 // We control breakpoints separately from other "stop reasons." So first,
315 // check the case where we stopped for an internal breakpoint, in that case,
316 // continue on.
317 // If it is not an internal breakpoint, consult m_ignore_breakpoints.
Jim Ingham18de2fd2012-05-10 01:35:39318
Kate Stoneb9c1b512016-09-06 20:57:50319 if (stop_reason == eStopReasonBreakpoint) {
320 ProcessSP process_sp(m_thread.CalculateProcess());
321 uint64_t break_site_id = m_real_stop_info_sp->GetValue();
322 BreakpointSiteSP bp_site_sp;
323 if (process_sp)
324 bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
325 if (bp_site_sp) {
326 uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
327 bool is_internal = true;
328 for (uint32_t i = 0; i < num_owners; i++) {
329 Breakpoint &bp = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
Jim Ingham35878c42014-04-08 21:33:21330 if (log)
Kate Stoneb9c1b512016-09-06 20:57:50331 log->Printf("ThreadPlanCallFunction::PlanExplainsStop: hit "
332 "breakpoint %d while calling function",
333 bp.GetID());
Eugene Zelenkoe65b2cf2015-12-15 01:33:19334
Kate Stoneb9c1b512016-09-06 20:57:50335 if (!bp.IsInternal()) {
336 is_internal = false;
337 break;
Jim Ingham40d871f2010-10-26 00:27:45338 }
Kate Stoneb9c1b512016-09-06 20:57:50339 }
340 if (is_internal) {
341 if (log)
342 log->Printf("ThreadPlanCallFunction::PlanExplainsStop hit an "
343 "internal breakpoint, not stopping.");
Jim Ingham0161b492013-02-09 01:29:05344 return false;
Kate Stoneb9c1b512016-09-06 20:57:50345 }
Jim Ingham40d871f2010-10-26 00:27:45346 }
Kate Stoneb9c1b512016-09-06 20:57:50347
348 if (m_ignore_breakpoints) {
349 if (log)
350 log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are ignoring "
351 "breakpoints, overriding breakpoint stop info ShouldStop, "
352 "returning true");
353 m_real_stop_info_sp->OverrideShouldStop(false);
354 return true;
355 } else {
356 if (log)
357 log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are not "
358 "ignoring breakpoints, overriding breakpoint stop info "
359 "ShouldStop, returning true");
360 m_real_stop_info_sp->OverrideShouldStop(true);
361 return false;
Jim Ingham40d871f2010-10-26 00:27:45362 }
Kate Stoneb9c1b512016-09-06 20:57:50363 } else if (!m_unwind_on_error) {
364 // If we don't want to discard this plan, than any stop we don't understand
365 // should be propagated up the stack.
366 return false;
367 } else {
368 // If the subplan is running, any crashes are attributable to us.
369 // If we want to discard the plan, then we say we explain the stop
370 // but if we are going to be discarded, let whoever is above us
371 // explain the stop.
372 // But don't discard the plan if the stop would restart itself (for instance
373 // if it is a
374 // signal that is set not to stop. Check that here first. We just say we
375 // explain the stop
376 // but aren't done and everything will continue on from there.
377
378 if (m_real_stop_info_sp &&
379 m_real_stop_info_sp->ShouldStopSynchronous(event_ptr)) {
380 SetPlanComplete(false);
381 return m_subplan_sp ? m_unwind_on_error : false;
382 } else
383 return true;
384 }
Chris Lattner30fdc8d2010-06-08 16:52:24385}
386
Kate Stoneb9c1b512016-09-06 20:57:50387bool ThreadPlanCallFunction::ShouldStop(Event *event_ptr) {
388 // We do some computation in DoPlanExplainsStop that may or may not set the
389 // plan as complete.
390 // We need to do that here to make sure our state is correct.
391 DoPlanExplainsStop(event_ptr);
392
393 if (IsPlanComplete()) {
394 ReportRegisterState("Function completed. Register state was:");
395 return true;
396 } else {
397 return false;
398 }
Chris Lattner30fdc8d2010-06-08 16:52:24399}
400
Kate Stoneb9c1b512016-09-06 20:57:50401bool ThreadPlanCallFunction::StopOthers() { return m_stop_other_threads; }
Chris Lattner30fdc8d2010-06-08 16:52:24402
Kate Stoneb9c1b512016-09-06 20:57:50403StateType ThreadPlanCallFunction::GetPlanRunState() { return eStateRunning; }
Chris Lattner30fdc8d2010-06-08 16:52:24404
Kate Stoneb9c1b512016-09-06 20:57:50405void ThreadPlanCallFunction::DidPush() {
406 //#define SINGLE_STEP_EXPRESSIONS
407
408 // Now set the thread state to "no reason" so we don't run with whatever
409 // signal was outstanding...
410 // Wait till the plan is pushed so we aren't changing the stop info till we're
411 // about to run.
412
413 GetThread().SetStopInfoToNothing();
414
Sean Callananbe3a1b12010-10-26 00:31:56415#ifndef SINGLE_STEP_EXPRESSIONS
Kate Stoneb9c1b512016-09-06 20:57:50416 m_subplan_sp.reset(
417 new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
418
419 m_thread.QueueThreadPlan(m_subplan_sp, false);
420 m_subplan_sp->SetPrivate(true);
Sean Callananbe3a1b12010-10-26 00:31:56421#endif
Chris Lattner30fdc8d2010-06-08 16:52:24422}
423
Kate Stoneb9c1b512016-09-06 20:57:50424bool ThreadPlanCallFunction::WillStop() { return true; }
425
426bool ThreadPlanCallFunction::MischiefManaged() {
427 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
428
429 if (IsPlanComplete()) {
430 if (log)
431 log->Printf("ThreadPlanCallFunction(%p): Completed call function plan.",
432 static_cast<void *>(this));
433
434 ThreadPlan::MischiefManaged();
Chris Lattner30fdc8d2010-06-08 16:52:24435 return true;
Kate Stoneb9c1b512016-09-06 20:57:50436 } else {
Sean Callananc98aca62010-11-03 19:36:28437 return false;
Kate Stoneb9c1b512016-09-06 20:57:50438 }
Sean Callananc98aca62010-11-03 19:36:28439}
Jim Ingham8559a352012-11-26 23:52:18440
Kate Stoneb9c1b512016-09-06 20:57:50441void ThreadPlanCallFunction::SetBreakpoints() {
442 ProcessSP process_sp(m_thread.CalculateProcess());
443 if (m_trap_exceptions && process_sp) {
444 m_cxx_language_runtime =
445 process_sp->GetLanguageRuntime(eLanguageTypeC_plus_plus);
446 m_objc_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeObjC);
Jim Ingham0ff099f2014-03-07 11:16:37447
Kate Stoneb9c1b512016-09-06 20:57:50448 if (m_cxx_language_runtime) {
449 m_should_clear_cxx_exception_bp =
450 !m_cxx_language_runtime->ExceptionBreakpointsAreSet();
451 m_cxx_language_runtime->SetExceptionBreakpoints();
Ewan Crawford90ff7912015-07-14 10:56:58452 }
Kate Stoneb9c1b512016-09-06 20:57:50453 if (m_objc_language_runtime) {
454 m_should_clear_objc_exception_bp =
455 !m_objc_language_runtime->ExceptionBreakpointsAreSet();
456 m_objc_language_runtime->SetExceptionBreakpoints();
457 }
458 }
459}
460
461void ThreadPlanCallFunction::ClearBreakpoints() {
462 if (m_trap_exceptions) {
463 if (m_cxx_language_runtime && m_should_clear_cxx_exception_bp)
464 m_cxx_language_runtime->ClearExceptionBreakpoints();
465 if (m_objc_language_runtime && m_should_clear_objc_exception_bp)
466 m_objc_language_runtime->ClearExceptionBreakpoints();
467 }
468}
469
470bool ThreadPlanCallFunction::BreakpointsExplainStop() {
471 StopInfoSP stop_info_sp = GetPrivateStopInfo();
472
473 if (m_trap_exceptions) {
474 if ((m_cxx_language_runtime &&
475 m_cxx_language_runtime->ExceptionBreakpointsExplainStop(
476 stop_info_sp)) ||
477 (m_objc_language_runtime &&
478 m_objc_language_runtime->ExceptionBreakpointsExplainStop(
479 stop_info_sp))) {
480 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP));
481 if (log)
482 log->Printf("ThreadPlanCallFunction::BreakpointsExplainStop - Hit an "
483 "exception breakpoint, setting plan complete.");
484
485 SetPlanComplete(false);
486
487 // If the user has set the ObjC language breakpoint, it would normally get
488 // priority over our internal
489 // catcher breakpoint, but in this case we can't let that happen, so force
490 // the ShouldStop here.
491 stop_info_sp->OverrideShouldStop(true);
492 return true;
493 }
494 }
495
496 return false;
497}
498
499void ThreadPlanCallFunction::SetStopOthers(bool new_value) {
500 m_subplan_sp->SetStopOthers(new_value);
501}
502
503bool ThreadPlanCallFunction::RestoreThreadState() {
504 return GetThread().RestoreThreadStateFromCheckpoint(m_stored_thread_state);
505}
506
507void ThreadPlanCallFunction::SetReturnValue() {
508 ProcessSP process_sp(m_thread.GetProcess());
509 const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
510 if (abi && m_return_type.IsValid()) {
511 const bool persistent = false;
512 m_return_valobj_sp =
513 abi->GetReturnValueObject(m_thread, m_return_type, persistent);
514 }
Ewan Crawford90ff7912015-07-14 10:56:58515}