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_
15 // Other libraries and framework includes
17 #include "lldb/Core/AddressRange.h"
18 #include "lldb/lldb-private.h"
20 namespace lldb_private {
24 //------------------------------------------------------------------
25 // Constructors and Destructors
26 //------------------------------------------------------------------
28 : m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS),
29 m_symbol_scope(nullptr) {}
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) {}
35 StackID(const StackID &rhs)
36 : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
40 lldb::addr_t GetPC() const { return m_pc; }
42 lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
44 SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
46 void SetSymbolContextScope(SymbolContextScope *symbol_scope) {
47 m_symbol_scope = symbol_scope;
51 m_pc = LLDB_INVALID_ADDRESS;
52 m_cfa = LLDB_INVALID_ADDRESS;
53 m_symbol_scope = nullptr;
56 bool IsValid() const {
57 return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
62 //------------------------------------------------------------------
64 //------------------------------------------------------------------
65 const StackID &operator=(const StackID &rhs) {
69 m_symbol_scope = rhs.m_symbol_scope;
75 friend class StackFrame;
77 void SetPC(lldb::addr_t pc) { m_pc = pc; }
79 void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
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
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
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.
100 bool operator==(const StackID &lhs, const StackID &rhs);
101 bool operator!=(const StackID &lhs, const StackID &rhs);
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);
106 } // namespace lldb_private
108 #endif // liblldb_StackID_h_