Coverage Report

Created: 2023-09-21 18:56

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Symbol/Variable.h
Line
Count
Source (jump to first uncovered line)
1
//===-- Variable.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_SYMBOL_VARIABLE_H
10
#define LLDB_SYMBOL_VARIABLE_H
11
12
#include "lldb/Core/Declaration.h"
13
#include "lldb/Core/Mangled.h"
14
#include "lldb/Expression/DWARFExpressionList.h"
15
#include "lldb/Utility/CompletionRequest.h"
16
#include "lldb/Utility/RangeMap.h"
17
#include "lldb/Utility/UserID.h"
18
#include "lldb/lldb-enumerations.h"
19
#include "lldb/lldb-private.h"
20
#include <memory>
21
#include <vector>
22
23
namespace lldb_private {
24
25
class Variable : public UserID, public std::enable_shared_from_this<Variable> {
26
public:
27
  typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList;
28
29
  /// Constructors and Destructors.
30
  ///
31
  /// \param mangled The mangled or fully qualified name of the variable.
32
  Variable(lldb::user_id_t uid, const char *name, const char *mangled,
33
           const lldb::SymbolFileTypeSP &symfile_type_sp, lldb::ValueType scope,
34
           SymbolContextScope *owner_scope, const RangeList &scope_range,
35
           Declaration *decl, const DWARFExpressionList &location,
36
           bool external, bool artificial, bool location_is_constant_data,
37
           bool static_member = false);
38
39
  virtual ~Variable();
40
41
  void Dump(Stream *s, bool show_context) const;
42
43
  bool DumpDeclaration(Stream *s, bool show_fullpaths, bool show_module);
44
45
186
  const Declaration &GetDeclaration() const { return m_declaration; }
46
47
  ConstString GetName() const;
48
49
  ConstString GetUnqualifiedName() const;
50
51
77.1k
  SymbolContextScope *GetSymbolContextScope() const { return m_owner_scope; }
52
53
  /// Since a variable can have a basename "i" and also a mangled named
54
  /// "_ZN12_GLOBAL__N_11iE" and a demangled mangled name "(anonymous
55
  /// namespace)::i", this function will allow a generic match function that can
56
  /// be called by commands and expression parsers to make sure we match
57
  /// anything we come across.
58
  bool NameMatches(ConstString name) const;
59
60
  bool NameMatches(const RegularExpression &regex) const;
61
62
  Type *GetType();
63
64
  lldb::LanguageType GetLanguage() const;
65
66
29.9k
  lldb::ValueType GetScope() const { return m_scope; }
67
68
123
  const RangeList &GetScopeRange() const { return m_scope_range; }
69
70
0
  bool IsExternal() const { return m_external; }
71
72
1.76k
  bool IsArtificial() const { return m_artificial; }
73
74
5.74k
  bool IsStaticMember() const { return m_static_member; }
75
76
28.7k
  DWARFExpressionList &LocationExpressionList() { return m_location_list; }
77
78
0
  const DWARFExpressionList &LocationExpressionList() const {
79
0
    return m_location_list;
80
0
  }
81
82
  // When given invalid address, it dumps all locations. Otherwise it only dumps
83
  // the location that contains this address.
84
  bool DumpLocations(Stream *s, const Address &address);
85
86
  size_t MemorySize() const;
87
88
  void CalculateSymbolContext(SymbolContext *sc);
89
90
  bool IsInScope(StackFrame *frame);
91
92
  bool LocationIsValidForFrame(StackFrame *frame);
93
94
  bool LocationIsValidForAddress(const Address &address);
95
96
28.3k
  bool GetLocationIsConstantValueData() const { return m_loc_is_const_data; }
97
98
0
  void SetLocationIsConstantValueData(bool b) { m_loc_is_const_data = b; }
99
100
  typedef size_t (*GetVariableCallback)(void *baton, const char *name,
101
                                        VariableList &var_list);
102
103
  static Status GetValuesForVariableExpressionPath(
104
      llvm::StringRef variable_expr_path, ExecutionContextScope *scope,
105
      GetVariableCallback callback, void *baton, VariableList &variable_list,
106
      ValueObjectList &valobj_list);
107
108
  static void AutoComplete(const ExecutionContext &exe_ctx,
109
                           CompletionRequest &request);
110
111
  CompilerDeclContext GetDeclContext();
112
113
  CompilerDecl GetDecl();
114
115
protected:
116
  /// The basename of the variable (no namespaces).
117
  ConstString m_name;
118
  /// The mangled name of the variable.
119
  Mangled m_mangled;
120
  /// The type pointer of the variable (int, struct, class, etc)
121
  /// global, parameter, local.
122
  lldb::SymbolFileTypeSP m_symfile_type_sp;
123
  lldb::ValueType m_scope;
124
  /// The symbol file scope that this variable was defined in
125
  SymbolContextScope *m_owner_scope;
126
  /// The list of ranges inside the owner's scope where this variable
127
  /// is valid.
128
  RangeList m_scope_range;
129
  /// Declaration location for this item.
130
  Declaration m_declaration;
131
  /// The location of this variable that can be fed to
132
  /// DWARFExpression::Evaluate().
133
  DWARFExpressionList m_location_list;
134
  /// Visible outside the containing compile unit?
135
  unsigned m_external : 1;
136
  /// Non-zero if the variable is not explicitly declared in source.
137
  unsigned m_artificial : 1;
138
  /// The m_location expression contains the constant variable value
139
  /// data, not a DWARF location.
140
  unsigned m_loc_is_const_data : 1;
141
  /// Non-zero if variable is static member of a class or struct.
142
  unsigned m_static_member : 1;
143
144
private:
145
  Variable(const Variable &rhs) = delete;
146
  Variable &operator=(const Variable &rhs) = delete;
147
};
148
149
} // namespace lldb_private
150
151
#endif // LLDB_SYMBOL_VARIABLE_H