Unwind.h revision bf97d74c0c3e9a0f7c89fe0cd4a059015ec482d5
1//===-- Unwind.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 liblldb_Unwind_h_ 11#define liblldb_Unwind_h_ 12 13// C Includes 14// C++ Includes 15// Other libraries and framework includes 16// Project includes 17#include "lldb/lldb-private.h" 18#include "lldb/Host/Mutex.h" 19 20namespace lldb_private { 21 22class Unwind 23{ 24protected: 25 //------------------------------------------------------------------ 26 // Classes that inherit from Unwind can see and modify these 27 //------------------------------------------------------------------ 28 Unwind(Thread &thread) : 29 m_thread (thread), 30 m_unwind_mutex() 31 { 32 } 33 34public: 35 virtual 36 ~Unwind() 37 { 38 } 39 40 void 41 Clear() 42 { 43 Mutex::Locker locker(m_unwind_mutex); 44 DoClear(); 45 46 } 47 48 uint32_t 49 GetFrameCount() 50 { 51 Mutex::Locker locker(m_unwind_mutex); 52 return DoGetFrameCount(); 53 } 54 55 uint32_t 56 GetFramesUpTo (uint32_t end_idx) 57 { 58 lldb::addr_t cfa; 59 lldb::addr_t pc; 60 uint32_t idx; 61 62 for (idx = 0; idx < end_idx; idx++) 63 { 64 if (!DoGetFrameInfoAtIndex (idx, cfa, pc)) 65 { 66 break; 67 } 68 } 69 return idx; 70 } 71 72 bool 73 GetFrameInfoAtIndex (uint32_t frame_idx, 74 lldb::addr_t& cfa, 75 lldb::addr_t& pc) 76 { 77 Mutex::Locker locker(m_unwind_mutex); 78 return DoGetFrameInfoAtIndex (frame_idx, cfa, pc); 79 } 80 81 lldb::RegisterContextSP 82 CreateRegisterContextForFrame (StackFrame *frame) 83 { 84 Mutex::Locker locker(m_unwind_mutex); 85 return DoCreateRegisterContextForFrame (frame); 86 } 87 88 Thread & 89 GetThread() 90 { 91 return m_thread; 92 } 93 94protected: 95 //------------------------------------------------------------------ 96 // Classes that inherit from Unwind can see and modify these 97 //------------------------------------------------------------------ 98 virtual void 99 DoClear() = 0; 100 101 virtual uint32_t 102 DoGetFrameCount() = 0; 103 104 virtual bool 105 DoGetFrameInfoAtIndex (uint32_t frame_idx, 106 lldb::addr_t& cfa, 107 lldb::addr_t& pc) = 0; 108 109 virtual lldb::RegisterContextSP 110 DoCreateRegisterContextForFrame (StackFrame *frame) = 0; 111 112 Thread &m_thread; 113 Mutex m_unwind_mutex; 114private: 115 DISALLOW_COPY_AND_ASSIGN (Unwind); 116}; 117 118} // namespace lldb_private 119 120#endif // liblldb_Unwind_h_ 121