forked from OSchip/llvm-project
Add the ability to pass an EvaluateExpressionOptions when you make a UserExpression. This
isn't used in this commit but will be in a future commit. llvm-svn: 251887
This commit is contained in:
parent
95c453a221
commit
19a63fc6fa
lldb
include/lldb
Expression
Symbol
Target
source
Breakpoint
Expression
Plugins/ExpressionParser
Symbol
Target
|
@ -109,6 +109,8 @@ public:
|
||||||
virtual bool
|
virtual bool
|
||||||
NeedsVariableResolution () = 0;
|
NeedsVariableResolution () = 0;
|
||||||
|
|
||||||
|
virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
/// Return the address of the function's JIT-compiled code, or
|
/// Return the address of the function's JIT-compiled code, or
|
||||||
/// LLDB_INVALID_ADDRESS if the function is not JIT compiled
|
/// LLDB_INVALID_ADDRESS if the function is not JIT compiled
|
||||||
|
|
|
@ -35,15 +35,23 @@ namespace lldb_private
|
||||||
class LLVMUserExpression : public UserExpression
|
class LLVMUserExpression : public UserExpression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
LLVMUserExpression(ExecutionContextScope &exe_scope,
|
||||||
lldb::LanguageType language, ResultType desired_type);
|
const char *expr,
|
||||||
|
const char *expr_prefix,
|
||||||
|
lldb::LanguageType language,
|
||||||
|
ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options);
|
||||||
~LLVMUserExpression() override;
|
~LLVMUserExpression() override;
|
||||||
|
|
||||||
lldb::ExpressionResults Execute(Stream &error_stream, ExecutionContext &exe_ctx,
|
lldb::ExpressionResults Execute(Stream &error_stream,
|
||||||
const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me,
|
ExecutionContext &exe_ctx,
|
||||||
|
const EvaluateExpressionOptions &options,
|
||||||
|
lldb::UserExpressionSP &shared_ptr_to_me,
|
||||||
lldb::ExpressionVariableSP &result) override;
|
lldb::ExpressionVariableSP &result) override;
|
||||||
|
|
||||||
bool FinalizeJITExecution(Stream &error_stream, ExecutionContext &exe_ctx, lldb::ExpressionVariableSP &result,
|
bool FinalizeJITExecution(Stream &error_stream,
|
||||||
|
ExecutionContext &exe_ctx,
|
||||||
|
lldb::ExpressionVariableSP &result,
|
||||||
lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
|
lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
|
||||||
lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;
|
lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "lldb/Expression/Expression.h"
|
#include "lldb/Expression/Expression.h"
|
||||||
#include "lldb/Expression/Materializer.h"
|
#include "lldb/Expression/Materializer.h"
|
||||||
#include "lldb/Target/ExecutionContext.h"
|
#include "lldb/Target/ExecutionContext.h"
|
||||||
|
#include "lldb/Target/Target.h"
|
||||||
|
|
||||||
namespace lldb_private
|
namespace lldb_private
|
||||||
{
|
{
|
||||||
|
@ -67,7 +68,8 @@ public:
|
||||||
const char *expr,
|
const char *expr,
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
ResultType desired_type);
|
ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options);
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
@ -236,6 +238,12 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EvaluateExpressionOptions *
|
||||||
|
GetOptions() override
|
||||||
|
{
|
||||||
|
return &m_options;
|
||||||
|
}
|
||||||
|
|
||||||
virtual lldb::ExpressionVariableSP
|
virtual lldb::ExpressionVariableSP
|
||||||
GetResultAfterDematerialization(ExecutionContextScope *exe_scope)
|
GetResultAfterDematerialization(ExecutionContextScope *exe_scope)
|
||||||
{
|
{
|
||||||
|
@ -319,7 +327,7 @@ protected:
|
||||||
std::string m_expr_prefix; ///< The text of the translation-level definitions, as provided by the user
|
std::string m_expr_prefix; ///< The text of the translation-level definitions, as provided by the user
|
||||||
lldb::LanguageType m_language; ///< The language to use when parsing (eLanguageTypeUnknown means use defaults)
|
lldb::LanguageType m_language; ///< The language to use when parsing (eLanguageTypeUnknown means use defaults)
|
||||||
ResultType m_desired_type; ///< The type to coerce the expression's result to. If eResultTypeAny, inferred from the expression.
|
ResultType m_desired_type; ///< The type to coerce the expression's result to. If eResultTypeAny, inferred from the expression.
|
||||||
|
EvaluateExpressionOptions m_options; ///< Additional options provided by the user.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lldb_private
|
} // namespace lldb_private
|
||||||
|
|
|
@ -1184,7 +1184,8 @@ public:
|
||||||
GetUserExpression (const char *expr,
|
GetUserExpression (const char *expr,
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type) override;
|
Expression::ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options) override;
|
||||||
|
|
||||||
FunctionCaller *
|
FunctionCaller *
|
||||||
GetFunctionCaller (const CompilerType &return_type,
|
GetFunctionCaller (const CompilerType &return_type,
|
||||||
|
|
|
@ -398,7 +398,8 @@ class GoASTContextForExpr : public GoASTContext
|
||||||
public:
|
public:
|
||||||
GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
|
GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
|
||||||
UserExpression *GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
|
UserExpression *GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type) override;
|
Expression::ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
lldb::TargetWP m_target_wp;
|
lldb::TargetWP m_target_wp;
|
||||||
|
|
|
@ -496,7 +496,8 @@ public:
|
||||||
GetUserExpression (const char *expr,
|
GetUserExpression (const char *expr,
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type)
|
Expression::ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1256,6 +1256,7 @@ public:
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type,
|
Expression::ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options,
|
||||||
Error &error);
|
Error &error);
|
||||||
|
|
||||||
// Creates a FunctionCaller for the given language, the rest of the parameters have the
|
// Creates a FunctionCaller for the given language, the rest of the parameters have the
|
||||||
|
|
|
@ -293,6 +293,7 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
|
||||||
nullptr,
|
nullptr,
|
||||||
language,
|
language,
|
||||||
Expression::eResultTypeAny,
|
Expression::eResultTypeAny,
|
||||||
|
EvaluateExpressionOptions(),
|
||||||
error));
|
error));
|
||||||
if (error.Fail())
|
if (error.Fail())
|
||||||
{
|
{
|
||||||
|
|
|
@ -387,6 +387,7 @@ Watchpoint::SetCondition (const char *condition)
|
||||||
nullptr,
|
nullptr,
|
||||||
lldb::eLanguageTypeUnknown,
|
lldb::eLanguageTypeUnknown,
|
||||||
UserExpression::eResultTypeAny,
|
UserExpression::eResultTypeAny,
|
||||||
|
EvaluateExpressionOptions(),
|
||||||
error));
|
error));
|
||||||
if (error.Fail())
|
if (error.Fail())
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,9 +40,13 @@
|
||||||
|
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
|
||||||
lldb::LanguageType language, ResultType desired_type)
|
const char *expr,
|
||||||
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type),
|
const char *expr_prefix,
|
||||||
|
lldb::LanguageType language,
|
||||||
|
ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options)
|
||||||
|
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options),
|
||||||
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
|
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
|
||||||
m_stack_frame_top(LLDB_INVALID_ADDRESS),
|
m_stack_frame_top(LLDB_INVALID_ADDRESS),
|
||||||
m_transformed_text(),
|
m_transformed_text(),
|
||||||
|
|
|
@ -45,13 +45,18 @@
|
||||||
|
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
UserExpression::UserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
UserExpression::UserExpression (ExecutionContextScope &exe_scope,
|
||||||
lldb::LanguageType language, ResultType desired_type)
|
const char *expr,
|
||||||
: Expression(exe_scope),
|
const char *expr_prefix,
|
||||||
|
lldb::LanguageType language,
|
||||||
|
ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options) :
|
||||||
|
Expression(exe_scope),
|
||||||
m_expr_text(expr),
|
m_expr_text(expr),
|
||||||
m_expr_prefix(expr_prefix ? expr_prefix : ""),
|
m_expr_prefix(expr_prefix ? expr_prefix : ""),
|
||||||
m_language(language),
|
m_language(language),
|
||||||
m_desired_type(desired_type)
|
m_desired_type(desired_type),
|
||||||
|
m_options (options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,6 +224,7 @@ UserExpression::Evaluate (ExecutionContext &exe_ctx,
|
||||||
full_prefix,
|
full_prefix,
|
||||||
language,
|
language,
|
||||||
desired_type,
|
desired_type,
|
||||||
|
options,
|
||||||
error));
|
error));
|
||||||
if (error.Fail())
|
if (error.Fail())
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,9 +55,13 @@
|
||||||
|
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
|
|
||||||
ClangUserExpression::ClangUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
ClangUserExpression::ClangUserExpression (ExecutionContextScope &exe_scope,
|
||||||
lldb::LanguageType language, ResultType desired_type)
|
const char *expr,
|
||||||
: LLVMUserExpression(exe_scope, expr, expr_prefix, language, desired_type),
|
const char *expr_prefix,
|
||||||
|
lldb::LanguageType language,
|
||||||
|
ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options) :
|
||||||
|
LLVMUserExpression (exe_scope, expr, expr_prefix, language, desired_type, options),
|
||||||
m_type_system_helper(*m_target_wp.lock().get())
|
m_type_system_helper(*m_target_wp.lock().get())
|
||||||
{
|
{
|
||||||
switch (m_language)
|
switch (m_language)
|
||||||
|
|
|
@ -118,7 +118,8 @@ public:
|
||||||
const char *expr,
|
const char *expr,
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
ResultType desired_type);
|
ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options);
|
||||||
|
|
||||||
~ClangUserExpression() override;
|
~ClangUserExpression() override;
|
||||||
|
|
||||||
|
|
|
@ -218,8 +218,9 @@ LookupType(TargetSP target, ConstString name)
|
||||||
return CompilerType();
|
return CompilerType();
|
||||||
}
|
}
|
||||||
GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
||||||
lldb::LanguageType language, ResultType desired_type)
|
lldb::LanguageType language, ResultType desired_type,
|
||||||
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type)
|
const EvaluateExpressionOptions &options)
|
||||||
|
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class GoUserExpression : public UserExpression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
|
||||||
lldb::LanguageType language, ResultType desired_type);
|
lldb::LanguageType language, ResultType desired_type, const EvaluateExpressionOptions &options);
|
||||||
|
|
||||||
virtual bool Parse(Stream &error_stream, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy,
|
virtual bool Parse(Stream &error_stream, ExecutionContext &exe_ctx, lldb_private::ExecutionPolicy execution_policy,
|
||||||
bool keep_result_in_memory, bool generate_debug_info) override;
|
bool keep_result_in_memory, bool generate_debug_info) override;
|
||||||
|
|
|
@ -9227,13 +9227,14 @@ UserExpression *
|
||||||
ClangASTContextForExpressions::GetUserExpression (const char *expr,
|
ClangASTContextForExpressions::GetUserExpression (const char *expr,
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type)
|
Expression::ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options)
|
||||||
{
|
{
|
||||||
TargetSP target_sp = m_target_wp.lock();
|
TargetSP target_sp = m_target_wp.lock();
|
||||||
if (!target_sp)
|
if (!target_sp)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return new ClangUserExpression(*target_sp.get(), expr, expr_prefix, language, desired_type);
|
return new ClangUserExpression(*target_sp.get(), expr, expr_prefix, language, desired_type, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionCaller *
|
FunctionCaller *
|
||||||
|
|
|
@ -1509,10 +1509,10 @@ GoASTContext::GetDWARFParser()
|
||||||
|
|
||||||
UserExpression *
|
UserExpression *
|
||||||
GoASTContextForExpr::GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
|
GoASTContextForExpr::GetUserExpression(const char *expr, const char *expr_prefix, lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type)
|
Expression::ResultType desired_type, const EvaluateExpressionOptions &options)
|
||||||
{
|
{
|
||||||
TargetSP target = m_target_wp.lock();
|
TargetSP target = m_target_wp.lock();
|
||||||
if (target)
|
if (target)
|
||||||
return new GoUserExpression(*target, expr, expr_prefix, language, desired_type);
|
return new GoUserExpression(*target, expr, expr_prefix, language, desired_type, options);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1993,6 +1993,7 @@ Target::GetUserExpressionForLanguage(const char *expr,
|
||||||
const char *expr_prefix,
|
const char *expr_prefix,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
Expression::ResultType desired_type,
|
Expression::ResultType desired_type,
|
||||||
|
const EvaluateExpressionOptions &options,
|
||||||
Error &error)
|
Error &error)
|
||||||
{
|
{
|
||||||
Error type_system_error;
|
Error type_system_error;
|
||||||
|
@ -2006,7 +2007,7 @@ Target::GetUserExpressionForLanguage(const char *expr,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
user_expr = type_system->GetUserExpression(expr, expr_prefix, language, desired_type);
|
user_expr = type_system->GetUserExpression(expr, expr_prefix, language, desired_type, options);
|
||||||
if (!user_expr)
|
if (!user_expr)
|
||||||
error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
|
error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue