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 liblldb_Expression_h_
10 #define liblldb_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 
21 namespace lldb_private {
22 
23 class RecordingMemoryManager;
24 
25 /// \class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates
26 /// a single expression for use in lldb
27 ///
28 /// LLDB uses expressions for various purposes, notably to call functions
29 /// and as a backend for the expr command. Expression encapsulates the
30 /// objects needed to parse and interpret or JIT an expression. It uses the
31 /// expression parser appropriate to the language of the expression to produce
32 /// LLVM IR from the expression.
33 class Expression {
34 public:
35  /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
44  };
45 
47 
48  Expression(Target &target, ExpressionKind kind);
49 
51 
52  /// Destructor
53  virtual ~Expression() {}
54 
55  /// Return the string that the parser should parse. Must be a full
56  /// translation unit.
57  virtual const char *Text() = 0;
58 
59  /// Return the function name that should be used for executing the
60  /// expression. Text() should contain the definition of this function.
61  virtual const char *FunctionName() = 0;
62 
63  /// Return the language that should be used when parsing. To use the
64  /// default, return eLanguageTypeUnknown.
66 
67  /// Return the desired result type of the function, or eResultTypeAny if
68  /// indifferent.
70 
71  /// Flags
72 
73  /// Return true if validation code should be inserted into the expression.
74  virtual bool NeedsValidation() = 0;
75 
76  /// Return true if external variables in the expression should be resolved.
77  virtual bool NeedsVariableResolution() = 0;
78 
79  virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
80 
81  /// Return the address of the function's JIT-compiled code, or
82  /// LLDB_INVALID_ADDRESS if the function is not JIT compiled
84 
85  /// Called to notify the expression that it is about to be executed.
86  virtual void WillStartExecuting() {}
87 
88  /// Called to notify the expression that its execution has finished.
89  virtual void DidFinishExecuting() {}
90 
91  virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
92 
93  /// LLVM-style RTTI support.
94  ExpressionKind getKind() const { return m_kind; }
95 
96 private:
97  /// LLVM-style RTTI support.
98  const ExpressionKind m_kind;
99 protected:
100  lldb::TargetWP m_target_wp; /// Expression's always have to have a target...
101  lldb::ProcessWP m_jit_process_wp; /// An expression might have a process, but
102  /// it doesn't need to (e.g. calculator
103  /// mode.)
104  lldb::addr_t m_jit_start_addr; ///< The address of the JITted function within
105  ///the JIT allocation. LLDB_INVALID_ADDRESS if
106  ///invalid.
107  lldb::addr_t m_jit_end_addr; ///< The address of the JITted function within
108  ///the JIT allocation. LLDB_INVALID_ADDRESS if
109  ///invalid.
110 };
111 
112 } // namespace lldb_private
113 
114 #endif // liblldb_Expression_h_
virtual bool NeedsVariableResolution()=0
Return true if external variables in the expression should be resolved.
virtual ResultType DesiredResultType()
Return the desired result type of the function, or eResultTypeAny if indifferent. ...
Definition: Expression.h:69
virtual const char * FunctionName()=0
Return the function name that should be used for executing the expression.
ExpressionKind
Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
Definition: Expression.h:36
lldb::addr_t m_jit_start_addr
An expression might have a process, but it doesn&#39;t need to (e.g.
Definition: Expression.h:104
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
virtual ~Expression()
Destructor.
Definition: Expression.h:53
Encapsulates a single expression for use in lldb.
Definition: Expression.h:33
ExpressionKind getKind() const
LLVM-style RTTI support.
Definition: Expression.h:94
virtual ExpressionTypeSystemHelper * GetTypeSystemHelper()
Definition: Expression.h:91
virtual const char * Text()=0
Return the string that the parser should parse.
LanguageType
Programming language type.
lldb::addr_t StartAddress()
Return the address of the function&#39;s JIT-compiled code, or LLDB_INVALID_ADDRESS if the function is no...
Definition: Expression.h:83
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
lldb::ProcessWP m_jit_process_wp
Expression&#39;s always have to have a target...
Definition: Expression.h:101
virtual EvaluateExpressionOptions * GetOptions()
Definition: Expression.h:79
virtual void WillStartExecuting()
Called to notify the expression that it is about to be executed.
Definition: Expression.h:86
lldb::addr_t m_jit_end_addr
The address of the JITted function within the JIT allocation.
Definition: Expression.h:107
virtual bool NeedsValidation()=0
Flags.
uint64_t addr_t
Definition: lldb-types.h:83
Unknown or invalid language value.
virtual void DidFinishExecuting()
Called to notify the expression that its execution has finished.
Definition: Expression.h:89
Expression(Target &target, ExpressionKind kind)
Definition: Expression.cpp:15
lldb::TargetWP m_target_wp
Definition: Expression.h:100
"lldb/Expression/ExpressionTypeSystemHelper.h" A helper object that the Expression can pass to its Ex...
virtual lldb::LanguageType Language()
Return the language that should be used when parsing.
Definition: Expression.h:65