1 //===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef ThreadPlanCallOnFunctionExit_h 11 #define ThreadPlanCallOnFunctionExit_h 12 13 #include "lldb/Target/ThreadPlan.h" 14 15 #include <functional> 16 17 namespace lldb_private { 18 19 // ============================================================================= 20 /// This thread plan calls a function object when the current function exits. 21 // ============================================================================= 22 23 class ThreadPlanCallOnFunctionExit : public ThreadPlan { 24 public: 25 /// Definition for the callback made when the currently executing thread 26 /// finishes executing its function. 27 using Callback = std::function<void()>; 28 29 ThreadPlanCallOnFunctionExit(Thread &thread, const Callback &callback); 30 31 void DidPush() override; 32 33 // ------------------------------------------------------------------------- 34 // ThreadPlan API 35 // ------------------------------------------------------------------------- 36 37 void GetDescription(Stream *s, lldb::DescriptionLevel level) override; 38 39 bool ValidatePlan(Stream *error) override; 40 41 bool ShouldStop(Event *event_ptr) override; 42 43 bool WillStop() override; 44 45 protected: 46 bool DoPlanExplainsStop(Event *event_ptr) override; 47 48 lldb::StateType GetPlanRunState() override; 49 50 private: 51 Callback m_callback; 52 lldb::ThreadPlanSP m_step_out_threadplan_sp; 53 }; 54 } 55 56 #endif /* ThreadPlanCallOnFunctionExit_h */ 57