2013-08-23 13:46:38 -04:00
|
|
|
//===-- ThreadPlanCallFunction.h --------------------------------*- C++ -*-===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#ifndef liblldb_ThreadPlanCallFunction_h_
|
|
|
|
|
#define liblldb_ThreadPlanCallFunction_h_
|
|
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
|
// C++ Includes
|
|
|
|
|
// Other libraries and framework includes
|
|
|
|
|
// Project includes
|
|
|
|
|
#include "lldb/lldb-private.h"
|
|
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
|
|
2013-12-03 13:51:59 -05:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
|
|
2013-08-23 13:46:38 -04:00
|
|
|
namespace lldb_private {
|
|
|
|
|
|
|
|
|
|
class ThreadPlanCallFunction : public ThreadPlan
|
|
|
|
|
{
|
|
|
|
|
// Create a thread plan to call a function at the address passed in the "function"
|
|
|
|
|
// argument. If you plan to call GetReturnValueObject, then pass in the
|
2015-12-30 06:55:28 -05:00
|
|
|
// return type, otherwise just pass in an invalid CompilerType.
|
2013-08-23 13:46:38 -04:00
|
|
|
public:
|
|
|
|
|
ThreadPlanCallFunction (Thread &thread,
|
|
|
|
|
const Address &function,
|
2015-12-30 06:55:28 -05:00
|
|
|
const CompilerType &return_type,
|
2013-12-03 13:51:59 -05:00
|
|
|
llvm::ArrayRef<lldb::addr_t> args,
|
|
|
|
|
const EvaluateExpressionOptions &options);
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-09-06 10:32:30 -04:00
|
|
|
ThreadPlanCallFunction(Thread &thread,
|
|
|
|
|
const Address &function,
|
|
|
|
|
const EvaluateExpressionOptions &options);
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
~ThreadPlanCallFunction() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
void
|
|
|
|
|
GetDescription(Stream *s, lldb::DescriptionLevel level) override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
ValidatePlan(Stream *error) override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
ShouldStop(Event *event_ptr) override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
Vote
|
|
|
|
|
ShouldReportStop(Event *event_ptr) override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
StopOthers() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
lldb::StateType
|
|
|
|
|
GetPlanRunState() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
void
|
|
|
|
|
DidPush() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
WillStop() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
MischiefManaged() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
|
|
|
|
// To get the return value from a function call you must create a
|
|
|
|
|
// lldb::ValueSP that contains a valid clang type in its context and call
|
|
|
|
|
// RequestReturnValue. The ValueSP will be stored and when the function is
|
|
|
|
|
// done executing, the object will check if there is a requested return
|
|
|
|
|
// value. If there is, the return value will be retrieved using the
|
|
|
|
|
// ABI::GetReturnValue() for the ABI in the process. Then after the thread
|
|
|
|
|
// plan is complete, you can call "GetReturnValue()" to retrieve the value
|
|
|
|
|
// that was extracted.
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
lldb::ValueObjectSP
|
|
|
|
|
GetReturnValueObject() override
|
2013-08-23 13:46:38 -04:00
|
|
|
{
|
|
|
|
|
return m_return_valobj_sp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the stack pointer that the function received
|
|
|
|
|
// on entry. Any stack address below this should be
|
|
|
|
|
// considered invalid after the function has been
|
|
|
|
|
// cleaned up.
|
|
|
|
|
lldb::addr_t
|
|
|
|
|
GetFunctionStackPointer()
|
|
|
|
|
{
|
|
|
|
|
return m_function_sp;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
// Classes that derive from FunctionCaller, and implement
|
2013-08-23 13:46:38 -04:00
|
|
|
// their own WillPop methods should call this so that the
|
|
|
|
|
// thread state gets restored if the plan gets discarded.
|
2015-12-30 06:55:28 -05:00
|
|
|
void
|
|
|
|
|
WillPop() override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
|
|
|
|
// If the thread plan stops mid-course, this will be the stop reason that interrupted us.
|
|
|
|
|
// Once DoTakedown is called, this will be the real stop reason at the end of the function call.
|
|
|
|
|
// If it hasn't been set for one or the other of these reasons, we'll return the PrivateStopReason.
|
|
|
|
|
// This is needed because we want the CallFunction thread plans not to show up as the stop reason.
|
|
|
|
|
// But if something bad goes wrong, it is nice to be able to tell the user what really happened.
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
lldb::StopInfoSP
|
|
|
|
|
GetRealStopInfo() override
|
2013-08-23 13:46:38 -04:00
|
|
|
{
|
|
|
|
|
if (m_real_stop_info_sp)
|
|
|
|
|
return m_real_stop_info_sp;
|
|
|
|
|
else
|
|
|
|
|
return GetPrivateStopInfo ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lldb::addr_t
|
|
|
|
|
GetStopAddress ()
|
|
|
|
|
{
|
|
|
|
|
return m_stop_address;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
RestoreThreadState() override;
|
2013-11-06 11:48:53 -05:00
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
void
|
|
|
|
|
ThreadDestroyed() override
|
2013-11-06 11:48:53 -05:00
|
|
|
{
|
|
|
|
|
m_takedown_done = true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
void
|
|
|
|
|
SetStopOthers(bool new_value) override;
|
2014-11-25 16:00:58 -05:00
|
|
|
|
|
|
|
|
protected:
|
2013-08-23 13:46:38 -04:00
|
|
|
void ReportRegisterState (const char *message);
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
bool
|
|
|
|
|
DoPlanExplainsStop(Event *event_ptr) override;
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2015-09-06 10:32:30 -04:00
|
|
|
virtual void
|
|
|
|
|
SetReturnValue();
|
2013-08-23 13:46:38 -04:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ConstructorSetup (Thread &thread,
|
|
|
|
|
ABI *& abi,
|
|
|
|
|
lldb::addr_t &start_load_addr,
|
|
|
|
|
lldb::addr_t &function_load_addr);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
DoTakedown (bool success);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
SetBreakpoints ();
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ClearBreakpoints ();
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
BreakpointsExplainStop ();
|
2015-09-06 10:32:30 -04:00
|
|
|
|
2013-08-23 13:46:38 -04:00
|
|
|
bool m_valid;
|
|
|
|
|
bool m_stop_other_threads;
|
2013-12-03 13:51:59 -05:00
|
|
|
bool m_unwind_on_error;
|
|
|
|
|
bool m_ignore_breakpoints;
|
|
|
|
|
bool m_debug_execution;
|
|
|
|
|
bool m_trap_exceptions;
|
2013-08-23 13:46:38 -04:00
|
|
|
Address m_function_addr;
|
|
|
|
|
Address m_start_addr;
|
|
|
|
|
lldb::addr_t m_function_sp;
|
|
|
|
|
lldb::ThreadPlanSP m_subplan_sp;
|
|
|
|
|
LanguageRuntime *m_cxx_language_runtime;
|
|
|
|
|
LanguageRuntime *m_objc_language_runtime;
|
|
|
|
|
Thread::ThreadStateCheckpoint m_stored_thread_state;
|
|
|
|
|
lldb::StopInfoSP m_real_stop_info_sp; // In general we want to hide call function
|
|
|
|
|
// thread plans, but for reporting purposes,
|
|
|
|
|
// it's nice to know the real stop reason.
|
|
|
|
|
// This gets set in DoTakedown.
|
|
|
|
|
StreamString m_constructor_errors;
|
|
|
|
|
lldb::ValueObjectSP m_return_valobj_sp; // If this contains a valid pointer, use the ABI to extract values when complete
|
|
|
|
|
bool m_takedown_done; // We want to ensure we only do the takedown once. This ensures that.
|
2013-12-03 13:51:59 -05:00
|
|
|
bool m_should_clear_objc_exception_bp;
|
|
|
|
|
bool m_should_clear_cxx_exception_bp;
|
2013-08-23 13:46:38 -04:00
|
|
|
lldb::addr_t m_stop_address; // This is the address we stopped at. Also set in DoTakedown;
|
|
|
|
|
|
2015-09-06 10:32:30 -04:00
|
|
|
private:
|
2015-12-30 06:55:28 -05:00
|
|
|
CompilerType m_return_type;
|
2013-08-23 13:46:38 -04:00
|
|
|
DISALLOW_COPY_AND_ASSIGN (ThreadPlanCallFunction);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace lldb_private
|
|
|
|
|
|
2015-12-30 06:55:28 -05:00
|
|
|
#endif // liblldb_ThreadPlanCallFunction_h_
|