diff options
author | dim <dim@FreeBSD.org> | 2017-04-02 17:24:58 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2017-04-02 17:24:58 +0000 |
commit | 60b571e49a90d38697b3aca23020d9da42fc7d7f (patch) | |
tree | 99351324c24d6cb146b6285b6caffa4d26fce188 /contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp | |
parent | bea1b22c7a9bce1dfdd73e6e5b65bc4752215180 (diff) | |
download | FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.zip FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.tar.gz |
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release:
MFC r309142 (by emaste):
Add WITH_LLD_AS_LD build knob
If set it installs LLD as /usr/bin/ld. LLD (as of version 3.9) is not
capable of linking the world and kernel, but can self-host and link many
substantial applications. GNU ld continues to be used for the world and
kernel build, regardless of how this knob is set.
It is on by default for arm64, and off for all other CPU architectures.
Sponsored by: The FreeBSD Foundation
MFC r310840:
Reapply 310775, now it also builds correctly if lldb is disabled:
Move llvm-objdump from CLANG_EXTRAS to installed by default
We currently install three tools from binutils 2.17.50: as, ld, and
objdump. Work is underway to migrate to a permissively-licensed
tool-chain, with one goal being the retirement of binutils 2.17.50.
LLVM's llvm-objdump is intended to be compatible with GNU objdump
although it is currently missing some options and may have formatting
differences. Enable it by default for testing and further investigation.
It may later be changed to install as /usr/bin/objdump, it becomes a
fully viable replacement.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D8879
MFC r312855 (by emaste):
Rename LLD_AS_LD to LLD_IS_LD, for consistency with CLANG_IS_CC
Reported by: Dan McGregor <dan.mcgregor usask.ca>
MFC r313559 | glebius | 2017-02-10 18:34:48 +0100 (Fri, 10 Feb 2017) | 5 lines
Don't check struct rtentry on FreeBSD, it is an internal kernel structure.
On other systems it may be API structure for SIOCADDRT/SIOCDELRT.
Reviewed by: emaste, dim
MFC r314152 (by jkim):
Remove an assembler flag, which is redundant since r309124. The upstream
took care of it by introducing a macro NO_EXEC_STACK_DIRECTIVE.
http://llvm.org/viewvc/llvm-project?rev=273500&view=rev
Reviewed by: dim
MFC r314564:
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
4.0.0 (branches/release_40 296509). The release will follow soon.
Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11
support to build; see UPDATING for more information.
Also note that as of 4.0.0, lld should be able to link the base system
on amd64 and aarch64. See the WITH_LLD_IS_LLD setting in src.conf(5).
Though please be aware that this is work in progress.
Release notes for llvm, clang and lld will be available here:
<http://releases.llvm.org/4.0.0/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/clang/docs/ReleaseNotes.html>
<http://releases.llvm.org/4.0.0/tools/lld/docs/ReleaseNotes.html>
Thanks to Ed Maste, Jan Beich, Antoine Brodin and Eric Fiselier for
their help.
Relnotes: yes
Exp-run: antoine
PR: 215969, 216008
MFC r314708:
For now, revert r287232 from upstream llvm trunk (by Daniil Fukalov):
[SCEV] limit recursion depth of CompareSCEVComplexity
Summary:
CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
loop) and runs almost infinite time.
Added cache of "equal" SCEV pairs to earlier cutoff of further
estimation. Recursion depth limit was also introduced as a parameter.
Reviewers: sanjoy
Subscribers: mzolotukhin, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D26389
This commit is the cause of excessive compile times on skein_block.c
(and possibly other files) during kernel builds on amd64.
We never saw the problematic behavior described in this upstream commit,
so for now it is better to revert it. An upstream bug has been filed
here: https://bugs.llvm.org/show_bug.cgi?id=32142
Reported by: mjg
MFC r314795:
Reapply r287232 from upstream llvm trunk (by Daniil Fukalov):
[SCEV] limit recursion depth of CompareSCEVComplexity
Summary:
CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled
loop) and runs almost infinite time.
Added cache of "equal" SCEV pairs to earlier cutoff of further
estimation. Recursion depth limit was also introduced as a parameter.
Reviewers: sanjoy
Subscribers: mzolotukhin, tstellarAMD, llvm-commits
Differential Revision: https://reviews.llvm.org/D26389
Pull in r296992 from upstream llvm trunk (by Sanjoy Das):
[SCEV] Decrease the recursion threshold for CompareValueComplexity
Fixes PR32142.
r287232 accidentally increased the recursion threshold for
CompareValueComplexity from 2 to 32. This change reverses that
change by introducing a separate flag for CompareValueComplexity's
threshold.
The latter revision fixes the excessive compile times for skein_block.c.
MFC r314907 | mmel | 2017-03-08 12:40:27 +0100 (Wed, 08 Mar 2017) | 7 lines
Unbreak ARMv6 world.
The new compiler_rt library imported with clang 4.0.0 have several fatal
issues (non-functional __udivsi3 for example) with ARM specific instrict
functions. As temporary workaround, until upstream solve these problems,
disable all thumb[1][2] related feature.
MFC r315016:
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release.
We were already very close to the last release candidate, so this is a
pretty minor update.
Relnotes: yes
MFC r316005:
Revert r314907, and pull in r298713 from upstream compiler-rt trunk (by
Weiming Zhao):
builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA.
Summary:
Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation
mode (-mthumb, -marm), it reflect's capability of given CPU.
Due to this:
- use __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB
- use '.thumb' directive consistently in all affected files
- decorate all thumb functions using
DEFINE_COMPILERRT_THUMB_FUNCTION()
---------
Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 !
Reviewers: weimingz, rengolin, compnerd
Subscribers: aemerson, dim
Differential Revision: https://reviews.llvm.org/D30938
Discussed with: mmel
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp | 632 |
1 files changed, 300 insertions, 332 deletions
diff --git a/contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp b/contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp index 3e2e07e..041caf5 100644 --- a/contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp +++ b/contrib/llvm/tools/lldb/source/Expression/UserExpression.cpp @@ -9,12 +9,12 @@ #include <stdio.h> #if HAVE_SYS_TYPES_H -# include <sys/types.h> +#include <sys/types.h> #endif #include <cstdlib> -#include <string> #include <map> +#include <string> #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/ConstString.h" @@ -46,359 +46,329 @@ using namespace lldb_private; -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_options (options) -{ -} - -UserExpression::~UserExpression () -{ -} - -void -UserExpression::InstallContext (ExecutionContext &exe_ctx) -{ - m_jit_process_wp = exe_ctx.GetProcessSP(); +UserExpression::UserExpression(ExecutionContextScope &exe_scope, + llvm::StringRef expr, llvm::StringRef prefix, + lldb::LanguageType language, + ResultType desired_type, + const EvaluateExpressionOptions &options) + : Expression(exe_scope), m_expr_text(expr), m_expr_prefix(prefix), + m_language(language), m_desired_type(desired_type), m_options(options) {} - lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP(); +UserExpression::~UserExpression() {} - if (frame_sp) - m_address = frame_sp->GetFrameCodeAddress(); -} +void UserExpression::InstallContext(ExecutionContext &exe_ctx) { + m_jit_process_wp = exe_ctx.GetProcessSP(); -bool -UserExpression::LockAndCheckContext (ExecutionContext &exe_ctx, - lldb::TargetSP &target_sp, - lldb::ProcessSP &process_sp, - lldb::StackFrameSP &frame_sp) -{ - lldb::ProcessSP expected_process_sp = m_jit_process_wp.lock(); - process_sp = exe_ctx.GetProcessSP(); - - if (process_sp != expected_process_sp) - return false; - - process_sp = exe_ctx.GetProcessSP(); - target_sp = exe_ctx.GetTargetSP(); - frame_sp = exe_ctx.GetFrameSP(); - - if (m_address.IsValid()) - { - if (!frame_sp) - return false; - else - return (0 == Address::CompareLoadAddress(m_address, frame_sp->GetFrameCodeAddress(), target_sp.get())); - } + lldb::StackFrameSP frame_sp = exe_ctx.GetFrameSP(); - return true; + if (frame_sp) + m_address = frame_sp->GetFrameCodeAddress(); } -bool -UserExpression::MatchesContext (ExecutionContext &exe_ctx) -{ - lldb::TargetSP target_sp; - lldb::ProcessSP process_sp; - lldb::StackFrameSP frame_sp; +bool UserExpression::LockAndCheckContext(ExecutionContext &exe_ctx, + lldb::TargetSP &target_sp, + lldb::ProcessSP &process_sp, + lldb::StackFrameSP &frame_sp) { + lldb::ProcessSP expected_process_sp = m_jit_process_wp.lock(); + process_sp = exe_ctx.GetProcessSP(); - return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp); -} + if (process_sp != expected_process_sp) + return false; -lldb::addr_t -UserExpression::GetObjectPointer (lldb::StackFrameSP frame_sp, - ConstString &object_name, - Error &err) -{ - err.Clear(); + process_sp = exe_ctx.GetProcessSP(); + target_sp = exe_ctx.GetTargetSP(); + frame_sp = exe_ctx.GetFrameSP(); + if (m_address.IsValid()) { if (!frame_sp) - { - err.SetErrorStringWithFormat("Couldn't load '%s' because the context is incomplete", object_name.AsCString()); - return LLDB_INVALID_ADDRESS; - } - - lldb::VariableSP var_sp; - lldb::ValueObjectSP valobj_sp; - - valobj_sp = frame_sp->GetValueForVariableExpressionPath(object_name.AsCString(), - lldb::eNoDynamicValues, - StackFrame::eExpressionPathOptionCheckPtrVsMember | - StackFrame::eExpressionPathOptionsNoFragileObjcIvar | - StackFrame::eExpressionPathOptionsNoSyntheticChildren | - StackFrame::eExpressionPathOptionsNoSyntheticArrayRange, - var_sp, - err); + return false; + else + return (0 == Address::CompareLoadAddress(m_address, + frame_sp->GetFrameCodeAddress(), + target_sp.get())); + } - if (!err.Success() || !valobj_sp.get()) - return LLDB_INVALID_ADDRESS; + return true; +} - lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); +bool UserExpression::MatchesContext(ExecutionContext &exe_ctx) { + lldb::TargetSP target_sp; + lldb::ProcessSP process_sp; + lldb::StackFrameSP frame_sp; - if (ret == LLDB_INVALID_ADDRESS) - { - err.SetErrorStringWithFormat("Couldn't load '%s' because its value couldn't be evaluated", object_name.AsCString()); - return LLDB_INVALID_ADDRESS; - } + return LockAndCheckContext(exe_ctx, target_sp, process_sp, frame_sp); +} - return ret; +lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp, + ConstString &object_name, + Error &err) { + err.Clear(); + + if (!frame_sp) { + err.SetErrorStringWithFormat( + "Couldn't load '%s' because the context is incomplete", + object_name.AsCString()); + return LLDB_INVALID_ADDRESS; + } + + lldb::VariableSP var_sp; + lldb::ValueObjectSP valobj_sp; + + valobj_sp = frame_sp->GetValueForVariableExpressionPath( + object_name.AsCString(), lldb::eNoDynamicValues, + StackFrame::eExpressionPathOptionCheckPtrVsMember | + StackFrame::eExpressionPathOptionsNoFragileObjcIvar | + StackFrame::eExpressionPathOptionsNoSyntheticChildren | + StackFrame::eExpressionPathOptionsNoSyntheticArrayRange, + var_sp, err); + + if (!err.Success() || !valobj_sp.get()) + return LLDB_INVALID_ADDRESS; + + lldb::addr_t ret = valobj_sp->GetValueAsUnsigned(LLDB_INVALID_ADDRESS); + + if (ret == LLDB_INVALID_ADDRESS) { + err.SetErrorStringWithFormat( + "Couldn't load '%s' because its value couldn't be evaluated", + object_name.AsCString()); + return LLDB_INVALID_ADDRESS; + } + + return ret; } -lldb::ExpressionResults -UserExpression::Evaluate (ExecutionContext &exe_ctx, - const EvaluateExpressionOptions& options, - const char *expr_cstr, - const char *expr_prefix, - lldb::ValueObjectSP &result_valobj_sp, - Error &error, - uint32_t line_offset, - std::string *fixed_expression, - lldb::ModuleSP *jit_module_sp_ptr) -{ - Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP)); - - lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy(); - lldb::LanguageType language = options.GetLanguage(); - const ResultType desired_type = options.DoesCoerceToId() ? UserExpression::eResultTypeId : UserExpression::eResultTypeAny; - lldb::ExpressionResults execution_results = lldb::eExpressionSetupError; - - Target *target = exe_ctx.GetTargetPtr(); - if (!target) - { - if (log) - log->Printf("== [UserExpression::Evaluate] Passed a NULL target, can't run expressions."); - return lldb::eExpressionSetupError; - } +lldb::ExpressionResults UserExpression::Evaluate( + ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, + llvm::StringRef expr, llvm::StringRef prefix, + lldb::ValueObjectSP &result_valobj_sp, Error &error, uint32_t line_offset, + std::string *fixed_expression, lldb::ModuleSP *jit_module_sp_ptr) { + Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS | + LIBLLDB_LOG_STEP)); + + lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy(); + lldb::LanguageType language = options.GetLanguage(); + const ResultType desired_type = options.DoesCoerceToId() + ? UserExpression::eResultTypeId + : UserExpression::eResultTypeAny; + lldb::ExpressionResults execution_results = lldb::eExpressionSetupError; + + Target *target = exe_ctx.GetTargetPtr(); + if (!target) { + if (log) + log->Printf("== [UserExpression::Evaluate] Passed a NULL target, can't " + "run expressions."); + error.SetErrorString("expression passed a null target"); + return lldb::eExpressionSetupError; + } - Process *process = exe_ctx.GetProcessPtr(); + Process *process = exe_ctx.GetProcessPtr(); - if (process == NULL || process->GetState() != lldb::eStateStopped) - { - if (execution_policy == eExecutionPolicyAlways) - { - if (log) - log->Printf("== [UserExpression::Evaluate] Expression may not run, but is not constant =="); + if (process == NULL || process->GetState() != lldb::eStateStopped) { + if (execution_policy == eExecutionPolicyAlways) { + if (log) + log->Printf("== [UserExpression::Evaluate] Expression may not run, but " + "is not constant =="); - error.SetErrorString ("expression needed to run but couldn't"); + error.SetErrorString("expression needed to run but couldn't"); - return execution_results; - } + return execution_results; } - - if (process == NULL || !process->CanJIT()) - execution_policy = eExecutionPolicyNever; - - // We need to set the expression execution thread here, turns out parse can call functions in the process of - // looking up symbols, which will escape the context set by exe_ctx passed to Execute. - lldb::ThreadSP thread_sp = exe_ctx.GetThreadSP(); - ThreadList::ExpressionExecutionThreadPusher execution_thread_pusher(thread_sp); - - const char *full_prefix = NULL; - const char *option_prefix = options.GetPrefix(); - std::string full_prefix_storage; - if (expr_prefix && option_prefix) - { - full_prefix_storage.assign(expr_prefix); - full_prefix_storage.append(option_prefix); - if (!full_prefix_storage.empty()) - full_prefix = full_prefix_storage.c_str(); - } - else if (expr_prefix) - full_prefix = expr_prefix; - else - full_prefix = option_prefix; - - // If the language was not specified in the expression command, - // set it to the language in the target's properties if - // specified, else default to the langage for the frame. - if (language == lldb::eLanguageTypeUnknown) - { - if (target->GetLanguage() != lldb::eLanguageTypeUnknown) - language = target->GetLanguage(); - else if (StackFrame *frame = exe_ctx.GetFramePtr()) - language = frame->GetLanguage(); + } + + if (process == NULL || !process->CanJIT()) + execution_policy = eExecutionPolicyNever; + + // We need to set the expression execution thread here, turns out parse can + // call functions in the process of + // looking up symbols, which will escape the context set by exe_ctx passed to + // Execute. + lldb::ThreadSP thread_sp = exe_ctx.GetThreadSP(); + ThreadList::ExpressionExecutionThreadPusher execution_thread_pusher( + thread_sp); + + llvm::StringRef full_prefix; + llvm::StringRef option_prefix(options.GetPrefix()); + std::string full_prefix_storage; + if (!prefix.empty() && !option_prefix.empty()) { + full_prefix_storage = prefix; + full_prefix_storage.append(option_prefix); + full_prefix = full_prefix_storage; + } else if (!prefix.empty()) + full_prefix = prefix; + else + full_prefix = option_prefix; + + // If the language was not specified in the expression command, + // set it to the language in the target's properties if + // specified, else default to the langage for the frame. + if (language == lldb::eLanguageTypeUnknown) { + if (target->GetLanguage() != lldb::eLanguageTypeUnknown) + language = target->GetLanguage(); + else if (StackFrame *frame = exe_ctx.GetFramePtr()) + language = frame->GetLanguage(); + } + + lldb::UserExpressionSP user_expression_sp( + target->GetUserExpressionForLanguage(expr, full_prefix, language, + desired_type, options, error)); + if (error.Fail()) { + if (log) + log->Printf("== [UserExpression::Evaluate] Getting expression: %s ==", + error.AsCString()); + return lldb::eExpressionSetupError; + } + + if (log) + log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==", + expr.str().c_str()); + + const bool keep_expression_in_memory = true; + const bool generate_debug_info = options.GetGenerateDebugInfo(); + + if (options.InvokeCancelCallback(lldb::eExpressionEvaluationParse)) { + error.SetErrorString("expression interrupted by callback before parse"); + result_valobj_sp = ValueObjectConstResult::Create( + exe_ctx.GetBestExecutionContextScope(), error); + return lldb::eExpressionInterrupted; + } + + DiagnosticManager diagnostic_manager; + + bool parse_success = + user_expression_sp->Parse(diagnostic_manager, exe_ctx, execution_policy, + keep_expression_in_memory, generate_debug_info); + + // Calculate the fixed expression always, since we need it for errors. + std::string tmp_fixed_expression; + if (fixed_expression == nullptr) + fixed_expression = &tmp_fixed_expression; + + const char *fixed_text = user_expression_sp->GetFixedText(); + if (fixed_text != nullptr) + fixed_expression->append(fixed_text); + + // If there is a fixed expression, try to parse it: + if (!parse_success) { + execution_results = lldb::eExpressionParseError; + if (fixed_expression && !fixed_expression->empty() && + options.GetAutoApplyFixIts()) { + lldb::UserExpressionSP fixed_expression_sp( + target->GetUserExpressionForLanguage(fixed_expression->c_str(), + full_prefix, language, + desired_type, options, error)); + DiagnosticManager fixed_diagnostic_manager; + parse_success = fixed_expression_sp->Parse( + fixed_diagnostic_manager, exe_ctx, execution_policy, + keep_expression_in_memory, generate_debug_info); + if (parse_success) { + diagnostic_manager.Clear(); + user_expression_sp = fixed_expression_sp; + } else { + // If the fixed expression failed to parse, don't tell the user about, + // that won't help. + fixed_expression->clear(); + } } - lldb::UserExpressionSP user_expression_sp(target->GetUserExpressionForLanguage (expr_cstr, - full_prefix, - language, - desired_type, - options, - error)); - if (error.Fail()) - { - if (log) - log->Printf ("== [UserExpression::Evaluate] Getting expression: %s ==", error.AsCString()); - return lldb::eExpressionSetupError; + if (!parse_success) { + if (!fixed_expression->empty() && target->GetEnableNotifyAboutFixIts()) { + error.SetExpressionErrorWithFormat( + execution_results, + "expression failed to parse, fixed expression suggested:\n %s", + fixed_expression->c_str()); + } else { + if (!diagnostic_manager.Diagnostics().size()) + error.SetExpressionError(execution_results, + "expression failed to parse, unknown error"); + else + error.SetExpressionError(execution_results, + diagnostic_manager.GetString().c_str()); + } } + } + + if (parse_success) { + // If a pointer to a lldb::ModuleSP was passed in, return the JIT'ed module + // if one was created + if (jit_module_sp_ptr) + *jit_module_sp_ptr = user_expression_sp->GetJITModule(); + + lldb::ExpressionVariableSP expr_result; + + if (execution_policy == eExecutionPolicyNever && + !user_expression_sp->CanInterpret()) { + if (log) + log->Printf("== [UserExpression::Evaluate] Expression may not run, but " + "is not constant =="); + + if (!diagnostic_manager.Diagnostics().size()) + error.SetExpressionError(lldb::eExpressionSetupError, + "expression needed to run but couldn't"); + } else if (execution_policy == eExecutionPolicyTopLevel) { + error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric); + return lldb::eExpressionCompleted; + } else { + if (options.InvokeCancelCallback(lldb::eExpressionEvaluationExecution)) { + error.SetExpressionError( + lldb::eExpressionInterrupted, + "expression interrupted by callback before execution"); + result_valobj_sp = ValueObjectConstResult::Create( + exe_ctx.GetBestExecutionContextScope(), error); + return lldb::eExpressionInterrupted; + } - if (log) - log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==", expr_cstr); + diagnostic_manager.Clear(); - const bool keep_expression_in_memory = true; - const bool generate_debug_info = options.GetGenerateDebugInfo(); + if (log) + log->Printf("== [UserExpression::Evaluate] Executing expression =="); - if (options.InvokeCancelCallback (lldb::eExpressionEvaluationParse)) - { - error.SetErrorString ("expression interrupted by callback before parse"); - result_valobj_sp = ValueObjectConstResult::Create(exe_ctx.GetBestExecutionContextScope(), error); - return lldb::eExpressionInterrupted; - } + execution_results = + user_expression_sp->Execute(diagnostic_manager, exe_ctx, options, + user_expression_sp, expr_result); - DiagnosticManager diagnostic_manager; - - bool parse_success = user_expression_sp->Parse(diagnostic_manager, - exe_ctx, - execution_policy, - keep_expression_in_memory, - generate_debug_info); - - // Calculate the fixed expression always, since we need it for errors. - std::string tmp_fixed_expression; - if (fixed_expression == nullptr) - fixed_expression = &tmp_fixed_expression; - - const char *fixed_text = user_expression_sp->GetFixedText(); - if (fixed_text != nullptr) - fixed_expression->append(fixed_text); - - // If there is a fixed expression, try to parse it: - if (!parse_success) - { - execution_results = lldb::eExpressionParseError; - if (fixed_expression && !fixed_expression->empty() && options.GetAutoApplyFixIts()) - { - lldb::UserExpressionSP fixed_expression_sp(target->GetUserExpressionForLanguage (fixed_expression->c_str(), - full_prefix, - language, - desired_type, - options, - error)); - DiagnosticManager fixed_diagnostic_manager; - parse_success = fixed_expression_sp->Parse(fixed_diagnostic_manager, - exe_ctx, - execution_policy, - keep_expression_in_memory, - generate_debug_info); - if (parse_success) - { - diagnostic_manager.Clear(); - user_expression_sp = fixed_expression_sp; - } - else - { - // If the fixed expression failed to parse, don't tell the user about, that won't help. - fixed_expression->clear(); - } - } - - if (!parse_success) - { - if (!fixed_expression->empty() && target->GetEnableNotifyAboutFixIts()) - { - error.SetExpressionErrorWithFormat(execution_results, "expression failed to parse, fixed expression suggested:\n %s", - fixed_expression->c_str()); - } - else - { - if (!diagnostic_manager.Diagnostics().size()) - error.SetExpressionError(execution_results, "expression failed to parse, unknown error"); - else - error.SetExpressionError(execution_results, diagnostic_manager.GetString().c_str()); - } - } - } - - if (parse_success) - { - // If a pointer to a lldb::ModuleSP was passed in, return the JIT'ed module if one was created - if (jit_module_sp_ptr) - *jit_module_sp_ptr = user_expression_sp->GetJITModule(); - - lldb::ExpressionVariableSP expr_result; - - if (execution_policy == eExecutionPolicyNever && - !user_expression_sp->CanInterpret()) - { - if (log) - log->Printf("== [UserExpression::Evaluate] Expression may not run, but is not constant =="); - - if (!diagnostic_manager.Diagnostics().size()) - error.SetExpressionError(lldb::eExpressionSetupError, "expression needed to run but couldn't"); - } - else if (execution_policy == eExecutionPolicyTopLevel) - { - error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric); - return lldb::eExpressionCompleted; - } + if (execution_results != lldb::eExpressionCompleted) { + if (log) + log->Printf("== [UserExpression::Evaluate] Execution completed " + "abnormally =="); + + if (!diagnostic_manager.Diagnostics().size()) + error.SetExpressionError( + execution_results, "expression failed to execute, unknown error"); else - { - if (options.InvokeCancelCallback (lldb::eExpressionEvaluationExecution)) - { - error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback before execution"); - result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error); - return lldb::eExpressionInterrupted; - } - - diagnostic_manager.Clear(); - - if (log) - log->Printf("== [UserExpression::Evaluate] Executing expression =="); - - execution_results = - user_expression_sp->Execute(diagnostic_manager, exe_ctx, options, user_expression_sp, expr_result); - - if (execution_results != lldb::eExpressionCompleted) - { - if (log) - log->Printf("== [UserExpression::Evaluate] Execution completed abnormally =="); - - if (!diagnostic_manager.Diagnostics().size()) - error.SetExpressionError(execution_results, "expression failed to execute, unknown error"); - else - error.SetExpressionError(execution_results, diagnostic_manager.GetString().c_str()); - } - else - { - if (expr_result) - { - result_valobj_sp = expr_result->GetValueObject(); - - if (log) - log->Printf("== [UserExpression::Evaluate] Execution completed normally with result %s ==", - result_valobj_sp->GetValueAsCString()); - } - else - { - if (log) - log->Printf("== [UserExpression::Evaluate] Execution completed normally with no result =="); - - error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric); - } - } + error.SetExpressionError(execution_results, + diagnostic_manager.GetString().c_str()); + } else { + if (expr_result) { + result_valobj_sp = expr_result->GetValueObject(); + + if (log) + log->Printf("== [UserExpression::Evaluate] Execution completed " + "normally with result %s ==", + result_valobj_sp->GetValueAsCString()); + } else { + if (log) + log->Printf("== [UserExpression::Evaluate] Execution completed " + "normally with no result =="); + + error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric); } + } } + } - if (options.InvokeCancelCallback(lldb::eExpressionEvaluationComplete)) - { - error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback after complete"); - return lldb::eExpressionInterrupted; - } + if (options.InvokeCancelCallback(lldb::eExpressionEvaluationComplete)) { + error.SetExpressionError( + lldb::eExpressionInterrupted, + "expression interrupted by callback after complete"); + return lldb::eExpressionInterrupted; + } - if (result_valobj_sp.get() == NULL) - { - result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error); - } + if (result_valobj_sp.get() == NULL) { + result_valobj_sp = ValueObjectConstResult::Create( + exe_ctx.GetBestExecutionContextScope(), error); + } - return execution_results; + return execution_results; } lldb::ExpressionResults @@ -406,15 +376,13 @@ UserExpression::Execute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options, lldb::UserExpressionSP &shared_ptr_to_me, - lldb::ExpressionVariableSP &result_var) -{ - lldb::ExpressionResults expr_result = DoExecute(diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var); - Target *target = exe_ctx.GetTargetPtr(); - if (options.GetResultIsInternal() && result_var && target) - { - target->GetPersistentExpressionStateForLanguage(m_language)->RemovePersistentVariable (result_var); - } - return expr_result; + lldb::ExpressionVariableSP &result_var) { + lldb::ExpressionResults expr_result = DoExecute( + diagnostic_manager, exe_ctx, options, shared_ptr_to_me, result_var); + Target *target = exe_ctx.GetTargetPtr(); + if (options.GetResultIsInternal() && result_var && target) { + target->GetPersistentExpressionStateForLanguage(m_language) + ->RemovePersistentVariable(result_var); + } + return expr_result; } - - |