Coverage Report

Created: 2023-09-12 09:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Expression/Expression.h
Line
Count
Source (jump to first uncovered line)
1
//===-- Expression.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_EXPRESSION_EXPRESSION_H
10
#define LLDB_EXPRESSION_EXPRESSION_H
11
12
#include <map>
13
#include <string>
14
#include <vector>
15
16
17
#include "lldb/Expression/ExpressionTypeSystemHelper.h"
18
#include "lldb/lldb-forward.h"
19
#include "lldb/lldb-private.h"
20
21
namespace lldb_private {
22
23
/// \class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates
24
/// a single expression for use in lldb
25
///
26
/// LLDB uses expressions for various purposes, notably to call functions
27
/// and as a backend for the expr command.  Expression encapsulates the
28
/// objects needed to parse and interpret or JIT an expression.  It uses the
29
/// expression parser appropriate to the language of the expression to produce
30
/// LLVM IR from the expression.
31
class Expression {
32
public:
33
  enum ResultType { eResultTypeAny, eResultTypeId };
34
35
  Expression(Target &target);
36
37
  Expression(ExecutionContextScope &exe_scope);
38
39
  /// Destructor
40
10.8k
  virtual ~Expression() = default;
41
42
  /// Return the string that the parser should parse.  Must be a full
43
  /// translation unit.
44
  virtual const char *Text() = 0;
45
46
  /// Return the function name that should be used for executing the
47
  /// expression.  Text() should contain the definition of this function.
48
  virtual const char *FunctionName() = 0;
49
50
  /// Return the language that should be used when parsing.  To use the
51
  /// default, return eLanguageTypeUnknown.
52
14.1k
  virtual lldb::LanguageType Language() const {
53
14.1k
    return lldb::eLanguageTypeUnknown;
54
14.1k
  }
55
56
  /// Return the Materializer that the parser should use when registering
57
  /// external values.
58
0
  virtual Materializer *GetMaterializer() { return nullptr; }
59
60
  /// Return the desired result type of the function, or eResultTypeAny if
61
  /// indifferent.
62
4.14k
  virtual ResultType DesiredResultType() { return eResultTypeAny; }
63
64
  /// Flags
65
66
  /// Return true if validation code should be inserted into the expression.
67
  virtual bool NeedsValidation() = 0;
68
69
  /// Return true if external variables in the expression should be resolved.
70
  virtual bool NeedsVariableResolution() = 0;
71
72
0
  virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
73
74
  /// Return the address of the function's JIT-compiled code, or
75
  /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
76
2.96k
  lldb::addr_t StartAddress() { return m_jit_start_addr; }
77
78
  /// Called to notify the expression that it is about to be executed.
79
1.08k
  virtual void WillStartExecuting() {}
80
81
  /// Called to notify the expression that its execution has finished.
82
1.07k
  virtual void DidFinishExecuting() {}
83
84
0
  virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
85
86
  // LLVM RTTI support
87
  virtual bool isA(const void *ClassID) const = 0;
88
89
protected:
90
  lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
91
  lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
92
                                    /// it doesn't need to (e.g. calculator
93
                                    /// mode.)
94
  lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within
95
                                 ///the JIT allocation.  LLDB_INVALID_ADDRESS if
96
                                 ///invalid.
97
  lldb::addr_t m_jit_end_addr;   ///< The address of the JITted function within
98
                                 ///the JIT allocation.  LLDB_INVALID_ADDRESS if
99
                                 ///invalid.
100
};
101
102
} // namespace lldb_private
103
104
#endif // LLDB_EXPRESSION_EXPRESSION_H