2015-11-03 03:30:40 +08:00
|
|
|
//===-- LLVMUserExpression.cpp ----------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-11-03 03:30:40 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
#include "lldb/Expression/LLVMUserExpression.h"
|
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Core/StreamFile.h"
|
|
|
|
#include "lldb/Core/ValueObjectConstResult.h"
|
2016-03-19 08:03:59 +08:00
|
|
|
#include "lldb/Expression/DiagnosticManager.h"
|
2015-11-03 03:30:40 +08:00
|
|
|
#include "lldb/Expression/IRExecutionUnit.h"
|
|
|
|
#include "lldb/Expression/IRInterpreter.h"
|
|
|
|
#include "lldb/Expression/Materializer.h"
|
|
|
|
#include "lldb/Host/HostInfo.h"
|
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
#include "lldb/Symbol/ClangASTContext.h"
|
2016-03-19 08:03:59 +08:00
|
|
|
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
|
2015-11-03 03:30:40 +08:00
|
|
|
#include "lldb/Symbol/Function.h"
|
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/SymbolVendor.h"
|
|
|
|
#include "lldb/Symbol/Type.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/StackFrame.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
#include "lldb/Target/ThreadPlanCallUserExpression.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/ConstString.h"
|
2017-03-04 04:56:28 +08:00
|
|
|
#include "lldb/Utility/Log.h"
|
2017-02-03 05:39:50 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
2015-11-03 03:30:40 +08:00
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
|
2016-11-08 12:52:16 +08:00
|
|
|
llvm::StringRef expr,
|
|
|
|
llvm::StringRef prefix,
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::LanguageType language,
|
|
|
|
ResultType desired_type,
|
2019-03-14 03:46:30 +08:00
|
|
|
const EvaluateExpressionOptions &options,
|
|
|
|
ExpressionKind kind)
|
|
|
|
: UserExpression(exe_scope, expr, prefix, language, desired_type, options,
|
|
|
|
kind),
|
2015-11-03 03:30:40 +08:00
|
|
|
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
|
2019-02-13 14:25:41 +08:00
|
|
|
m_stack_frame_top(LLDB_INVALID_ADDRESS), m_allow_cxx(false),
|
|
|
|
m_allow_objc(false), m_transformed_text(), m_execution_unit_sp(),
|
|
|
|
m_materializer_up(), m_jit_module_wp(), m_enforce_valid_object(true),
|
|
|
|
m_in_cplusplus_method(false), m_in_objectivec_method(false),
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
m_in_static_method(false), m_needs_object_ptr(false), m_target(nullptr),
|
2019-02-13 14:25:41 +08:00
|
|
|
m_can_interpret(false), m_materialized_address(LLDB_INVALID_ADDRESS) {}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
LLVMUserExpression::~LLVMUserExpression() {
|
|
|
|
if (m_target) {
|
|
|
|
lldb::ModuleSP jit_module_sp(m_jit_module_wp.lock());
|
|
|
|
if (jit_module_sp)
|
|
|
|
m_target->GetImages().Remove(jit_module_sp);
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::ExpressionResults
|
|
|
|
LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
|
|
|
|
ExecutionContext &exe_ctx,
|
|
|
|
const EvaluateExpressionOptions &options,
|
|
|
|
lldb::UserExpressionSP &shared_ptr_to_me,
|
|
|
|
lldb::ExpressionVariableSP &result) {
|
|
|
|
// The expression log is quite verbose, and if you're just tracking the
|
2018-05-01 00:49:04 +08:00
|
|
|
// execution of the expression, it's quite convenient to have these logs come
|
|
|
|
// out with the STEP log as well.
|
2016-09-07 04:57:50 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
|
|
|
|
LIBLLDB_LOG_STEP));
|
|
|
|
|
|
|
|
if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret) {
|
|
|
|
lldb::addr_t struct_address = LLDB_INVALID_ADDRESS;
|
|
|
|
|
|
|
|
if (!PrepareToExecuteJITExpression(diagnostic_manager, exe_ctx,
|
|
|
|
struct_address)) {
|
|
|
|
diagnostic_manager.Printf(
|
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"errored out in %s, couldn't PrepareToExecuteJITExpression",
|
|
|
|
__FUNCTION__);
|
|
|
|
return lldb::eExpressionSetupError;
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS;
|
|
|
|
lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (m_can_interpret) {
|
|
|
|
llvm::Module *module = m_execution_unit_sp->GetModule();
|
|
|
|
llvm::Function *function = m_execution_unit_sp->GetFunction();
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!module || !function) {
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(
|
2016-09-07 04:57:50 +08:00
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"supposed to interpret, but nothing is there");
|
|
|
|
return lldb::eExpressionSetupError;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status interpreter_error;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
std::vector<lldb::addr_t> args;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!AddArguments(exe_ctx, args, struct_address, diagnostic_manager)) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"errored out in %s, couldn't AddArguments",
|
|
|
|
__FUNCTION__);
|
|
|
|
return lldb::eExpressionSetupError;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
function_stack_bottom = m_stack_frame_bottom;
|
|
|
|
function_stack_top = m_stack_frame_top;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2019-02-12 11:47:39 +08:00
|
|
|
IRInterpreter::Interpret(*module, *function, args, *m_execution_unit_sp,
|
|
|
|
interpreter_error, function_stack_bottom,
|
|
|
|
function_stack_top, exe_ctx);
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!interpreter_error.Success()) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"supposed to interpret, but failed: %s",
|
|
|
|
interpreter_error.AsCString());
|
|
|
|
return lldb::eExpressionDiscarded;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!exe_ctx.HasThreadScope()) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"%s called with no thread selected",
|
|
|
|
__FUNCTION__);
|
|
|
|
return lldb::eExpressionSetupError;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
Address wrapper_address(m_jit_start_addr);
|
|
|
|
|
|
|
|
std::vector<lldb::addr_t> args;
|
|
|
|
|
|
|
|
if (!AddArguments(exe_ctx, args, struct_address, diagnostic_manager)) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"errored out in %s, couldn't AddArguments",
|
|
|
|
__FUNCTION__);
|
|
|
|
return lldb::eExpressionSetupError;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression(
|
|
|
|
exe_ctx.GetThreadRef(), wrapper_address, args, options,
|
|
|
|
shared_ptr_to_me));
|
|
|
|
|
|
|
|
StreamString ss;
|
|
|
|
if (!call_plan_sp || !call_plan_sp->ValidatePlan(&ss)) {
|
2016-11-17 05:15:24 +08:00
|
|
|
diagnostic_manager.PutString(eDiagnosticSeverityError, ss.GetString());
|
2016-09-07 04:57:50 +08:00
|
|
|
return lldb::eExpressionSetupError;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadPlanCallUserExpression *user_expression_plan =
|
|
|
|
static_cast<ThreadPlanCallUserExpression *>(call_plan_sp.get());
|
|
|
|
|
|
|
|
lldb::addr_t function_stack_pointer =
|
|
|
|
user_expression_plan->GetFunctionStackPointer();
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
|
|
|
|
function_stack_top = function_stack_pointer;
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf(
|
|
|
|
"-- [UserExpression::Execute] Execution of expression begins --");
|
|
|
|
|
|
|
|
if (exe_ctx.GetProcessPtr())
|
|
|
|
exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
|
|
|
|
|
|
|
|
lldb::ExpressionResults execution_result =
|
|
|
|
exe_ctx.GetProcessRef().RunThreadPlan(exe_ctx, call_plan_sp, options,
|
|
|
|
diagnostic_manager);
|
|
|
|
|
|
|
|
if (exe_ctx.GetProcessPtr())
|
|
|
|
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
log->Printf("-- [UserExpression::Execute] Execution of expression "
|
|
|
|
"completed --");
|
|
|
|
|
|
|
|
if (execution_result == lldb::eExpressionInterrupted ||
|
|
|
|
execution_result == lldb::eExpressionHitBreakpoint) {
|
[lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]
This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.
This is the command I ran and I to fix and format the code base:
```
run-clang-tidy.py \
-header-filter='.*' \
-checks='-*,modernize-use-nullptr' \
-fix ~/dev/llvm-project/lldb/.* \
-format \
-style LLVM \
-p ~/llvm-builds/debug-ninja-gcc
```
NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.
NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.
Reviewers: martong, espindola, shafik, #lldb, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits
Tags: #lldb, #llvm
Differential Revision: https://reviews.llvm.org/D61847
llvm-svn: 361484
2019-05-23 19:14:47 +08:00
|
|
|
const char *error_desc = nullptr;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
if (call_plan_sp) {
|
|
|
|
lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
|
|
|
|
if (real_stop_info_sp)
|
|
|
|
error_desc = real_stop_info_sp->GetDescription();
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
if (error_desc)
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"Execution was interrupted, reason: %s.",
|
|
|
|
error_desc);
|
2015-11-03 03:30:40 +08:00
|
|
|
else
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(eDiagnosticSeverityError,
|
|
|
|
"Execution was interrupted.");
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
if ((execution_result == lldb::eExpressionInterrupted &&
|
|
|
|
options.DoesUnwindOnError()) ||
|
|
|
|
(execution_result == lldb::eExpressionHitBreakpoint &&
|
|
|
|
options.DoesIgnoreBreakpoints()))
|
|
|
|
diagnostic_manager.AppendMessageToDiagnostic(
|
|
|
|
"The process has been returned to the state before expression "
|
|
|
|
"evaluation.");
|
|
|
|
else {
|
|
|
|
if (execution_result == lldb::eExpressionHitBreakpoint)
|
|
|
|
user_expression_plan->TransferExpressionOwnership();
|
|
|
|
diagnostic_manager.AppendMessageToDiagnostic(
|
|
|
|
"The process has been left at the point where it was "
|
|
|
|
"interrupted, "
|
|
|
|
"use \"thread return -x\" to return to the state before "
|
|
|
|
"expression evaluation.");
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
return execution_result;
|
|
|
|
} else if (execution_result == lldb::eExpressionStoppedForDebug) {
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(
|
2016-09-07 04:57:50 +08:00
|
|
|
eDiagnosticSeverityRemark,
|
|
|
|
"Execution was halted at the first instruction of the expression "
|
|
|
|
"function because \"debug\" was requested.\n"
|
|
|
|
"Use \"thread return -x\" to return to the state before expression "
|
|
|
|
"evaluation.");
|
|
|
|
return execution_result;
|
|
|
|
} else if (execution_result != lldb::eExpressionCompleted) {
|
|
|
|
diagnostic_manager.Printf(
|
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"Couldn't execute function; result was %s",
|
|
|
|
Process::ExecutionResultAsCString(execution_result));
|
|
|
|
return execution_result;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
if (FinalizeJITExecution(diagnostic_manager, exe_ctx, result,
|
|
|
|
function_stack_bottom, function_stack_top)) {
|
|
|
|
return lldb::eExpressionCompleted;
|
|
|
|
} else {
|
|
|
|
return lldb::eExpressionResultUnavailable;
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
} else {
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(
|
2016-09-07 04:57:50 +08:00
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"Expression can't be run, because there is no JIT compiled function");
|
|
|
|
return lldb::eExpressionSetupError;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool LLVMUserExpression::FinalizeJITExecution(
|
|
|
|
DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
|
|
|
|
lldb::ExpressionVariableSP &result, lldb::addr_t function_stack_bottom,
|
|
|
|
lldb::addr_t function_stack_top) {
|
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("-- [UserExpression::FinalizeJITExecution] Dematerializing "
|
|
|
|
"after execution --");
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!m_dematerializer_sp) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"Couldn't apply expression side effects : no "
|
|
|
|
"dematerializer is present");
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status dematerialize_error;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
m_dematerializer_sp->Dematerialize(dematerialize_error, function_stack_bottom,
|
|
|
|
function_stack_top);
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!dematerialize_error.Success()) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"Couldn't apply expression side effects : %s",
|
|
|
|
dematerialize_error.AsCString("unknown error"));
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
result =
|
|
|
|
GetResultAfterDematerialization(exe_ctx.GetBestExecutionContextScope());
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (result)
|
|
|
|
result->TransferAddress();
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
m_dematerializer_sp.reset();
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
return true;
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
bool LLVMUserExpression::PrepareToExecuteJITExpression(
|
|
|
|
DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
|
|
|
|
lldb::addr_t &struct_address) {
|
|
|
|
lldb::TargetSP target;
|
|
|
|
lldb::ProcessSP process;
|
|
|
|
lldb::StackFrameSP frame;
|
|
|
|
|
|
|
|
if (!LockAndCheckContext(exe_ctx, target, process, frame)) {
|
2016-11-13 03:12:56 +08:00
|
|
|
diagnostic_manager.PutString(
|
2016-09-07 04:57:50 +08:00
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"The context has changed before we could JIT the expression!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_jit_start_addr != LLDB_INVALID_ADDRESS || m_can_interpret) {
|
|
|
|
if (m_materialized_address == LLDB_INVALID_ADDRESS) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status alloc_error;
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
IRMemoryMap::AllocationPolicy policy =
|
|
|
|
m_can_interpret ? IRMemoryMap::eAllocationPolicyHostOnly
|
|
|
|
: IRMemoryMap::eAllocationPolicyMirror;
|
|
|
|
|
|
|
|
const bool zero_memory = false;
|
|
|
|
|
|
|
|
m_materialized_address = m_execution_unit_sp->Malloc(
|
2019-02-13 14:25:41 +08:00
|
|
|
m_materializer_up->GetStructByteSize(),
|
|
|
|
m_materializer_up->GetStructAlignment(),
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::ePermissionsReadable | lldb::ePermissionsWritable, policy,
|
|
|
|
zero_memory, alloc_error);
|
|
|
|
|
|
|
|
if (!alloc_error.Success()) {
|
|
|
|
diagnostic_manager.Printf(
|
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"Couldn't allocate space for materialized struct: %s",
|
|
|
|
alloc_error.AsCString());
|
2015-11-03 03:30:40 +08:00
|
|
|
return false;
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
struct_address = m_materialized_address;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (m_can_interpret && m_stack_frame_bottom == LLDB_INVALID_ADDRESS) {
|
2017-05-12 12:51:55 +08:00
|
|
|
Status alloc_error;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const size_t stack_frame_size = 512 * 1024;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
const bool zero_memory = false;
|
2015-11-05 04:32:27 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
m_stack_frame_bottom = m_execution_unit_sp->Malloc(
|
|
|
|
stack_frame_size, 8,
|
|
|
|
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
|
|
|
|
IRMemoryMap::eAllocationPolicyHostOnly, zero_memory, alloc_error);
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
m_stack_frame_top = m_stack_frame_bottom + stack_frame_size;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!alloc_error.Success()) {
|
|
|
|
diagnostic_manager.Printf(
|
|
|
|
eDiagnosticSeverityError,
|
|
|
|
"Couldn't allocate space for the stack frame: %s",
|
|
|
|
alloc_error.AsCString());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2017-05-12 12:51:55 +08:00
|
|
|
Status materialize_error;
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2019-02-13 14:25:41 +08:00
|
|
|
m_dematerializer_sp = m_materializer_up->Materialize(
|
2016-09-07 04:57:50 +08:00
|
|
|
frame, *m_execution_unit_sp, struct_address, materialize_error);
|
2015-11-03 03:30:40 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if (!materialize_error.Success()) {
|
|
|
|
diagnostic_manager.Printf(eDiagnosticSeverityError,
|
|
|
|
"Couldn't materialize: %s",
|
|
|
|
materialize_error.AsCString());
|
|
|
|
return false;
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
|
|
|
return true;
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
lldb::ModuleSP LLVMUserExpression::GetJITModule() {
|
|
|
|
if (m_execution_unit_sp)
|
|
|
|
return m_execution_unit_sp->GetJITModule();
|
|
|
|
return lldb::ModuleSP();
|
2015-11-03 03:30:40 +08:00
|
|
|
}
|