Unwind.h revision 591cf15899706efe8878a0718daec056e1ffd442
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    bool
56    GetFrameInfoAtIndex (uint32_t frame_idx,
57                         lldb::addr_t& cfa,
58                         lldb::addr_t& pc)
59    {
60        Mutex::Locker locker(m_unwind_mutex);
61        return DoGetFrameInfoAtIndex (frame_idx, cfa, pc);
62    }
63
64    lldb::RegisterContextSP
65    CreateRegisterContextForFrame (StackFrame *frame)
66    {
67        Mutex::Locker locker(m_unwind_mutex);
68        return DoCreateRegisterContextForFrame (frame);
69    }
70
71    Thread &
72    GetThread()
73    {
74        return m_thread;
75    }
76
77protected:
78    //------------------------------------------------------------------
79    // Classes that inherit from Unwind can see and modify these
80    //------------------------------------------------------------------
81    virtual void
82    DoClear() = 0;
83
84    virtual uint32_t
85    DoGetFrameCount() = 0;
86
87    virtual bool
88    DoGetFrameInfoAtIndex (uint32_t frame_idx,
89                         lldb::addr_t& cfa,
90                         lldb::addr_t& pc) = 0;
91
92    virtual lldb::RegisterContextSP
93    DoCreateRegisterContextForFrame (StackFrame *frame) = 0;
94
95    Thread &m_thread;
96    Mutex  m_unwind_mutex;
97private:
98    DISALLOW_COPY_AND_ASSIGN (Unwind);
99};
100
101} // namespace lldb_private
102
103#endif  // liblldb_Unwind_h_
104