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 LLDB_TARGET_STACKID_H
10#define LLDB_TARGET_STACKID_H
11
13
14namespace lldb_private {
15
16class Process;
17
18/// How the call frame addresses of two frames order them.
20
21class StackID {
22public:
23 StackID() = default;
24
25 explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
26 SymbolContextScope *symbol_scope, Process *process);
27
28 ~StackID() = default;
29
30 lldb::addr_t GetPC() const { return m_pc; }
31
35
37
39
41 m_symbol_scope = symbol_scope;
42 }
43
44 uint32_t GetTailCallDepth() const { return m_tail_call_depth; }
45
46 void SetTailCallDepth(uint32_t depth) { m_tail_call_depth = depth; }
47
54
55 bool IsValid() const {
57 }
58
59 void Dump(Stream *s);
60
61 /// Returns true if this StackID corresponds to a frame younger (i.e. higher
62 /// on the call stack) than `other`, and false otherwise (including when the
63 /// frames are not comparable, in some cases where this can be detected).
64 /// \p process and then its language runtimes get the first say, see
65 /// Process::CompareCFAs() and LanguageRuntime::CompareCFAs().
66 bool IsYoungerThan(const StackID &other, Process &process) const;
67
68protected:
69 friend class StackFrame;
71
72 void SetPC(lldb::addr_t pc, Process *process);
73 void SetCFA(lldb::addr_t cfa, Process *process);
74
75 /// The pc value for the function/symbol for this frame. This will only get
76 /// used if the symbol scope is nullptr (the code where we are stopped is not
77 /// represented by any function or symbol in any shared library).
79
80 /// The call frame address (stack pointer) value at the beginning of the
81 /// function that uniquely identifies this frame (along with m_symbol_scope
82 /// below)
84
85 /// The cfa with metadata (i.e. prior to Process::FixAddress).
87
88 /// If nullptr, there is no block or symbol for this frame. If not nullptr,
89 /// this will either be the scope for the lexical block for the frame, or the
90 /// scope for the symbol. Symbol context scopes are always be unique pointers
91 /// since the are part of the Block and Symbol objects and can easily be used
92 /// to tell if a stack ID is the same as another.
94
95 /// For a synthesized tail call frame, which has the CFA of the younger frame
96 /// that replaced it, its position in the chain of tail calls after that
97 /// frame (1, 2, ...). 0 for every other frame.
98 uint32_t m_tail_call_depth = 0;
99};
100
101bool operator==(const StackID &lhs, const StackID &rhs);
102bool operator!=(const StackID &lhs, const StackID &rhs);
103} // namespace lldb_private
104
105#endif // LLDB_TARGET_STACKID_H
A plug-in interface definition class for debugging a process.
Definition Process.h:370
void Dump(Stream *s)
Definition StackID.cpp:38
lldb::addr_t m_cfa
The call frame address (stack pointer) value at the beginning of the function that uniquely identifie...
Definition StackID.h:83
lldb::addr_t GetCallFrameAddressWithoutMetadata() const
Definition StackID.h:36
void SetPC(lldb::addr_t pc, Process *process)
Definition StackID.cpp:29
bool IsValid() const
Definition StackID.h:55
SymbolContextScope * GetSymbolContextScope() const
Definition StackID.h:38
uint32_t m_tail_call_depth
For a synthesized tail call frame, which has the CFA of the younger frame that replaced it,...
Definition StackID.h:98
lldb::addr_t m_pc
The pc value for the function/symbol for this frame.
Definition StackID.h:78
friend class SyntheticStackFrameList
Definition StackID.h:70
lldb::addr_t GetPC() const
Definition StackID.h:30
lldb::addr_t m_cfa_with_metadata
The cfa with metadata (i.e. prior to Process::FixAddress).
Definition StackID.h:86
friend class StackFrame
Definition StackID.h:69
SymbolContextScope * m_symbol_scope
If nullptr, there is no block or symbol for this frame.
Definition StackID.h:93
uint32_t GetTailCallDepth() const
Definition StackID.h:44
bool IsYoungerThan(const StackID &other, Process &process) const
Returns true if this StackID corresponds to a frame younger (i.e.
Definition StackID.cpp:78
void SetSymbolContextScope(SymbolContextScope *symbol_scope)
Definition StackID.h:40
lldb::addr_t GetCallFrameAddressWithMetadata() const
Definition StackID.h:32
void SetTailCallDepth(uint32_t depth)
Definition StackID.h:46
void SetCFA(lldb::addr_t cfa, Process *process)
Definition StackID.cpp:33
A stream class that can stream formatted output to a file.
Definition Stream.h:28
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
bool operator!=(const Address &lhs, const Address &rhs)
Definition Address.cpp:1011
bool operator==(const Address &lhs, const Address &rhs)
Definition Address.cpp:1005
CFAComparison
How the call frame addresses of two frames order them.
Definition StackID.h:19
uint64_t addr_t
Definition lldb-types.h:80