Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 1 | //===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===// |
| 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 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 9 | #ifndef LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H |
| 10 | #define LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 11 | |
| 12 | #include "lldb/Target/ThreadPlan.h" |
| 13 | |
| 14 | #include <functional> |
| 15 | |
| 16 | namespace lldb_private { |
| 17 | |
| 18 | // ============================================================================= |
| 19 | /// This thread plan calls a function object when the current function exits. |
| 20 | // ============================================================================= |
| 21 | |
| 22 | class ThreadPlanCallOnFunctionExit : public ThreadPlan { |
| 23 | public: |
| 24 | /// Definition for the callback made when the currently executing thread |
| 25 | /// finishes executing its function. |
| 26 | using Callback = std::function<void()>; |
| 27 | |
| 28 | ThreadPlanCallOnFunctionExit(Thread &thread, const Callback &callback); |
| 29 | |
| 30 | void DidPush() override; |
| 31 | |
| 32 | // ThreadPlan API |
| 33 | |
| 34 | void GetDescription(Stream *s, lldb::DescriptionLevel level) override; |
| 35 | |
| 36 | bool ValidatePlan(Stream *error) override; |
| 37 | |
| 38 | bool ShouldStop(Event *event_ptr) override; |
| 39 | |
| 40 | bool WillStop() override; |
| 41 | |
| 42 | protected: |
| 43 | bool DoPlanExplainsStop(Event *event_ptr) override; |
| 44 | |
| 45 | lldb::StateType GetPlanRunState() override; |
| 46 | |
| 47 | private: |
| 48 | Callback m_callback; |
| 49 | lldb::ThreadPlanSP m_step_out_threadplan_sp; |
| 50 | }; |
| 51 | } |
| 52 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 53 | #endif // LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H |