1 //===-- Unwind.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Unwind_h_
11 #define liblldb_Unwind_h_
17 // Other libraries and framework includes
19 #include "lldb/lldb-private.h"
21 namespace lldb_private {
25 //------------------------------------------------------------------
26 // Classes that inherit from Unwind can see and modify these
27 //------------------------------------------------------------------
28 Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
34 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
38 uint32_t GetFrameCount() {
39 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
40 return DoGetFrameCount();
43 uint32_t GetFramesUpTo(uint32_t end_idx) {
48 for (idx = 0; idx < end_idx; idx++) {
49 if (!DoGetFrameInfoAtIndex(idx, cfa, pc)) {
56 bool GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
58 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
59 return DoGetFrameInfoAtIndex(frame_idx, cfa, pc);
62 lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) {
63 std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
64 return DoCreateRegisterContextForFrame(frame);
67 Thread &GetThread() { return m_thread; }
70 //------------------------------------------------------------------
71 // Classes that inherit from Unwind can see and modify these
72 //------------------------------------------------------------------
73 virtual void DoClear() = 0;
75 virtual uint32_t DoGetFrameCount() = 0;
77 virtual bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
78 lldb::addr_t &pc) = 0;
80 virtual lldb::RegisterContextSP
81 DoCreateRegisterContextForFrame(StackFrame *frame) = 0;
84 std::recursive_mutex m_unwind_mutex;
87 DISALLOW_COPY_AND_ASSIGN(Unwind);
90 } // namespace lldb_private
92 #endif // liblldb_Unwind_h_