• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     //------------------------------------------------------------------
StackID()28     StackID () :
29         m_pc (LLDB_INVALID_ADDRESS),
30         m_cfa (LLDB_INVALID_ADDRESS),
31         m_symbol_scope (NULL)
32     {
33     }
34 
35     explicit
StackID(lldb::addr_t pc,lldb::addr_t cfa,SymbolContextScope * symbol_scope)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 
StackID(const StackID & rhs)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 
~StackID()50     ~StackID()
51     {
52     }
53 
54     lldb::addr_t
GetPC()55     GetPC() const
56     {
57         return m_pc;
58     }
59 
60     lldb::addr_t
GetCallFrameAddress()61     GetCallFrameAddress() const
62     {
63         return m_cfa;
64     }
65 
66     SymbolContextScope *
GetSymbolContextScope()67     GetSymbolContextScope () const
68     {
69         return m_symbol_scope;
70     }
71 
72     void
SetSymbolContextScope(SymbolContextScope * symbol_scope)73     SetSymbolContextScope (SymbolContextScope *symbol_scope)
74     {
75         m_symbol_scope = symbol_scope;
76     }
77 
78     void
Clear()79     Clear ()
80     {
81         m_pc = LLDB_INVALID_ADDRESS;
82         m_cfa = LLDB_INVALID_ADDRESS;
83         m_symbol_scope = NULL;
84     }
85 
86     bool
IsValid()87     IsValid () const
88     {
89         return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
90     }
91 
92     void
93     Dump (Stream *s);
94 
95     //------------------------------------------------------------------
96     // Operators
97     //------------------------------------------------------------------
98     const StackID&
99     operator=(const StackID& rhs)
100     {
101         if (this != &rhs)
102         {
103             m_pc = rhs.m_pc;
104             m_cfa = rhs.m_cfa;
105             m_symbol_scope = rhs.m_symbol_scope;
106         }
107         return *this;
108     }
109 
110 protected:
111 
112     friend class StackFrame;
113 
114     void
SetPC(lldb::addr_t pc)115     SetPC (lldb::addr_t pc)
116     {
117         m_pc = pc;
118     }
119 
120 
121     //------------------------------------------------------------------
122     // Classes that inherit from StackID can see and modify these
123     //------------------------------------------------------------------
124     lldb::addr_t m_pc;                  // The pc value for the function/symbol for this frame. This will
125                                         // only get used if the symbol scope is NULL (the code where we are
126                                         // stopped is not represented by any function or symbol in any
127                                         // shared library).
128     lldb::addr_t m_cfa;                 // The call frame address (stack pointer) value
129                                         // at the beginning of the function that uniquely
130                                         // identifies this frame (along with m_symbol_scope below)
131     SymbolContextScope *m_symbol_scope; // If NULL, there is no block or symbol for this frame.
132                                         // If not NULL, this will either be the scope for the
133                                         // lexical block for the frame, or the scope
134                                         // for the symbol. Symbol context scopes are
135                                         // always be unique pointers since the are part
136                                         // of the Block and Symbol objects and can easily
137                                         // be used to tell if a stack ID is the same as
138                                         // another.
139 };
140 
141 bool operator== (const StackID& lhs, const StackID& rhs);
142 bool operator!= (const StackID& lhs, const StackID& rhs);
143 
144 // frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
145 bool operator<  (const StackID& lhs, const StackID& rhs);
146 
147 } // namespace lldb_private
148 
149 #endif  // liblldb_StackID_h_
150