Navigation Menu

Skip to content

Commit

Permalink
[lldb] Inline invariant params to AppleThreadPlanStepThrough (NFC)
Browse files Browse the repository at this point in the history
These two `AppleThreadPlanStepThrough` thread plans have parameterized behavior
that is unutilized. To make their interface and implementation simpler, this
change inlines those outside parameters.

Differential Revision: https://reviews.llvm.org/D96276
  • Loading branch information
kastiglione committed Feb 9, 2021
1 parent 5e8a246 commit 2309392
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 50 deletions.
Expand Up @@ -1157,13 +1157,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
flag_value.GetScalar() = 0; // FIXME - Set to 0 when debugging is done.
dispatch_values.PushValue(flag_value);

// The step through code might have to fill in the cache, so it
// is not safe to run only one thread. So we override the
// stop_others value passed in to us here:
const bool trampoline_stop_others = false;
ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughObjCTrampoline>(
thread, *this, dispatch_values, isa_addr, sel_addr,
trampoline_stop_others);
thread, *this, dispatch_values, isa_addr, sel_addr);
if (log) {
StreamString s;
ret_plan_sp->GetDescription(&s, eDescriptionLevelFull);
Expand All @@ -1182,13 +1177,9 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
MsgsendMap::iterator pos;
pos = m_opt_dispatch_map.find(curr_pc);
if (pos != m_opt_dispatch_map.end()) {

const char *opt_name = g_opt_dispatch_names[(*pos).second];

bool trampoline_stop_others = false;
LazyBool step_in_should_stop = eLazyBoolCalculate;
ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughDirectDispatch> (
thread, *this, opt_name, trampoline_stop_others, step_in_should_stop);
ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughDirectDispatch>(
thread, *this, opt_name);
}
}

Expand Down
Expand Up @@ -30,15 +30,13 @@ using namespace lldb_private;
AppleThreadPlanStepThroughObjCTrampoline::
AppleThreadPlanStepThroughObjCTrampoline(
Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
ValueList &input_values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
bool stop_others)
ValueList &input_values, lldb::addr_t isa_addr, lldb::addr_t sel_addr)
: ThreadPlan(ThreadPlan::eKindGeneric,
"MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion,
eVoteNoOpinion),
m_trampoline_handler(trampoline_handler),
m_args_addr(LLDB_INVALID_ADDRESS), m_input_values(input_values),
m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(nullptr),
m_stop_others(stop_others) {}
m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(nullptr) {}

