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:
Jim Ingham 2015-11-03 02:11:24 +00:00
parent 95c453a221
commit 19a63fc6fa
18 changed files with 72 additions and 30 deletions

View File

@ -109,6 +109,8 @@ public:
virtual bool
NeedsVariableResolution () = 0;
virtual EvaluateExpressionOptions *GetOptions() { return nullptr; };
//------------------------------------------------------------------
/// Return the address of the function's JIT-compiled code, or
/// LLDB_INVALID_ADDRESS if the function is not JIT compiled

View File

@ -35,15 +35,23 @@ namespace lldb_private
class LLVMUserExpression : public UserExpression
{
public:
LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
lldb::LanguageType language, ResultType desired_type);
LLVMUserExpression(ExecutionContextScope &exe_scope,
const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options);
~LLVMUserExpression() override;
lldb::ExpressionResults Execute(Stream &error_stream, ExecutionContext &exe_ctx,
const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me,
lldb::ExpressionResults Execute(Stream &error_stream,
ExecutionContext &exe_ctx,
const EvaluateExpressionOptions &options,
lldb::UserExpressionSP &shared_ptr_to_me,
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_top = LLDB_INVALID_ADDRESS) override;

View File

@ -24,6 +24,7 @@
#include "lldb/Expression/Expression.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
namespace lldb_private
{
@ -67,7 +68,8 @@ public:
const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
ResultType desired_type);
ResultType desired_type,
const EvaluateExpressionOptions &options);
//------------------------------------------------------------------
/// Destructor
@ -236,6 +238,12 @@ public:
return true;
}
EvaluateExpressionOptions *
GetOptions() override
{
return &m_options;
}
virtual lldb::ExpressionVariableSP
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
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.
EvaluateExpressionOptions m_options; ///< Additional options provided by the user.
};
} // namespace lldb_private

View File

@ -1184,7 +1184,8 @@ public:
GetUserExpression (const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
Expression::ResultType desired_type) override;
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options) override;
FunctionCaller *
GetFunctionCaller (const CompilerType &return_type,

View File

@ -398,7 +398,8 @@ class GoASTContextForExpr : public GoASTContext
public:
GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {}
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:
lldb::TargetWP m_target_wp;

View File

@ -496,7 +496,8 @@ public:
GetUserExpression (const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
Expression::ResultType desired_type)
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options)
{
return nullptr;
}

View File

@ -1256,6 +1256,7 @@ public:
const char *expr_prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options,
Error &error);
// Creates a FunctionCaller for the given language, the rest of the parameters have the

View File

@ -293,6 +293,7 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error)
nullptr,
language,
Expression::eResultTypeAny,
EvaluateExpressionOptions(),
error));
if (error.Fail())
{

View File

@ -387,6 +387,7 @@ Watchpoint::SetCondition (const char *condition)
nullptr,
lldb::eLanguageTypeUnknown,
UserExpression::eResultTypeAny,
EvaluateExpressionOptions(),
error));
if (error.Fail())
{

View File

@ -40,9 +40,13 @@
using namespace lldb_private;
LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
lldb::LanguageType language, ResultType desired_type)
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type),
LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
const char *expr,
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_top(LLDB_INVALID_ADDRESS),
m_transformed_text(),

View File

@ -45,13 +45,18 @@
using namespace lldb_private;
UserExpression::UserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
lldb::LanguageType language, ResultType desired_type)
: Expression(exe_scope),
UserExpression::UserExpression (ExecutionContextScope &exe_scope,
const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options) :
Expression(exe_scope),
m_expr_text(expr),
m_expr_prefix(expr_prefix ? expr_prefix : ""),
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,
language,
desired_type,
options,
error));
if (error.Fail())
{

View File

@ -55,10 +55,14 @@
using namespace lldb_private;
ClangUserExpression::ClangUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
lldb::LanguageType language, ResultType desired_type)
: LLVMUserExpression(exe_scope, expr, expr_prefix, language, desired_type),
m_type_system_helper(*m_target_wp.lock().get())
ClangUserExpression::ClangUserExpression (ExecutionContextScope &exe_scope,
const char *expr,
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())
{
switch (m_language)
{

View File

@ -118,7 +118,8 @@ public:
const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
ResultType desired_type);
ResultType desired_type,
const EvaluateExpressionOptions &options);
~ClangUserExpression() override;

View File

@ -218,8 +218,9 @@ LookupType(TargetSP target, ConstString name)
return CompilerType();
}
GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope, const char *expr, const char *expr_prefix,
lldb::LanguageType language, ResultType desired_type)
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type)
lldb::LanguageType language, ResultType desired_type,
const EvaluateExpressionOptions &options)
: UserExpression(exe_scope, expr, expr_prefix, language, desired_type, options)
{
}

View File

@ -66,7 +66,7 @@ class GoUserExpression : public UserExpression
{
public:
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,
bool keep_result_in_memory, bool generate_debug_info) override;

View File

@ -9227,13 +9227,14 @@ UserExpression *
ClangASTContextForExpressions::GetUserExpression (const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
Expression::ResultType desired_type)
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options)
{
TargetSP target_sp = m_target_wp.lock();
if (!target_sp)
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 *

View File

@ -1509,10 +1509,10 @@ GoASTContext::GetDWARFParser()
UserExpression *
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();
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;
}

View File

@ -1993,6 +1993,7 @@ Target::GetUserExpressionForLanguage(const char *expr,
const char *expr_prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options,
Error &error)
{
Error type_system_error;
@ -2006,7 +2007,7 @@ Target::GetUserExpressionForLanguage(const char *expr,
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)
error.SetErrorStringWithFormat("Could not create an expression for language %s", Language::GetNameForLanguageType(language));