]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/StackID.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Target / StackID.h
1 //===-- StackID.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_StackID_h_
11 #define liblldb_StackID_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/AddressRange.h"
18 #include "lldb/lldb-private.h"
19
20 namespace lldb_private {
21
22 class StackID {
23 public:
24   //------------------------------------------------------------------
25   // Constructors and Destructors
26   //------------------------------------------------------------------
27   StackID()
28       : m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS),
29         m_symbol_scope(nullptr) {}
30
31   explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
32                    SymbolContextScope *symbol_scope)
33       : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {}
34
35   StackID(const StackID &rhs)
36       : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
37
38   ~StackID() = default;
39
40   lldb::addr_t GetPC() const { return m_pc; }
41
42   lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
43
44   SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
45
46   void SetSymbolContextScope(SymbolContextScope *symbol_scope) {
47     m_symbol_scope = symbol_scope;
48   }
49
50   void Clear() {
51     m_pc = LLDB_INVALID_ADDRESS;
52     m_cfa = LLDB_INVALID_ADDRESS;
53     m_symbol_scope = nullptr;
54   }
55
56   bool IsValid() const {
57     return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
58   }
59
60   void Dump(Stream *s);
61
62   //------------------------------------------------------------------
63   // Operators
64   //------------------------------------------------------------------
65   const StackID &operator=(const StackID &rhs) {
66     if (this != &rhs) {
67       m_pc = rhs.m_pc;
68       m_cfa = rhs.m_cfa;
69       m_symbol_scope = rhs.m_symbol_scope;
70     }
71     return *this;
72   }
73
74 protected:
75   friend class StackFrame;
76
77   void SetPC(lldb::addr_t pc) { m_pc = pc; }
78
79   void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
80
81   lldb::addr_t
82       m_pc; // The pc value for the function/symbol for this frame. This will
83   // only get used if the symbol scope is nullptr (the code where we are
84   // stopped is not represented by any function or symbol in any shared
85   // library).
86   lldb::addr_t m_cfa; // The call frame address (stack pointer) value
87                       // at the beginning of the function that uniquely
88                       // identifies this frame (along with m_symbol_scope
89                       // below)
90   SymbolContextScope *
91       m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
92                       // If not nullptr, this will either be the scope for the
93                       // lexical block for the frame, or the scope for the
94                       // symbol. Symbol context scopes are always be unique
95                       // pointers since the are part of the Block and Symbol
96                       // objects and can easily be used to tell if a stack ID
97                       // is the same as another.
98 };
99
100 bool operator==(const StackID &lhs, const StackID &rhs);
101 bool operator!=(const StackID &lhs, const StackID &rhs);
102
103 // frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
104 bool operator<(const StackID &lhs, const StackID &rhs);
105
106 } // namespace lldb_private
107
108 #endif // liblldb_StackID_h_