/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Target/StackID.h
Line | Count | Source (jump to first uncovered line) |
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 | | |
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 |
20 | 490k | StackID() = default; |
21 | | |
22 | | explicit StackID(lldb::addr_t pc, lldb::addr_t cfa, |
23 | | SymbolContextScope *symbol_scope) |
24 | 200k | : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {} |
25 | | |
26 | | StackID(const StackID &rhs) |
27 | 101k | : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {} |
28 | | |
29 | | ~StackID() = default; |
30 | | |
31 | 68.1k | lldb::addr_t GetPC() const { return m_pc; } |
32 | | |
33 | 8.07M | lldb::addr_t GetCallFrameAddress() const { return m_cfa; } |
34 | | |
35 | 7.85M | SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; } |
36 | | |
37 | 19.9k | void SetSymbolContextScope(SymbolContextScope *symbol_scope) { |
38 | 19.9k | m_symbol_scope = symbol_scope; |
39 | 19.9k | } |
40 | | |
41 | 362k | void Clear() { |
42 | 362k | m_pc = LLDB_INVALID_ADDRESS; |
43 | 362k | m_cfa = LLDB_INVALID_ADDRESS; |
44 | 362k | m_symbol_scope = nullptr; |
45 | 362k | } |
46 | | |
47 | 6.81M | bool IsValid() const { |
48 | 6.81M | return m_pc != LLDB_INVALID_ADDRESS || m_cfa != 359k LLDB_INVALID_ADDRESS359k ; |
49 | 6.81M | } |
50 | | |
51 | | void Dump(Stream *s); |
52 | | |
53 | | // Operators |
54 | 139k | const StackID &operator=(const StackID &rhs) { |
55 | 139k | if (this != &rhs) { |
56 | 139k | m_pc = rhs.m_pc; |
57 | 139k | m_cfa = rhs.m_cfa; |
58 | 139k | m_symbol_scope = rhs.m_symbol_scope; |
59 | 139k | } |
60 | 139k | return *this; |
61 | 139k | } |
62 | | |
63 | | protected: |
64 | | friend class StackFrame; |
65 | | |
66 | 3.46k | void SetPC(lldb::addr_t pc) { m_pc = pc; } |
67 | | |
68 | 0 | void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; } |
69 | | |
70 | | lldb::addr_t m_pc = |
71 | | LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this |
72 | | // frame. This will |
73 | | // only get used if the symbol scope is nullptr (the code where we are |
74 | | // stopped is not represented by any function or symbol in any shared |
75 | | // library). |
76 | | lldb::addr_t m_cfa = |
77 | | LLDB_INVALID_ADDRESS; // 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) |
81 | | SymbolContextScope *m_symbol_scope = |
82 | | nullptr; // 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 // LLDB_TARGET_STACKID_H |