summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangExpressionParser.cpp
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-09-15 02:13:07 +0000
committerSean Callanan <scallanan@apple.com>2011-09-15 02:13:07 +0000
commit3bfdaa2a4735262a1d246ced4db906a3531ba330 (patch)
tree8ff56a95ada43dd7cee0482eb3400462c7eb9054 /lldb/source/Expression/ClangExpressionParser.cpp
parent5acab501de113acb4c0d28b48e76c27631ba0904 (diff)
downloadbcm5719-llvm-3bfdaa2a4735262a1d246ced4db906a3531ba330.tar.gz
bcm5719-llvm-3bfdaa2a4735262a1d246ced4db906a3531ba330.zip
This patch modifies the expression parser to allow it
to execute expressions even in the absence of a process. This allows expressions to run in situations where the target cannot run -- e.g., to perform calculations based on type information, or to inspect a binary's static data. This modification touches the following files: lldb-private-enumerations.h Introduce a new enum specifying the policy for processing an expression. Some expressions should always be JITted, for example if they are functions that will be used over and over again. Some expressions should always be interpreted, for example if the target is unsafe to run. For most, it is acceptable to JIT them, but interpretation is preferable when possible. Target.[h,cpp] Have EvaluateExpression now accept the new enum. ClangExpressionDeclMap.[cpp,h] Add support for the IR interpreter and also make the ClangExpressionDeclMap more robust in the absence of a process. ClangFunction.[cpp,h] Add support for the new enum. IRInterpreter.[cpp,h] New implementation. ClangUserExpression.[cpp,h] Add support for the new enum, and for running expressions in the absence of a process. ClangExpression.h Remove references to the old DWARF-based method of evaluating expressions, because it has been superseded for now. ClangUtilityFunction.[cpp,h] Add support for the new enum. ClangExpressionParser.[cpp,h] Add support for the new enum, remove references to DWARF, and add support for checking whether the expression could be evaluated statically. IRForTarget.[h,cpp] Add support for the new enum, and add utility functions to support the interpreter. IRToDWARF.cpp Removed CommandObjectExpression.cpp Remove references to the obsolete -i option. Process.cpp Modify calls to ClangUserExpression::Evaluate to pass the correct enum (for dlopen/dlclose) SBValue.cpp Add support for the new enum. SBFrame.cpp Add support for he new enum. BreakpointOptions.cpp Add support for the new enum. llvm-svn: 139772
Diffstat (limited to 'lldb/source/Expression/ClangExpressionParser.cpp')
-rw-r--r--lldb/source/Expression/ClangExpressionParser.cpp86
1 files changed, 21 insertions, 65 deletions
diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp
index 81c03f36c52..921dc00c7f4 100644
--- a/lldb/source/Expression/ClangExpressionParser.cpp
+++ b/lldb/source/Expression/ClangExpressionParser.cpp
@@ -19,7 +19,6 @@
#include "lldb/Expression/ClangExpression.h"
#include "lldb/Expression/ClangExpressionDeclMap.h"
#include "lldb/Expression/IRDynamicChecks.h"
-#include "lldb/Expression/IRToDWARF.h"
#include "lldb/Expression/RecordingMemoryManager.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
@@ -418,66 +417,14 @@ static bool FindFunctionInModule (std::string &mangled_name,
}
Error
-ClangExpressionParser::MakeDWARF ()
-{
- Error err;
-
- llvm::Module *module = m_code_generator->GetModule();
-
- if (!module)
- {
- err.SetErrorToGenericError();
- err.SetErrorString("IR doesn't contain a module");
- return err;
- }
-
- ClangExpressionVariableList *local_variables = m_expr.LocalVariables();
- ClangExpressionDeclMap *decl_map = m_expr.DeclMap();
-
- if (!local_variables)
- {
- err.SetErrorToGenericError();
- err.SetErrorString("Can't convert an expression without a VariableList to DWARF");
- return err;
- }
-
- if (!decl_map)
- {
- err.SetErrorToGenericError();
- err.SetErrorString("Can't convert an expression without a DeclMap to DWARF");
- return err;
- }
-
- std::string function_name;
-
- if (!FindFunctionInModule(function_name, module, m_expr.FunctionName()))
- {
- err.SetErrorToGenericError();
- err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName());
- return err;
- }
-
- IRToDWARF ir_to_dwarf(*local_variables, decl_map, m_expr.DwarfOpcodeStream(), function_name.c_str());
-
- if (!ir_to_dwarf.runOnModule(*module))
- {
- err.SetErrorToGenericError();
- err.SetErrorString("Couldn't convert the expression to DWARF");
- return err;
- }
-
- err.Clear();
- return err;
-}
-
-Error
-ClangExpressionParser::MakeJIT (lldb::addr_t &func_allocation_addr,
- lldb::addr_t &func_addr,
- lldb::addr_t &func_end,
- ExecutionContext &exe_ctx,
- IRForTarget::StaticDataAllocator *data_allocator,
- lldb::ClangExpressionVariableSP &const_result,
- bool jit_only_if_needed)
+ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr,
+ lldb::addr_t &func_addr,
+ lldb::addr_t &func_end,
+ ExecutionContext &exe_ctx,
+ IRForTarget::StaticDataAllocator *data_allocator,
+ bool &evaluated_statically,
+ lldb::ClangExpressionVariableSP &const_result,
+ ExecutionPolicy execution_policy)
{
func_allocation_addr = LLDB_INVALID_ADDRESS;
func_addr = LLDB_INVALID_ADDRESS;
@@ -520,8 +467,9 @@ ClangExpressionParser::MakeJIT (lldb::addr_t &func_allocation_addr,
if (exe_ctx.target)
error_stream = &exe_ctx.target->GetDebugger().GetErrorStream();
- IRForTarget ir_for_target(decl_map,
+ IRForTarget ir_for_target(decl_map,
m_expr.NeedsVariableResolution(),
+ execution_policy,
const_result,
data_allocator,
error_stream,
@@ -530,17 +478,25 @@ ClangExpressionParser::MakeJIT (lldb::addr_t &func_allocation_addr,
if (!ir_for_target.runOnModule(*module))
{
err.SetErrorToGenericError();
- err.SetErrorString("Couldn't convert the expression to DWARF");
+ err.SetErrorString("Couldn't prepare the expression for execution in the target");
return err;
}
- if (jit_only_if_needed && const_result.get())
+ if (execution_policy != eExecutionPolicyAlways && ir_for_target.interpretSuccess())
{
+ evaluated_statically = true;
err.Clear();
return err;
}
- if (m_expr.NeedsValidation() && exe_ctx.process->GetDynamicCheckers())
+ if (!exe_ctx.process || execution_policy == eExecutionPolicyNever)
+ {
+ err.SetErrorToGenericError();
+ err.SetErrorString("Execution needed to run in the target, but the target can't be run");
+ return err;
+ }
+
+ if (m_expr.NeedsValidation() && exe_ctx.process && exe_ctx.process->GetDynamicCheckers())
{
IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), function_name.c_str());
OpenPOWER on IntegriCloud