LLDB mainline
ThreadPlanCallOnFunctionExit.cpp
Go to the documentation of this file.
1//===-- ThreadPlanCallOnFunctionExit.cpp ----------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11using namespace lldb;
12using namespace lldb_private;
13
15 Thread &thread, const Callback &callback)
16 : ThreadPlan(ThreadPlanKind::eKindGeneric, "CallOnFunctionExit", thread,
17 eVoteNoOpinion, eVoteNoOpinion // TODO check with Jim on these
18 ),
19 m_callback(callback) {
20 // We are not a user-generated plan.
22}
23
25 // We now want to queue the "step out" thread plan so it executes and
26 // completes.
27
28 // Set stop vote to eVoteNo.
29 Status status;
31 false, // abort other plans
32 nullptr, // addr_context
33 true, // first instruction
34 true, // stop other threads
35 eVoteNo, // do not say "we're stopping"
36 eVoteNoOpinion, // don't care about run state broadcasting
37 0, // frame_idx
38 status, // status
39 eLazyBoolCalculate // avoid code w/o debinfo
40 );
41}
42
43// ThreadPlan API
44
47 if (!s)
48 return;
49 s->Printf("Running until completion of current function, then making "
50 "callback.");
51}
52
54 // We'll say we're always good since I don't know what would make this
55 // invalid.
56 return true;
57}
58
60 // If this is where we find out that an internal stop came in, then: Check if
61 // the step-out plan completed. If it did, then we want to run the callback
62 // here (our reason for living...)
63 if (m_step_out_threadplan_sp && m_step_out_threadplan_sp->IsPlanComplete()) {
64 m_callback();
65
66 // We no longer need the pointer to the step-out thread plan.
68
69 // Indicate that this plan is done and can be discarded.
71
72 // We're done now, but we want to return false so that we don't cause the
73 // thread to really stop.
74 }
75
76 return false;
77}
78
80 // The code looks like the return value is ignored via ThreadList::
81 // ShouldStop(). This is called when we really are going to stop. We don't
82 // care and don't need to do anything here.
83 return false;
84}
85
87 // We don't ever explain a stop. The only stop that is relevant to us
88 // directly is the step_out plan we added to do the heavy lifting of getting
89 // us past the current method.
90 return false;
91}
92
94 // This value doesn't matter - we'll never be the top thread plan, so nobody
95 // will ask us this question.
96 return eStateRunning;
97}
static llvm::raw_ostream & error(Stream &strm)
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
ThreadPlanCallOnFunctionExit(Thread &thread, const Callback &callback)
std::function< void()> Callback
Definition for the callback made when the currently executing thread finishes executing its function.
bool ValidatePlan(Stream *error) override
Returns whether this plan could be successfully created.
void GetDescription(Stream *s, lldb::DescriptionLevel level) override
Print a description of this thread to the stream s.
void SetPlanComplete(bool success=true)
Definition: ThreadPlan.cpp:66
Thread & GetThread()
Returns the Thread that is using this thread plan.
Definition: ThreadPlan.cpp:42
bool SetIsControllingPlan(bool value)
Definition: ThreadPlan.h:398
virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut(bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_other_threads, Vote report_stop_vote, Vote report_run_vote, uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info=eLazyBoolCalculate)
Queue the plan used to step out of the function at the current PC of thread.
Definition: Thread.cpp:1310
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
StateType
Process and Thread States.
@ eStateRunning
Process or thread is running and can't be examined.