]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/StackID.h
Merge ^/head r295544 through r295600.
[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/lldb-private.h"
18 #include "lldb/Core/AddressRange.h"
19
20 namespace lldb_private {
21
22 class StackID
23 {
24 public:
25     //------------------------------------------------------------------
26     // Constructors and Destructors
27     //------------------------------------------------------------------
28     StackID () :
29         m_pc (LLDB_INVALID_ADDRESS),
30         m_cfa (LLDB_INVALID_ADDRESS),
31         m_symbol_scope (nullptr)
32     {
33     }
34
35     explicit 
36     StackID (lldb::addr_t pc, lldb::addr_t cfa, SymbolContextScope *symbol_scope) :
37         m_pc (pc),
38         m_cfa (cfa),
39         m_symbol_scope (symbol_scope)
40     {
41     }
42
43     StackID (const StackID& rhs) :
44         m_pc (rhs.m_pc),
45         m_cfa (rhs.m_cfa),
46         m_symbol_scope (rhs.m_symbol_scope)
47     {
48     }
49
50     ~StackID() = default;
51
52     lldb::addr_t
53     GetPC() const
54     {
55         return m_pc;
56     }
57     
58     lldb::addr_t
59     GetCallFrameAddress() const
60     {
61         return m_cfa;
62     }
63
64     SymbolContextScope *
65     GetSymbolContextScope () const
66     {
67         return m_symbol_scope;
68     }
69     
70     void
71     SetSymbolContextScope (SymbolContextScope *symbol_scope)
72     {
73         m_symbol_scope = symbol_scope;
74     }
75
76     void
77     Clear ()
78     {
79         m_pc = LLDB_INVALID_ADDRESS;
80         m_cfa = LLDB_INVALID_ADDRESS;
81         m_symbol_scope = nullptr;
82     }
83     
84     bool
85     IsValid () const
86     {
87         return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
88     }
89     
90     void
91     Dump (Stream *s);
92
93     //------------------------------------------------------------------
94     // Operators
95     //------------------------------------------------------------------
96     const StackID&
97     operator=(const StackID& rhs)
98     {
99         if (this != &rhs)
100         {
101             m_pc = rhs.m_pc;
102             m_cfa = rhs.m_cfa;
103             m_symbol_scope = rhs.m_symbol_scope;
104         }
105         return *this;
106     }
107
108 protected:
109     friend class StackFrame;
110
111     void
112     SetPC (lldb::addr_t pc)
113     {
114         m_pc = pc;
115     }
116
117     void
118     SetCFA (lldb::addr_t cfa)
119     {
120         m_cfa = cfa;
121     }
122
123     lldb::addr_t m_pc;                  // The pc value for the function/symbol for this frame. This will
124                                         // only get used if the symbol scope is nullptr (the code where we are
125                                         // stopped is not represented by any function or symbol in any
126                                         // shared library).
127     lldb::addr_t m_cfa;                 // The call frame address (stack pointer) value
128                                         // at the beginning of the function that uniquely
129                                         // identifies this frame (along with m_symbol_scope below)
130     SymbolContextScope *m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
131                                         // If not nullptr, this will either be the scope for the 
132                                         // lexical block for the frame, or the scope 
133                                         // for the symbol. Symbol context scopes are 
134                                         // always be unique pointers since the are part
135                                         // of the Block and Symbol objects and can easily
136                                         // be used to tell if a stack ID is the same as 
137                                         // another.
138 };
139
140 bool operator== (const StackID& lhs, const StackID& rhs);
141 bool operator!= (const StackID& lhs, const StackID& rhs);
142
143 // frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
144 bool operator<  (const StackID& lhs, const StackID& rhs);
145
146 } // namespace lldb_private
147
148 #endif // liblldb_StackID_h_