LLDB  mainline
Unwind.h
Go to the documentation of this file.
1 //===-- Unwind.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 
9 #ifndef liblldb_Unwind_h_
10 #define liblldb_Unwind_h_
11 
12 #include <mutex>
13 
14 #include "lldb/lldb-private.h"
15 
16 namespace lldb_private {
17 
18 class Unwind {
19 protected:
20  // Classes that inherit from Unwind can see and modify these
21  Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
22 
23 public:
24  virtual ~Unwind() {}
25 
26  void Clear() {
27  std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
28  DoClear();
29  }
30 
32  std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
33  return DoGetFrameCount();
34  }
35 
37  lldb::addr_t cfa;
39  uint32_t idx;
40 
41  for (idx = 0; idx < end_idx; idx++) {
42  if (!DoGetFrameInfoAtIndex(idx, cfa, pc)) {
43  break;
44  }
45  }
46  return idx;
47  }
48 
50  lldb::addr_t &pc) {
51  std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
52  return DoGetFrameInfoAtIndex(frame_idx, cfa, pc);
53  }
54 
55  lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame) {
56  std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
57  return DoCreateRegisterContextForFrame(frame);
58  }
59 
60  Thread &GetThread() { return m_thread; }
61 
62 protected:
63  // Classes that inherit from Unwind can see and modify these
64  virtual void DoClear() = 0;
65 
66  virtual uint32_t DoGetFrameCount() = 0;
67 
68  virtual bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
69  lldb::addr_t &pc) = 0;
70 
71  virtual lldb::RegisterContextSP
73 
75  std::recursive_mutex m_unwind_mutex;
76 
77 private:
78  DISALLOW_COPY_AND_ASSIGN(Unwind);
79 };
80 
81 } // namespace lldb_private
82 
83 #endif // liblldb_Unwind_h_
virtual bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, lldb::addr_t &pc)=0
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual uint32_t DoGetFrameCount()=0
uint32_t GetFrameCount()
Definition: Unwind.h:31
Thread & GetThread()
Definition: Unwind.h:60
lldb::RegisterContextSP CreateRegisterContextForFrame(StackFrame *frame)
Definition: Unwind.h:55
bool GetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa, lldb::addr_t &pc)
Definition: Unwind.h:49
virtual void DoClear()=0
Unwind(Thread &thread)
Definition: Unwind.h:21
Thread & m_thread
Definition: Unwind.h:74
std::recursive_mutex m_unwind_mutex
Definition: Unwind.h:75
uint64_t addr_t
Definition: lldb-types.h:83
virtual lldb::RegisterContextSP DoCreateRegisterContextForFrame(StackFrame *frame)=0
virtual ~Unwind()
Definition: Unwind.h:24
uint32_t GetFramesUpTo(uint32_t end_idx)
Definition: Unwind.h:36
This base class provides an interface to stack frames.
Definition: StackFrame.h:40