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