LLDB  mainline
StackID.h
Go to the documentation of this file.
1 //===-- StackID.h -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_StackID_h_
10 #define liblldb_StackID_h_
11 
12 #include "lldb/Core/AddressRange.h"
13 #include "lldb/lldb-private.h"
14 
15 namespace lldb_private {
16 
17 class StackID {
18 public:
19  // Constructors and Destructors
22  m_symbol_scope(nullptr) {}
23 
25  SymbolContextScope *symbol_scope)
26  : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {}
27 
28  StackID(const StackID &rhs)
29  : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
30 
31  ~StackID() = default;
32 
33  lldb::addr_t GetPC() const { return m_pc; }
34 
36 
38 
40  m_symbol_scope = symbol_scope;
41  }
42 
43  void Clear() {
46  m_symbol_scope = nullptr;
47  }
48 
49  bool IsValid() const {
51  }
52 
53  void Dump(Stream *s);
54 
55  // Operators
56  const StackID &operator=(const StackID &rhs) {
57  if (this != &rhs) {
58  m_pc = rhs.m_pc;
59  m_cfa = rhs.m_cfa;
61  }
62  return *this;
63  }
64 
65 protected:
66  friend class StackFrame;
67 
68  void SetPC(lldb::addr_t pc) { m_pc = pc; }
69 
70  void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
71 
73  m_pc; // The pc value for the function/symbol for this frame. This will
74  // only get used if the symbol scope is nullptr (the code where we are
75  // stopped is not represented by any function or symbol in any shared
76  // library).
77  lldb::addr_t m_cfa; // The call frame address (stack pointer) value
78  // at the beginning of the function that uniquely
79  // identifies this frame (along with m_symbol_scope
80  // below)
82  m_symbol_scope; // If nullptr, there is no block or symbol for this frame.
83  // If not nullptr, this will either be the scope for the
84  // lexical block for the frame, or the scope for the
85  // symbol. Symbol context scopes are always be unique
86  // pointers since the are part of the Block and Symbol
87  // objects and can easily be used to tell if a stack ID
88  // is the same as another.
89 };
90 
91 bool operator==(const StackID &lhs, const StackID &rhs);
92 bool operator!=(const StackID &lhs, const StackID &rhs);
93 
94 // frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
95 bool operator<(const StackID &lhs, const StackID &rhs);
96 
97 } // namespace lldb_private
98 
99 #endif // liblldb_StackID_h_
lldb::addr_t m_cfa
Definition: StackID.h:77
void SetCFA(lldb::addr_t cfa)
Definition: StackID.h:70
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
lldb::addr_t m_pc
Definition: StackID.h:73
lldb::addr_t GetPC() const
Definition: StackID.h:33
const StackID & operator=(const StackID &rhs)
Definition: StackID.h:56
lldb::addr_t GetCallFrameAddress() const
Definition: StackID.h:35
SymbolContextScope * GetSymbolContextScope() const
Definition: StackID.h:37
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:973
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
SymbolContextScope * m_symbol_scope
Definition: StackID.h:82
void Dump(Stream *s)
Definition: StackID.cpp:17
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:979
uint64_t addr_t
Definition: lldb-types.h:83
StackID(const StackID &rhs)
Definition: StackID.h:28
void SetSymbolContextScope(SymbolContextScope *symbol_scope)
Definition: StackID.h:39
void SetPC(lldb::addr_t pc)
Definition: StackID.h:68
bool IsValid() const
Definition: StackID.h:49
bool operator<(const Address &lhs, const Address &rhs)
Definition: Address.cpp:942
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
This base class provides an interface to stack frames.
Definition: StackFrame.h:40
StackID(lldb::addr_t pc, lldb::addr_t cfa, SymbolContextScope *symbol_scope)
Definition: StackID.h:24