ThreadPlanCallOnFunctionExit.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H
  9. #define LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H
  10. #include "lldb/Target/ThreadPlan.h"
  11. #include <functional>
  12. namespace lldb_private {
  13. // =============================================================================
  14. /// This thread plan calls a function object when the current function exits.
  15. // =============================================================================
  16. class ThreadPlanCallOnFunctionExit : public ThreadPlan {
  17. public:
  18. /// Definition for the callback made when the currently executing thread
  19. /// finishes executing its function.
  20. using Callback = std::function<void()>;
  21. ThreadPlanCallOnFunctionExit(Thread &thread, const Callback &callback);
  22. void DidPush() override;
  23. // ThreadPlan API
  24. void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
  25. bool ValidatePlan(Stream *error) override;
  26. bool ShouldStop(Event *event_ptr) override;
  27. bool WillStop() override;
  28. protected:
  29. bool DoPlanExplainsStop(Event *event_ptr) override;
  30. lldb::StateType GetPlanRunState() override;
  31. private:
  32. Callback m_callback;
  33. lldb::ThreadPlanSP m_step_out_threadplan_sp;
  34. };
  35. }
  36. #endif // LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H