Coverage Report

Created: 2022-01-18 06:27

/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
  StackID()
21
22
542k
  {}
23
24
  explicit StackID(lldb::addr_t pc, lldb::addr_t cfa,
25
                   SymbolContextScope *symbol_scope)
26
35.4k
      : m_pc(pc), m_cfa(cfa), m_symbol_scope(symbol_scope) {}
27
28
  StackID(const StackID &rhs)
29
122k
      : m_pc(rhs.m_pc), m_cfa(rhs.m_cfa), m_symbol_scope(rhs.m_symbol_scope) {}
30
31
  ~StackID() = default;
32
33
55.0k
  lldb::addr_t GetPC() const { return m_pc; }
34
35
8.99M
  lldb::addr_t GetCallFrameAddress() const { return m_cfa; }
36
37
8.67M
  SymbolContextScope *GetSymbolContextScope() const { return m_symbol_scope; }
38
39
27.2k
  void SetSymbolContextScope(SymbolContextScope *symbol_scope) {
40
27.2k
    m_symbol_scope = symbol_scope;
41
27.2k
  }
42
43
378k
  void Clear() {
44
378k
    m_pc = LLDB_INVALID_ADDRESS;
45
378k
    m_cfa = LLDB_INVALID_ADDRESS;
46
378k
    m_symbol_scope = nullptr;
47
378k
  }
48
49
7.49M
  bool IsValid() const {
50
7.49M
    return m_pc != LLDB_INVALID_ADDRESS || 
m_cfa != 357k
LLDB_INVALID_ADDRESS357k
;
51
7.49M
  }
52
53
  void Dump(Stream *s);
54
55
  // Operators
56
184k
  const StackID &operator=(const StackID &rhs) {
57
184k
    if (this != &rhs) {
58
184k
      m_pc = rhs.m_pc;
59
184k
      m_cfa = rhs.m_cfa;
60
184k
      m_symbol_scope = rhs.m_symbol_scope;
61
184k
    }
62
184k
    return *this;
63
184k
  }
64
65
protected:
66
  friend class StackFrame;
67
68
5.35k
  void SetPC(lldb::addr_t pc) { m_pc = pc; }
69
70
0
  void SetCFA(lldb::addr_t cfa) { m_cfa = cfa; }
71
72
  lldb::addr_t m_pc =
73
      LLDB_INVALID_ADDRESS; // The pc value for the function/symbol for this
74
                            // frame. This will
75
  // only get used if the symbol scope is nullptr (the code where we are
76
  // stopped is not represented by any function or symbol in any shared
77
  // library).
78
  lldb::addr_t m_cfa =
79
      LLDB_INVALID_ADDRESS; // The call frame address (stack pointer) value
80
                            // at the beginning of the function that uniquely
81
                            // identifies this frame (along with m_symbol_scope
82
                            // below)
83
  SymbolContextScope *m_symbol_scope =
84
      nullptr; // If nullptr, there is no block or symbol for this frame.
85
               // If not nullptr, this will either be the scope for the
86
               // lexical block for the frame, or the scope for the
87
               // symbol. Symbol context scopes are always be unique
88
               // pointers since the are part of the Block and Symbol
89
               // objects and can easily be used to tell if a stack ID
90
               // is the same as another.
91
};
92
93
bool operator==(const StackID &lhs, const StackID &rhs);
94
bool operator!=(const StackID &lhs, const StackID &rhs);
95
96
// frame_id_1 < frame_id_2 means "frame_id_1 is YOUNGER than frame_id_2"
97
bool operator<(const StackID &lhs, const StackID &rhs);
98
99
} // namespace lldb_private
100
101
#endif // LLDB_TARGET_STACKID_H