1 //===-- Unwind.h ------------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_Unwind_h_
10 #define liblldb_Unwind_h_
14 #include "lldb/lldb-private.h"
16 namespace lldb_private {
20 // Classes that inherit from Unwind can see and modify these
21 Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
27 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
31 uint32_t GetFrameCount() {
32 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
33 return DoGetFrameCount();
36 uint32_t GetFramesUpTo(uint32_t end_idx) {
41 for (idx = 0; idx < end_idx; idx++) {
42 if (!DoGetFrameInfoAtIndex(idx, cfa, pc)) {
49 bool GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
51 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
52 return DoGetFrameInfoAtIndex(frame_idx, cfa, pc);
55 lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) {
56 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
57 return DoCreateRegisterContextForFrame(frame);
60 Thread &GetThread() { return m_thread; }
63 // Classes that inherit from Unwind can see and modify these
64 virtual void DoClear() = 0;
66 virtual uint32_t DoGetFrameCount() = 0;
68 virtual bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
69 lldb::addr_t &pc) = 0;
71 virtual lldb::RegisterContextSP
72 DoCreateRegisterContextForFrame(StackFrame *frame) = 0;
75 std::recursive_mutex m_unwind_mutex;
78 DISALLOW_COPY_AND_ASSIGN(Unwind);
81 } // namespace lldb_private
83 #endif // liblldb_Unwind_h_