Path: blob/main/contrib/llvm-project/lldb/source/Target/ThreadPlanCallOnFunctionExit.cpp
39587 views
//===-- ThreadPlanCallOnFunctionExit.cpp ----------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Target/ThreadPlanCallOnFunctionExit.h"910using namespace lldb;11using namespace lldb_private;1213ThreadPlanCallOnFunctionExit::ThreadPlanCallOnFunctionExit(14Thread &thread, const Callback &callback)15: ThreadPlan(ThreadPlanKind::eKindGeneric, "CallOnFunctionExit", thread,16eVoteNoOpinion, eVoteNoOpinion // TODO check with Jim on these17),18m_callback(callback) {19// We are not a user-generated plan.20SetIsControllingPlan(false);21}2223void ThreadPlanCallOnFunctionExit::DidPush() {24// We now want to queue the "step out" thread plan so it executes and25// completes.2627// Set stop vote to eVoteNo.28Status status;29m_step_out_threadplan_sp = GetThread().QueueThreadPlanForStepOut(30false, // abort other plans31nullptr, // addr_context32true, // first instruction33true, // stop other threads34eVoteNo, // do not say "we're stopping"35eVoteNoOpinion, // don't care about run state broadcasting360, // frame_idx37status, // status38eLazyBoolCalculate // avoid code w/o debinfo39);40}4142// ThreadPlan API4344void ThreadPlanCallOnFunctionExit::GetDescription(45Stream *s, lldb::DescriptionLevel level) {46if (!s)47return;48s->Printf("Running until completion of current function, then making "49"callback.");50}5152bool ThreadPlanCallOnFunctionExit::ValidatePlan(Stream *error) {53// We'll say we're always good since I don't know what would make this54// invalid.55return true;56}5758bool ThreadPlanCallOnFunctionExit::ShouldStop(Event *event_ptr) {59// If this is where we find out that an internal stop came in, then: Check if60// the step-out plan completed. If it did, then we want to run the callback61// here (our reason for living...)62if (m_step_out_threadplan_sp && m_step_out_threadplan_sp->IsPlanComplete()) {63m_callback();6465// We no longer need the pointer to the step-out thread plan.66m_step_out_threadplan_sp.reset();6768// Indicate that this plan is done and can be discarded.69SetPlanComplete();7071// We're done now, but we want to return false so that we don't cause the72// thread to really stop.73}7475return false;76}7778bool ThreadPlanCallOnFunctionExit::WillStop() {79// The code looks like the return value is ignored via ThreadList::80// ShouldStop(). This is called when we really are going to stop. We don't81// care and don't need to do anything here.82return false;83}8485bool ThreadPlanCallOnFunctionExit::DoPlanExplainsStop(Event *event_ptr) {86// We don't ever explain a stop. The only stop that is relevant to us87// directly is the step_out plan we added to do the heavy lifting of getting88// us past the current method.89return false;90}9192lldb::StateType ThreadPlanCallOnFunctionExit::GetPlanRunState() {93// This value doesn't matter - we'll never be the top thread plan, so nobody94// will ask us this question.95return eStateRunning;96}979899