1 //===-- StackID.h -----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_StackID_h_
11 #define liblldb_StackID_h_
13 #include "lldb/Core/AddressRange.h"
14 #include "lldb/lldb-private.h"
16 namespace lldb_private {
20 //------------------------------------------------------------------
21 // Constructors and Destructors
22 //------------------------------------------------------------------
24 : m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS),
25 m_symbol_scope(nullptr) {}
27 explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
28 SymbolContextScope *symbol_scope)
29 : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {}
31 StackID(const StackID &rhs)
32 : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
36 lldb::addr_t GetPC() const { return m_pc; }
38 lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
40 SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
42 void SetSymbolContextScope(SymbolContextScope *symbol_scope) {
43 m_symbol_scope = symbol_scope;
47 m_pc = LLDB_INVALID_ADDRESS;
48 m_cfa = LLDB_INVALID_ADDRESS;
49 m_symbol_scope = nullptr;
52 bool IsValid() const {
53 return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
58 //------------------------------------------------------------------
60 //------------------------------------------------------------------
61 const StackID &operator=(const StackID &rhs) {
65 m_symbol_scope = rhs.m_symbol_scope;
71 friend class StackFrame;
73 void SetPC(lldb::addr_t pc) { m_pc = pc; }
75 void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
78 m_pc; // The pc value for the function/symbol for this frame. This will
79 // only get used if the symbol scope is nullptr (the code where we are
80 // stopped is not represented by any function or symbol in any shared
82 lldb::addr_t m_cfa; // The call frame address (stack pointer) value
83 // at the beginning of the function that uniquely
84 // identifies this frame (along with m_symbol_scope
87 m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
88 // If not nullptr, this will either be the scope for the
89 // lexical block for the frame, or the scope for the
90 // symbol. Symbol context scopes are always be unique
91 // pointers since the are part of the Block and Symbol
92 // objects and can easily be used to tell if a stack ID
93 // is the same as another.
96 bool operator==(const StackID &lhs, const StackID &rhs);
97 bool operator!=(const StackID &lhs, const StackID &rhs);
99 // frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
100 bool operator<(const StackID &lhs, const StackID &rhs);
102 } // namespace lldb_private
104 #endif // liblldb_StackID_h_