StackID.h revision 4fb08150367853dae24bb92904356788e919a72f
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 20namespace lldb_private { 21 22class StackID 23{ 24public: 25 //------------------------------------------------------------------ 26 // Constructors and Destructors 27 //------------------------------------------------------------------ 28 StackID () : 29 m_start_pc (LLDB_INVALID_ADDRESS), 30 m_cfa (LLDB_INVALID_ADDRESS), 31 m_symbol_scope (NULL) 32 { 33 } 34 35 explicit 36 StackID (lldb::addr_t start_pc, lldb::addr_t cfa, SymbolContextScope *symbol_scope) : 37 m_start_pc (start_pc), 38 m_cfa (cfa), 39 m_symbol_scope (symbol_scope) 40 { 41 } 42 43 StackID (const StackID& rhs) : 44 m_start_pc (rhs.m_start_pc), 45 m_cfa (rhs.m_cfa), 46 m_symbol_scope (rhs.m_symbol_scope) 47 { 48 } 49 50 ~StackID() 51 { 52 } 53 54 const lldb::addr_t 55 GetStartAddress() const 56 { 57 return m_start_pc; 58 } 59 60 void 61 SetStartAddress(lldb::addr_t start_pc) 62 { 63 m_start_pc = start_pc; 64 } 65 66 lldb::addr_t 67 GetCallFrameAddress() const 68 { 69 return m_cfa; 70 } 71 72 SymbolContextScope * 73 GetSymbolContextScope () const 74 { 75 return m_symbol_scope; 76 } 77 78 void 79 SetSymbolContextScope (SymbolContextScope *symbol_scope) 80 { 81 m_symbol_scope = symbol_scope; 82 } 83 84 void 85 Dump (Stream *s); 86 87 //------------------------------------------------------------------ 88 // Operators 89 //------------------------------------------------------------------ 90 const StackID& 91 operator=(const StackID& rhs) 92 { 93 if (this != &rhs) 94 { 95 m_start_pc = rhs.m_start_pc; 96 m_cfa = rhs.m_cfa; 97 m_symbol_scope = rhs.m_symbol_scope; 98 } 99 return *this; 100 } 101 102protected: 103 //------------------------------------------------------------------ 104 // Classes that inherit from StackID can see and modify these 105 //------------------------------------------------------------------ 106 lldb::addr_t m_start_pc; // The start address for the function/symbol for this frame 107 lldb::addr_t m_cfa; // The call frame address (stack pointer) value 108 // at the beginning of the function that uniquely 109 // identifies this frame (along with m_symbol_scope below) 110 SymbolContextScope *m_symbol_scope; // If NULL, there is no block or symbol for this frame. 111 // If not NULL, this will either be the scope for the 112 // lexical block for the frame, or the scope 113 // for the symbol. Symbol context scopes are 114 // always be unique pointers since the are part 115 // of the Block and Symbol objects and can easily 116 // be used to tell if a stack ID is the same as 117 // another. 118}; 119 120bool operator== (const StackID& lhs, const StackID& rhs); 121bool operator!= (const StackID& lhs, const StackID& rhs); 122bool operator< (const StackID& lhs, const StackID& rhs); 123 124} // namespace lldb_private 125 126#endif // liblldb_StackID_h_ 127