Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:55

0001 //===-- StackID.h -----------------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_TARGET_STACKID_H
0010 #define LLDB_TARGET_STACKID_H
0011 
0012 #include "lldb/Core/AddressRange.h"
0013 #include "lldb/lldb-private.h"
0014 
0015 namespace lldb_private {
0016 
0017 class StackID {
0018 public:
0019   // Constructors and Destructors
0020   StackID() = default;
0021 
0022   explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
0023                    SymbolContextScope *symbol_scope)
0024       : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {}
0025 
0026   StackID(const StackID &rhs)
0027       : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
0028 
0029   ~StackID() = default;
0030 
0031   lldb::addr_t GetPC() const { return m_pc; }
0032 
0033   lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
0034 
0035   SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
0036 
0037   void SetSymbolContextScope(SymbolContextScope *symbol_scope) {
0038     m_symbol_scope = symbol_scope;
0039   }
0040 
0041   void Clear() {
0042     m_pc = LLDB_INVALID_ADDRESS;
0043     m_cfa = LLDB_INVALID_ADDRESS;
0044     m_symbol_scope = nullptr;
0045   }
0046 
0047   bool IsValid() const {
0048     return m_pc != LLDB_INVALID_ADDRESS || m_cfa != LLDB_INVALID_ADDRESS;
0049   }
0050 
0051   void Dump(Stream *s);
0052 
0053   // Operators
0054   const StackID &operator=(const StackID &rhs) {
0055     if (this != &rhs) {
0056       m_pc = rhs.m_pc;
0057       m_cfa = rhs.m_cfa;
0058       m_symbol_scope = rhs.m_symbol_scope;
0059     }
0060     return *this;
0061   }
0062 
0063 protected:
0064   friend class StackFrame;
0065 
0066   void SetPC(lldb::addr_t pc) { m_pc = pc; }
0067 
0068   void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
0069 
0070   lldb::addr_t m_pc =
0071       LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
0072                             // frame. This will
0073   // only get used if the symbol scope is nullptr (the code where we are
0074   // stopped is not represented by any function or symbol in any shared
0075   // library).
0076   lldb::addr_t m_cfa =
0077       LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
0078                             // at the beginning of the function that uniquely
0079                             // identifies this frame (along with m_symbol_scope
0080                             // below)
0081   SymbolContextScope *m_symbol_scope =
0082       nullptr; // If nullptr, there is no block or symbol for this frame.
0083                // If not nullptr, this will either be the scope for the
0084                // lexical block for the frame, or the scope for the
0085                // symbol. Symbol context scopes are always be unique
0086                // pointers since the are part of the Block and Symbol
0087                // objects and can easily be used to tell if a stack ID
0088                // is the same as another.
0089 };
0090 
0091 bool operator==(const StackID &lhs, const StackID &rhs);
0092 bool operator!=(const StackID &lhs, const StackID &rhs);
0093 
0094 // frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
0095 bool operator<(const StackID &lhs, const StackID &rhs);
0096 
0097 } // namespace lldb_private
0098 
0099 #endif // LLDB_TARGET_STACKID_H