LLDB mainline
Expression.h
Go to the documentation of this file.
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
18#include "lldb/lldb-forward.h"
19#include "lldb/lldb-private.h"
20
21namespace 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.
32public:
34
35 Expression(Target &target);
36
38
39 /// Destructor
40 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.
51 virtual SourceLanguage Language() const { return {}; }
52
53 /// Return the Materializer that the parser should use when registering
54 /// external values.
55 virtual Materializer *GetMaterializer() { return nullptr; }
56
57 /// Return the desired result type of the function, or eResultTypeAny if
58 /// indifferent.
59 virtual ResultType DesiredResultType() const { return eResultTypeAny; }
60
61 /// Flags
62
63 /// Return true if validation code should be inserted into the expression.
64 virtual bool NeedsValidation() = 0;
65
66 /// Return true if external variables in the expression should be resolved.
67 virtual bool NeedsVariableResolution() = 0;
68
69 virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
70
71 /// Return the address of the function's JIT-compiled code, or
72 /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
74
75 /// Called to notify the expression that it is about to be executed.
76 virtual void WillStartExecuting() {}
77
78 /// Called to notify the expression that its execution has finished.
79 virtual void DidFinishExecuting() {}
80
81 virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
82
83 // LLVM RTTI support
84 virtual bool isA(const void *ClassID) const = 0;
85
86protected:
87 lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
88 lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
89 /// it doesn't need to (e.g. calculator
90 /// mode.)
91 lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within
92 ///the JIT allocation. LLDB_INVALID_ADDRESS if
93 ///invalid.
94 lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within
95 ///the JIT allocation. LLDB_INVALID_ADDRESS if
96 ///invalid.
97};
98
99} // namespace lldb_private
100
101#endif // LLDB_EXPRESSION_EXPRESSION_H
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
"lldb/Expression/ExpressionTypeSystemHelper.h" A helper object that the Expression can pass to its Ex...
Encapsulates a single expression for use in lldb.
Definition: Expression.h:31
virtual bool NeedsValidation()=0
Flags.
virtual const char * Text()=0
Return the string that the parser should parse.
lldb::addr_t m_jit_end_addr
The address of the JITted function within the JIT allocation.
Definition: Expression.h:94
virtual SourceLanguage Language() const
Return the language that should be used when parsing.
Definition: Expression.h:51
lldb::ProcessWP m_jit_process_wp
Expression's always have to have a target...
Definition: Expression.h:88
lldb::addr_t m_jit_start_addr
An expression might have a process, but it doesn't need to (e.g.
Definition: Expression.h:91
lldb::TargetWP m_target_wp
Definition: Expression.h:87
lldb::addr_t StartAddress()
Return the address of the function's JIT-compiled code, or LLDB_INVALID_ADDRESS if the function is no...
Definition: Expression.h:73
virtual void DidFinishExecuting()
Called to notify the expression that its execution has finished.
Definition: Expression.h:79
virtual EvaluateExpressionOptions * GetOptions()
Definition: Expression.h:69
virtual ResultType DesiredResultType() const
Return the desired result type of the function, or eResultTypeAny if indifferent.
Definition: Expression.h:59
virtual bool isA(const void *ClassID) const =0
virtual bool NeedsVariableResolution()=0
Return true if external variables in the expression should be resolved.
virtual ExpressionTypeSystemHelper * GetTypeSystemHelper()
Definition: Expression.h:81
virtual const char * FunctionName()=0
Return the function name that should be used for executing the expression.
virtual Materializer * GetMaterializer()
Return the Materializer that the parser should use when registering external values.
Definition: Expression.h:55
virtual void WillStartExecuting()
Called to notify the expression that it is about to be executed.
Definition: Expression.h:76
virtual ~Expression()=default
Destructor.
A class that represents a running process on the host machine.
std::weak_ptr< lldb_private::Process > ProcessWP
Definition: lldb-forward.h:392
uint64_t addr_t
Definition: lldb-types.h:80
std::weak_ptr< lldb_private::Target > TargetWP
Definition: lldb-forward.h:449
A type-erased pair of llvm::dwarf::SourceLanguageName and version.