summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-09-20 23:01:51 +0000
committerSean Callanan <scallanan@apple.com>2011-09-20 23:01:51 +0000
commit90539456a10254fe8c707ad955a43d36cff5187d (patch)
tree81221b223c6bc8c16b93498f6c217d7a43b69d55 /lldb
parent5227ea6028371f6d8538680fef1a79b49eb87f76 (diff)
downloadbcm5719-llvm-90539456a10254fe8c707ad955a43d36cff5187d.tar.gz
bcm5719-llvm-90539456a10254fe8c707ad955a43d36cff5187d.zip
Fixed a problem where expressions would attempt to
allocate memory in a process that did not support expression execution. Also improved detection of whether or not a process can execute expressions. llvm-svn: 140202
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Target/Process.h24
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp26
-rw-r--r--lldb/source/Expression/ClangUserExpression.cpp28
-rw-r--r--lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp3
-rw-r--r--lldb/source/Target/Process.cpp15
5 files changed, 67 insertions, 29 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 3bf87f9c3e5..fbf85a338b3 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2301,6 +2301,24 @@ public:
AllocateMemory (size_t size, uint32_t permissions, Error &error);
//------------------------------------------------------------------
+ /// Determines whether executing JIT-compiled code in this process
+ /// is possible.
+ ///
+ /// @return
+ /// True if execution of JIT code is possible; false otherwise.
+ //------------------------------------------------------------------
+ bool CanJIT ();
+
+ //------------------------------------------------------------------
+ /// Sets whether executing JIT-compiled code in this process
+ /// is possible.
+ ///
+ /// @param[in] can_jit
+ /// True if execution of JIT code is possible; false otherwise.
+ //------------------------------------------------------------------
+ void SetCanJIT (bool can_jit);
+
+ //------------------------------------------------------------------
/// Actually deallocate memory in the process.
///
/// This function will deallocate memory in the process's address
@@ -2771,6 +2789,12 @@ protected:
LanguageRuntimeCollection m_language_runtimes;
std::auto_ptr<NextEventAction> m_next_event_action_ap;
+ enum {
+ eCanJITDontKnow= 0,
+ eCanJITYes,
+ eCanJITNo
+ } m_can_jit;
+
size_t
RemoveBreakpointOpcodesFromBuffer (lldb::addr_t addr, size_t size, uint8_t *buf) const;
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index 921dc00c7f4..3549196ed68 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -496,8 +496,32 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
return err;
}
- if (m_expr.NeedsValidation() && exe_ctx.process && exe_ctx.process->GetDynamicCheckers())
+ if (execution_policy != eExecutionPolicyNever &&
+ m_expr.NeedsValidation() &&
+ exe_ctx.process)
{
+ if (!exe_ctx.process->GetDynamicCheckers())
+ {
+ DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
+
+ StreamString install_errors;
+
+ if (!dynamic_checkers->Install(install_errors, exe_ctx))
+ {
+ if (install_errors.GetString().empty())
+ err.SetErrorString ("couldn't install checkers, unknown error");
+ else
+ err.SetErrorString (install_errors.GetString().c_str());
+
+ return err;
+ }
+
+ exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
+
+ if (log)
+ log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
+ }
+
IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str());
if (!ir_dynamic_checks.runOnModule(*module))
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index 742367f55b3..194ad95a190 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -615,34 +615,8 @@ ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx,
}
}
- if (exe_ctx.process == NULL)
+ if (exe_ctx.process == NULL || !exe_ctx.process->CanJIT())
execution_policy = eExecutionPolicyNever;
-
- if (execution_policy != eExecutionPolicyNever && !exe_ctx.process->GetDynamicCheckers())
- {
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Installing dynamic checkers ==");
-
- DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions();
-
- StreamString install_errors;
-
- if (!dynamic_checkers->Install(install_errors, exe_ctx))
- {
- if (install_errors.GetString().empty())
- error.SetErrorString ("couldn't install checkers, unknown error");
- else
- error.SetErrorString (install_errors.GetString().c_str());
-
- result_valobj_sp = ValueObjectConstResult::Create (NULL, error);
- return eExecutionSetupError;
- }
-
- exe_ctx.process->SetDynamicCheckers(dynamic_checkers);
-
- if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Finished installing dynamic checkers ==");
- }
ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix));
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index e5f6155025b..6628f92a10f 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -78,7 +78,10 @@ DynamicLoaderDarwinKernel::CreateInstance (Process* process, bool force)
}
if (create)
+ {
+ process->SetCanJIT(false);
return new DynamicLoaderDarwinKernel (process);
+ }
return NULL;
}
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 14f26d24c26..bab1eda3bc1 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -601,7 +601,8 @@ Process::Process(Target &target, Listener &listener) :
m_memory_cache (*this),
m_allocated_memory_cache (*this),
m_attached_to_process (false),
- m_next_event_action_ap()
+ m_next_event_action_ap(),
+ m_can_jit(eCanJITYes)
{
UpdateInstanceName();
@@ -1956,6 +1957,18 @@ Process::AllocateMemory(size_t size, uint32_t permissions, Error &error)
#endif
}
+bool
+Process::CanJIT ()
+{
+ return m_can_jit == eCanJITYes;
+}
+
+void
+Process::SetCanJIT (bool can_jit)
+{
+ m_can_jit = (can_jit ? eCanJITYes : eCanJITNo);
+}
+
Error
Process::DeallocateMemory (addr_t ptr)
{
OpenPOWER on IntegriCloud