// Destructor
AppleThreadPlanStepThroughObjCTrampoline::
Expand Down Expand Up @@ -66,7 +64,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::InitializeFunctionCaller() {
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetStopOthers(m_stop_others);
options.SetStopOthers(false);
GetThread().CalculateExecutionContext(exc_ctx);
m_func_sp = m_impl_function->GetThreadPlanToCallFunction(
exc_ctx, m_args_addr, options, diagnostics);
Expand Down Expand Up @@ -157,7 +155,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
const bool first_insn = true;
const uint32_t frame_idx = 0;
m_run_to_sp = GetThread().QueueThreadPlanForStepOutNoShouldStop(
abort_other_plans, &sc, first_insn, m_stop_others, eVoteNoOpinion,
abort_other_plans, &sc, first_insn, false, eVoteNoOpinion,
eVoteNoOpinion, frame_idx, status);
if (m_run_to_sp && status.Success())
m_run_to_sp->SetPrivate(true);
Expand All @@ -179,7 +177,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
// Extract the target address from the value:

m_run_to_sp = std::make_shared<ThreadPlanRunToAddress>(
GetThread(), target_so_addr, m_stop_others);
GetThread(), target_so_addr, false);
PushPlan(m_run_to_sp);
return false;
} else if (GetThread().IsThreadPlanDone(m_run_to_sp.get())) {
Expand Down Expand Up @@ -222,10 +220,9 @@ bool AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; }
AppleThreadPlanStepThroughDirectDispatch ::
AppleThreadPlanStepThroughDirectDispatch(
Thread &thread, AppleObjCTrampolineHandler &handler,
llvm::StringRef dispatch_func_name, bool stop_others,
LazyBool step_in_avoids_code_without_debug_info)
: ThreadPlanStepOut(thread, nullptr, true /* first instruction */,
stop_others, eVoteNoOpinion, eVoteNoOpinion,
llvm::StringRef dispatch_func_name)
: ThreadPlanStepOut(thread, nullptr, true /* first instruction */, false,
eVoteNoOpinion, eVoteNoOpinion,
0 /* Step out of zeroth frame */,
eLazyBoolNo /* Our parent plan will decide this
when we are done */
Expand All @@ -234,7 +231,7 @@ AppleThreadPlanStepThroughDirectDispatch ::
false /* Don't gather the return value */),
m_trampoline_handler(handler),
m_dispatch_func_name(std::string(dispatch_func_name)),
m_at_msg_send(false), m_stop_others(stop_others) {
m_at_msg_send(false) {
// Set breakpoints on the dispatch functions:
auto bkpt_callback = [&] (lldb::addr_t addr,
const AppleObjCTrampolineHandler
Expand All @@ -249,20 +246,7 @@ AppleThreadPlanStepThroughDirectDispatch ::
// We'll set the step-out plan in the DidPush so it gets queued in the right
// order.

bool avoid_nodebug = true;

switch (step_in_avoids_code_without_debug_info) {
case eLazyBoolYes:
avoid_nodebug = true;
break;
case eLazyBoolNo:
avoid_nodebug = false;
break;
case eLazyBoolCalculate:
avoid_nodebug = GetThread().GetStepInAvoidsNoDebug();
break;
}
if (avoid_nodebug)
if (GetThread().GetStepInAvoidsNoDebug())
GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
else
GetFlags().Clear(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
Expand Down Expand Up @@ -398,8 +382,8 @@ bool AppleThreadPlanStepThroughDirectDispatch::ShouldStop(Event *event_ptr) {
// There's no way we could have gotten here without an ObjC language
// runtime.
assert(objc_runtime);
m_objc_step_through_sp
= objc_runtime->GetStepThroughTrampolinePlan(GetThread(), m_stop_others);
m_objc_step_through_sp =
objc_runtime->GetStepThroughTrampolinePlan(GetThread(), false);
// If we failed to find the target for this dispatch, just keep going and
// let the step out complete.
if (!m_objc_step_through_sp) {
Expand Down
Expand Up @@ -24,8 +24,7 @@ class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
public:
AppleThreadPlanStepThroughObjCTrampoline(
Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
bool stop_others);
ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr);

~AppleThreadPlanStepThroughObjCTrampoline() override;

Expand All @@ -39,7 +38,9 @@ class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {

bool ShouldStop(Event *event_ptr) override;

bool StopOthers() override { return m_stop_others; }
// The step through code might have to fill in the cache, so it is not safe
// to run only one thread.
bool StopOthers() override { return false; }

// The base class MischiefManaged does some cleanup - so you have to call it
// in your MischiefManaged derived class.
Expand Down Expand Up @@ -69,23 +70,21 @@ class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
FunctionCaller *m_impl_function; /// This is a pointer to a impl function that
/// is owned by the client that pushes this
/// plan.
bool m_stop_others; /// Whether we should stop other threads.
};

class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
public:
AppleThreadPlanStepThroughDirectDispatch(
Thread &thread, AppleObjCTrampolineHandler &handler,
llvm::StringRef dispatch_func_name, bool stop_others,
LazyBool step_in_avoids_code_without_debug_info);
AppleThreadPlanStepThroughDirectDispatch(Thread &thread,
AppleObjCTrampolineHandler &handler,
llvm::StringRef dispatch_func_name);

~AppleThreadPlanStepThroughDirectDispatch() override;

void GetDescription(Stream *s, lldb::DescriptionLevel level) override;

bool ShouldStop(Event *event_ptr) override;

bool StopOthers() override { return m_stop_others; }
bool StopOthers() override { return false; }

bool MischiefManaged() override;

Expand All @@ -107,7 +106,6 @@ class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc
/// dispatch functions.
bool m_at_msg_send; /// Are we currently handling an msg_send
bool m_stop_others; /// Whether we should stop other threads.

};

Expand Down

0 comments on commit 2309392

Please sign in to comment.