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
2011-09-15 10:13:07 +08:00
|
|
|
//===-- IRInterpreter.cpp ---------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-04-26 02:55:45 +08:00
|
|
|
#include "lldb/Core/DataExtractor.h"
|
|
|
|
#include "lldb/Core/Error.h"
|
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
2011-09-15 10:13:07 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
#include "lldb/Core/ModuleSpec.h"
|
|
|
|
#include "lldb/Core/Module.h"
|
2013-04-26 02:55:45 +08:00
|
|
|
#include "lldb/Core/Scalar.h"
|
|
|
|
#include "lldb/Core/StreamString.h"
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
2013-04-26 02:55:45 +08:00
|
|
|
#include "lldb/Expression/IRMemoryMap.h"
|
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
2011-09-15 10:13:07 +08:00
|
|
|
#include "lldb/Expression/IRInterpreter.h"
|
2013-09-18 02:26:42 +08:00
|
|
|
#include "lldb/Host/Endian.h"
|
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
2011-09-15 10:13:07 +08:00
|
|
|
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
#include "lldb/Target/ABI.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
#include "lldb/Target/ThreadPlan.h"
|
|
|
|
#include "lldb/Target/ThreadPlanCallFunctionUsingABI.h"
|
|
|
|
|
2013-01-02 20:20:07 +08:00
|
|
|
#include "llvm/IR/Constants.h"
|
2013-04-26 02:55:45 +08:00
|
|
|
#include "llvm/IR/DataLayout.h"
|
2013-01-02 20:20:07 +08:00
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/Instructions.h"
|
2014-03-26 03:33:15 +08:00
|
|
|
#include "llvm/IR/Intrinsics.h"
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
#include "llvm/IR/LLVMContext.h"
|
2013-01-02 20:20:07 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
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
2011-09-15 10:13:07 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-07-07 01:54:58 +08:00
|
|
|
static std::string
|
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
2011-09-15 10:13:07 +08:00
|
|
|
PrintValue(const Value *value, bool truncate = false)
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
raw_string_ostream rso(s);
|
|
|
|
value->print(rso);
|
|
|
|
rso.flush();
|
|
|
|
if (truncate)
|
|
|
|
s.resize(s.length() - 1);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
size_t offset;
|
|
|
|
while ((offset = s.find('\n')) != s.npos)
|
|
|
|
s.erase(offset, 1);
|
|
|
|
while (s[0] == ' ' || s[0] == '\t')
|
|
|
|
s.erase(0, 1);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static std::string
|
|
|
|
PrintType(const Type *type, bool truncate = false)
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
raw_string_ostream rso(s);
|
|
|
|
type->print(rso);
|
|
|
|
rso.flush();
|
|
|
|
if (truncate)
|
|
|
|
s.resize(s.length() - 1);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2014-03-26 03:33:15 +08:00
|
|
|
static bool
|
|
|
|
CanIgnoreCall (const CallInst *call)
|
|
|
|
{
|
|
|
|
const llvm::Function *called_function = call->getCalledFunction();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2014-03-26 03:33:15 +08:00
|
|
|
if (!called_function)
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2014-03-26 03:33:15 +08:00
|
|
|
if (called_function->isIntrinsic())
|
|
|
|
{
|
|
|
|
switch (called_function->getIntrinsicID())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case llvm::Intrinsic::dbg_declare:
|
|
|
|
case llvm::Intrinsic::dbg_value:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2014-03-26 03:33:15 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
class InterpreterStackFrame
|
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
2011-09-15 10:13:07 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-04-17 15:50:58 +08:00
|
|
|
typedef std::map <const Value*, lldb::addr_t> ValueMap;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
ValueMap m_values;
|
2012-10-09 00:28:57 +08:00
|
|
|
DataLayout &m_target_data;
|
2013-04-17 07:49:09 +08:00
|
|
|
lldb_private::IRMemoryMap &m_memory_map;
|
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
2011-09-15 10:13:07 +08:00
|
|
|
const BasicBlock *m_bb;
|
|
|
|
BasicBlock::const_iterator m_ii;
|
|
|
|
BasicBlock::const_iterator m_ie;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t m_frame_process_address;
|
|
|
|
size_t m_frame_size;
|
|
|
|
lldb::addr_t m_stack_pointer;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
lldb::ByteOrder m_byte_order;
|
|
|
|
size_t m_addr_byte_size;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2012-10-09 00:28:57 +08:00
|
|
|
InterpreterStackFrame (DataLayout &target_data,
|
2013-04-27 10:19:33 +08:00
|
|
|
lldb_private::IRMemoryMap &memory_map,
|
|
|
|
lldb::addr_t stack_frame_bottom,
|
|
|
|
lldb::addr_t stack_frame_top) :
|
2011-11-01 06:50:49 +08:00
|
|
|
m_target_data (target_data),
|
2013-04-17 07:49:09 +08:00
|
|
|
m_memory_map (memory_map)
|
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
2011-09-15 10:13:07 +08:00
|
|
|
{
|
|
|
|
m_byte_order = (target_data.isLittleEndian() ? lldb::eByteOrderLittle : lldb::eByteOrderBig);
|
2012-10-12 06:00:52 +08:00
|
|
|
m_addr_byte_size = (target_data.getPointerSize(0));
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-27 10:19:33 +08:00
|
|
|
m_frame_process_address = stack_frame_bottom;
|
|
|
|
m_frame_size = stack_frame_top - stack_frame_bottom;
|
|
|
|
m_stack_pointer = stack_frame_top;
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
~InterpreterStackFrame ()
|
|
|
|
{
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
void Jump (const BasicBlock *bb)
|
|
|
|
{
|
|
|
|
m_bb = bb;
|
|
|
|
m_ii = m_bb->begin();
|
|
|
|
m_ie = m_bb->end();
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
std::string SummarizeValue (const Value *value)
|
|
|
|
{
|
|
|
|
lldb_private::StreamString ss;
|
|
|
|
|
|
|
|
ss.Printf("%s", PrintValue(value).c_str());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
ValueMap::iterator i = m_values.find(value);
|
|
|
|
|
|
|
|
if (i != m_values.end())
|
|
|
|
{
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb::addr_t addr = i->second;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
ss.Printf(" 0x%llx", (unsigned long long)addr);
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return ss.GetString();
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
bool AssignToMatchType (lldb_private::Scalar &scalar, uint64_t u64value, Type *type)
|
|
|
|
{
|
|
|
|
size_t type_size = m_target_data.getTypeStoreSize(type);
|
|
|
|
|
|
|
|
switch (type_size)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
scalar = (uint8_t)u64value;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
scalar = (uint16_t)u64value;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
scalar = (uint32_t)u64value;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
scalar = (uint64_t)u64value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return true;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
bool EvaluateValue (lldb_private::Scalar &scalar, const Value *value, Module &module)
|
|
|
|
{
|
|
|
|
const Constant *constant = dyn_cast<Constant>(value);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
if (constant)
|
|
|
|
{
|
2013-06-06 06:07:06 +08:00
|
|
|
APInt value_apint;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
if (!ResolveConstantValue(value_apint, constant))
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
return AssignToMatchType(scalar, value_apint.getLimitedValue(), value->getType());
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb::addr_t process_address = ResolveValue(value, module);
|
|
|
|
size_t value_size = m_target_data.getTypeStoreSize(value->getType());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::DataExtractor value_extractor;
|
|
|
|
lldb_private::Error extract_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
m_memory_map.GetMemoryData(value_extractor, process_address, value_size, extract_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
if (!extract_error.Success())
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-01-26 02:06:21 +08:00
|
|
|
lldb::offset_t offset = 0;
|
2013-06-07 05:14:35 +08:00
|
|
|
if (value_size == 1 || value_size == 2 || value_size == 4 || value_size == 8)
|
2013-04-25 08:57:05 +08:00
|
|
|
{
|
|
|
|
uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size);
|
|
|
|
return AssignToMatchType(scalar, u64value, value->getType());
|
|
|
|
}
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
bool AssignValue (const Value *value, lldb_private::Scalar &scalar, Module &module)
|
|
|
|
{
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb::addr_t process_address = ResolveValue (value, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
if (process_address == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
lldb_private::Scalar cast_scalar;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
if (!AssignToMatchType(cast_scalar, scalar.GetRawBits64(0), value->getType()))
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
size_t value_byte_size = m_target_data.getTypeStoreSize(value->getType());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::DataBufferHeap buf(value_byte_size, 0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::Error get_data_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
if (!cast_scalar.GetAsMemoryData(buf.GetBytes(), buf.GetByteSize(), m_byte_order, get_data_error))
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::Error write_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
m_memory_map.WriteMemory(process_address, buf.GetBytes(), buf.GetByteSize(), write_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
return write_error.Success();
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2012-02-08 09:27:49 +08:00
|
|
|
bool ResolveConstantValue (APInt &value, const Constant *constant)
|
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
2011-09-15 10:13:07 +08:00
|
|
|
{
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
switch (constant->getValueID())
|
2011-10-21 13:18:02 +08:00
|
|
|
{
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case Value::ConstantIntVal:
|
|
|
|
if (const ConstantInt *constant_int = dyn_cast<ConstantInt>(constant))
|
2011-10-21 13:18:02 +08:00
|
|
|
{
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
value = constant_int->getValue();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Value::ConstantFPVal:
|
|
|
|
if (const ConstantFP *constant_fp = dyn_cast<ConstantFP>(constant))
|
|
|
|
{
|
|
|
|
value = constant_fp->getValueAPF().bitcastToAPInt();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Value::ConstantExprVal:
|
|
|
|
if (const ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(constant))
|
|
|
|
{
|
|
|
|
switch (constant_expr->getOpcode())
|
2012-02-08 09:27:49 +08:00
|
|
|
{
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
default:
|
2012-02-08 09:27:49 +08:00
|
|
|
return false;
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
case Instruction::IntToPtr:
|
|
|
|
case Instruction::PtrToInt:
|
|
|
|
case Instruction::BitCast:
|
|
|
|
return ResolveConstantValue(value, constant_expr->getOperand(0));
|
|
|
|
case Instruction::GetElementPtr:
|
|
|
|
{
|
|
|
|
ConstantExpr::const_op_iterator op_cursor = constant_expr->op_begin();
|
|
|
|
ConstantExpr::const_op_iterator op_end = constant_expr->op_end();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
Constant *base = dyn_cast<Constant>(*op_cursor);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (!base)
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (!ResolveConstantValue(value, base))
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
op_cursor++;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (op_cursor == op_end)
|
|
|
|
return true; // no offset to apply!
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
SmallVector <Value *, 8> indices (op_cursor, op_end);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
uint64_t offset = m_target_data.getIndexedOffset(base->getType(), indices);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
const bool is_signed = true;
|
|
|
|
value += APInt(value.getBitWidth(), offset, is_signed);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
return true;
|
|
|
|
}
|
2012-02-08 09:27:49 +08:00
|
|
|
}
|
2011-10-21 13:18:02 +08:00
|
|
|
}
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
break;
|
|
|
|
case Value::ConstantPointerNullVal:
|
|
|
|
if (isa<ConstantPointerNull>(constant))
|
|
|
|
{
|
|
|
|
value = APInt(m_target_data.getPointerSizeInBits(), 0);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2011-10-21 13:18:02 +08:00
|
|
|
}
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
bool MakeArgument(const Argument *value, uint64_t address)
|
|
|
|
{
|
|
|
|
lldb::addr_t data_address = Malloc(value->getType());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (data_address == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb_private::Error write_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
m_memory_map.WritePointerToMemory(data_address, address, write_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (!write_error.Success())
|
|
|
|
{
|
|
|
|
lldb_private::Error free_error;
|
|
|
|
m_memory_map.Free(data_address, free_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
m_values[value] = data_address;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Made an allocation for argument %s", PrintValue(value).c_str());
|
|
|
|
log->Printf(" Data region : %llx", (unsigned long long)address);
|
|
|
|
log->Printf(" Ref region : %llx", (unsigned long long)data_address);
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
return true;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
bool ResolveConstant (lldb::addr_t process_address, const Constant *constant)
|
2012-02-08 09:27:49 +08:00
|
|
|
{
|
|
|
|
APInt resolved_value;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2012-02-08 09:27:49 +08:00
|
|
|
if (!ResolveConstantValue(resolved_value, constant))
|
|
|
|
return false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-09-18 02:26:42 +08:00
|
|
|
lldb_private::StreamString buffer (lldb_private::Stream::eBinary,
|
|
|
|
m_memory_map.GetAddressByteSize(),
|
|
|
|
m_memory_map.GetByteOrder());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2012-02-08 09:27:49 +08:00
|
|
|
size_t constant_size = m_target_data.getTypeStoreSize(constant->getType());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-09-18 02:26:42 +08:00
|
|
|
const uint64_t *raw_data = resolved_value.getRawData();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-09-18 02:26:42 +08:00
|
|
|
buffer.PutRawBytes(raw_data, constant_size, lldb::endian::InlHostByteOrder());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::Error write_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-09-18 02:26:42 +08:00
|
|
|
m_memory_map.WriteMemory(process_address, (const uint8_t*)buffer.GetData(), constant_size, write_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
return write_error.Success();
|
2012-02-08 09:27:49 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t Malloc (size_t size, uint8_t byte_alignment)
|
2013-04-17 15:50:58 +08:00
|
|
|
{
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t ret = m_stack_pointer;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
ret -= size;
|
|
|
|
ret -= (ret % byte_alignment);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (ret < m_frame_process_address)
|
2013-04-17 15:50:58 +08:00
|
|
|
return LLDB_INVALID_ADDRESS;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
m_stack_pointer = ret;
|
|
|
|
return ret;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t MallocPointer ()
|
|
|
|
{
|
|
|
|
return Malloc(m_target_data.getPointerSize(), m_target_data.getPointerPrefAlignment());
|
2013-04-17 15:50:58 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t Malloc (llvm::Type *type)
|
2013-04-17 15:50:58 +08:00
|
|
|
{
|
|
|
|
lldb_private::Error alloc_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
return Malloc(m_target_data.getTypeAllocSize(type), m_target_data.getPrefTypeAlignment(type));
|
2013-04-17 15:50:58 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
std::string PrintData (lldb::addr_t addr, llvm::Type *type)
|
|
|
|
{
|
|
|
|
size_t length = m_target_data.getTypeStoreSize(type);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::DataBufferHeap buf(length, 0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::Error read_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
m_memory_map.ReadMemory(buf.GetBytes(), addr, length, read_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
if (!read_error.Success())
|
|
|
|
return std::string("<couldn't read data>");
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb_private::StreamString ss;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
for (size_t i = 0; i < length; i++)
|
|
|
|
{
|
|
|
|
if ((!(i & 0xf)) && i)
|
|
|
|
ss.Printf("%02hhx - ", buf.GetBytes()[i]);
|
|
|
|
else
|
|
|
|
ss.Printf("%02hhx ", buf.GetBytes()[i]);
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
return ss.GetString();
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-17 15:50:58 +08:00
|
|
|
lldb::addr_t ResolveValue (const Value *value, Module &module)
|
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
2011-09-15 10:13:07 +08:00
|
|
|
{
|
|
|
|
ValueMap::iterator i = m_values.find(value);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
if (i != m_values.end())
|
|
|
|
return i->second;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
// Fall back and allocate space [allocation type Alloca]
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t data_address = Malloc(value->getType());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (const Constant *constant = dyn_cast<Constant>(value))
|
|
|
|
{
|
|
|
|
if (!ResolveConstant (data_address, constant))
|
|
|
|
{
|
|
|
|
lldb_private::Error free_error;
|
|
|
|
m_memory_map.Free(data_address, free_error);
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
|
|
|
}
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
m_values[value] = data_address;
|
|
|
|
return data_address;
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-01-25 06:06:48 +08:00
|
|
|
static const char *unsupported_opcode_error = "Interpreter doesn't handle one of the expression's opcodes";
|
2013-05-02 08:33:44 +08:00
|
|
|
static const char *unsupported_operand_error = "Interpreter doesn't handle one of the expression's operands";
|
2013-04-19 02:10:51 +08:00
|
|
|
//static const char *interpreter_initialization_error = "Interpreter couldn't be initialized";
|
2012-01-25 06:06:48 +08:00
|
|
|
static const char *interpreter_internal_error = "Interpreter encountered an internal error";
|
|
|
|
static const char *bad_value_error = "Interpreter couldn't resolve a value during execution";
|
|
|
|
static const char *memory_allocation_error = "Interpreter couldn't allocate memory";
|
|
|
|
static const char *memory_write_error = "Interpreter couldn't write to memory";
|
|
|
|
static const char *memory_read_error = "Interpreter couldn't read from memory";
|
|
|
|
static const char *infinite_loop_error = "Interpreter ran for too many cycles";
|
2013-04-19 16:14:32 +08:00
|
|
|
//static const char *bad_result_error = "Result of expression is in bad memory";
|
2012-01-25 06:06:48 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
bool
|
2013-04-19 16:14:32 +08:00
|
|
|
IRInterpreter::CanInterpret (llvm::Module &module,
|
|
|
|
llvm::Function &function,
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
lldb_private::Error &error,
|
|
|
|
const bool support_function_calls)
|
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
2011-09-15 10:13:07 +08:00
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-27 09:59:51 +08:00
|
|
|
bool saw_function_with_body = false;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-27 09:59:51 +08:00
|
|
|
for (Module::iterator fi = module.begin(), fe = module.end();
|
|
|
|
fi != fe;
|
|
|
|
++fi)
|
|
|
|
{
|
|
|
|
if (fi->begin() != fi->end())
|
|
|
|
{
|
|
|
|
if (saw_function_with_body)
|
|
|
|
return false;
|
|
|
|
saw_function_with_body = true;
|
|
|
|
}
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-19 16:14:32 +08:00
|
|
|
for (Function::iterator bbi = function.begin(), bbe = function.end();
|
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
2011-09-15 10:13:07 +08:00
|
|
|
bbi != bbe;
|
|
|
|
++bbi)
|
|
|
|
{
|
|
|
|
for (BasicBlock::iterator ii = bbi->begin(), ie = bbi->end();
|
|
|
|
ii != ie;
|
|
|
|
++ii)
|
|
|
|
{
|
|
|
|
switch (ii->getOpcode())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Unsupported instruction: %s", PrintValue(ii).c_str());
|
2013-04-19 16:14:32 +08:00
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(unsupported_opcode_error);
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case Instruction::Add:
|
|
|
|
case Instruction::Alloca:
|
|
|
|
case Instruction::BitCast:
|
|
|
|
case Instruction::Br:
|
2014-03-26 03:33:15 +08:00
|
|
|
break;
|
|
|
|
case Instruction::Call:
|
|
|
|
{
|
|
|
|
CallInst *call_inst = dyn_cast<CallInst>(ii);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2014-03-26 03:33:15 +08:00
|
|
|
if (!call_inst)
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
if (!CanIgnoreCall(call_inst) && !support_function_calls)
|
2014-03-26 03:33:15 +08:00
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Unsupported instruction: %s", PrintValue(ii).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(unsupported_opcode_error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2014-03-26 03:47:07 +08:00
|
|
|
break;
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case Instruction::GetElementPtr:
|
|
|
|
break;
|
|
|
|
case Instruction::ICmp:
|
|
|
|
{
|
|
|
|
ICmpInst *icmp_inst = dyn_cast<ICmpInst>(ii);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
if (!icmp_inst)
|
2012-01-25 06:06:48 +08:00
|
|
|
{
|
2013-04-19 16:14:32 +08:00
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
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
2011-09-15 10:13:07 +08:00
|
|
|
return false;
|
2012-01-25 06:06:48 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
switch (icmp_inst->getPredicate())
|
|
|
|
{
|
|
|
|
default:
|
2013-04-19 16:14:32 +08:00
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Unsupported ICmp predicate: %s", PrintValue(ii).c_str());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-19 16:14:32 +08:00
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(unsupported_opcode_error);
|
|
|
|
return false;
|
|
|
|
}
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case CmpInst::ICMP_EQ:
|
|
|
|
case CmpInst::ICMP_NE:
|
|
|
|
case CmpInst::ICMP_UGT:
|
|
|
|
case CmpInst::ICMP_UGE:
|
|
|
|
case CmpInst::ICMP_ULT:
|
|
|
|
case CmpInst::ICMP_ULE:
|
|
|
|
case CmpInst::ICMP_SGT:
|
|
|
|
case CmpInst::ICMP_SGE:
|
|
|
|
case CmpInst::ICMP_SLT:
|
|
|
|
case CmpInst::ICMP_SLE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-01-10 06:44:41 +08:00
|
|
|
case Instruction::And:
|
|
|
|
case Instruction::AShr:
|
2011-10-21 13:18:02 +08:00
|
|
|
case Instruction::IntToPtr:
|
2012-12-01 08:09:34 +08:00
|
|
|
case Instruction::PtrToInt:
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case Instruction::Load:
|
2013-01-10 06:44:41 +08:00
|
|
|
case Instruction::LShr:
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case Instruction::Mul:
|
2013-01-10 06:44:41 +08:00
|
|
|
case Instruction::Or:
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case Instruction::Ret:
|
|
|
|
case Instruction::SDiv:
|
2013-06-06 06:07:06 +08:00
|
|
|
case Instruction::SExt:
|
2013-01-10 06:44:41 +08:00
|
|
|
case Instruction::Shl:
|
2012-12-22 06:27:55 +08:00
|
|
|
case Instruction::SRem:
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case Instruction::Store:
|
|
|
|
case Instruction::Sub:
|
2013-10-12 03:45:00 +08:00
|
|
|
case Instruction::Trunc:
|
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
2011-09-15 10:13:07 +08:00
|
|
|
case Instruction::UDiv:
|
2012-12-22 06:27:55 +08:00
|
|
|
case Instruction::URem:
|
2013-01-10 06:44:41 +08:00
|
|
|
case Instruction::Xor:
|
2012-04-24 01:25:38 +08:00
|
|
|
case Instruction::ZExt:
|
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
2011-09-15 10:13:07 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-05-02 08:33:44 +08:00
|
|
|
for (int oi = 0, oe = ii->getNumOperands();
|
|
|
|
oi != oe;
|
|
|
|
++oi)
|
|
|
|
{
|
|
|
|
Value *operand = ii->getOperand(oi);
|
|
|
|
Type *operand_type = operand->getType();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-05-02 08:33:44 +08:00
|
|
|
switch (operand_type->getTypeID())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case Type::VectorTyID:
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Unsupported operand type: %s", PrintType(operand_type).c_str());
|
|
|
|
error.SetErrorString(unsupported_operand_error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
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
2011-09-15 10:13:07 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-19 16:14:32 +08:00
|
|
|
return true;}
|
2013-04-18 02:35:47 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
IRInterpreter::Interpret (llvm::Module &module,
|
|
|
|
llvm::Function &function,
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
llvm::ArrayRef<lldb::addr_t> args,
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::IRMemoryMap &memory_map,
|
2013-04-27 10:19:33 +08:00
|
|
|
lldb_private::Error &error,
|
|
|
|
lldb::addr_t stack_frame_bottom,
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
lldb::addr_t stack_frame_top,
|
|
|
|
lldb_private::ExecutionContext &exe_ctx)
|
2013-04-18 02:35:47 +08:00
|
|
|
{
|
|
|
|
lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
raw_string_ostream oss(s);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
module.print(oss, NULL);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
oss.flush();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
log->Printf("Module as passed in to IRInterpreter::Interpret: \n\"%s\"", s.c_str());
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
DataLayout data_layout(&module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-27 10:19:33 +08:00
|
|
|
InterpreterStackFrame frame(data_layout, memory_map, stack_frame_bottom, stack_frame_top);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
if (frame.m_frame_process_address == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
error.SetErrorString("Couldn't allocate stack frame");
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
int arg_index = 0;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
for (llvm::Function::arg_iterator ai = function.arg_begin(), ae = function.arg_end();
|
|
|
|
ai != ae;
|
|
|
|
++ai, ++arg_index)
|
|
|
|
{
|
2014-04-02 11:51:35 +08:00
|
|
|
if (args.size() < static_cast<size_t>(arg_index))
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
{
|
|
|
|
error.SetErrorString ("Not enough arguments passed in to function");
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
This commit changes the way LLDB executes user
expressions.
Previously, ClangUserExpression assumed that if
there was a constant result for an expression
then it could be determined during parsing. In
particular, the IRInterpreter ran while parser
state (in particular, ClangExpressionDeclMap)
was present. This approach is flawed, because
the IRInterpreter actually is capable of using
external variables, and hence the result might
be different each run. Until now, we papered
over this flaw by re-parsing the expression each
time we ran it.
I have rewritten the IRInterpreter to be
completely independent of the ClangExpressionDeclMap.
Instead of special-casing external variable lookup,
which ties the IRInterpreter closely to LLDB,
we now interpret the exact same IR that the JIT
would see. This IR assumes that materialization
has occurred; hence the recent implementation of the
Materializer, which does not require parser state
(in the form of ClangExpressionDeclMap) to be
present.
Materialization, interpretation, and dematerialization
are now all independent of parsing. This means that
in theory we can parse expressions once and run them
many times. I have three outstanding tasks before
shutting this down:
- First, I will ensure that all of this works with
core files. Core files have a Process but do not
allow allocating memory, which currently confuses
materialization.
- Second, I will make expression breakpoint
conditions remember their ClangUserExpression and
re-use it.
- Third, I will tear out all the redundant code
(for example, materialization logic in
ClangExpressionDeclMap) that is no longer used.
While implementing this fix, I also found a bug in
IRForTarget's handling of floating-point constants.
This should be fixed.
llvm-svn: 179801
2013-04-19 06:06:33 +08:00
|
|
|
lldb::addr_t ptr = args[arg_index];
|
|
|
|
|
|
|
|
frame.MakeArgument(ai, ptr);
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
uint32_t num_insts = 0;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.Jump(function.begin());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
while (frame.m_ii != frame.m_ie && (++num_insts < 4096))
|
|
|
|
{
|
|
|
|
const Instruction *inst = frame.m_ii;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Interpreting %s", PrintValue(inst).c_str());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
switch (inst->getOpcode())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
case Instruction::Add:
|
|
|
|
case Instruction::Sub:
|
|
|
|
case Instruction::Mul:
|
|
|
|
case Instruction::SDiv:
|
|
|
|
case Instruction::UDiv:
|
|
|
|
case Instruction::SRem:
|
|
|
|
case Instruction::URem:
|
|
|
|
case Instruction::Shl:
|
|
|
|
case Instruction::LShr:
|
|
|
|
case Instruction::AShr:
|
|
|
|
case Instruction::And:
|
|
|
|
case Instruction::Or:
|
|
|
|
case Instruction::Xor:
|
|
|
|
{
|
|
|
|
const BinaryOperator *bin_op = dyn_cast<BinaryOperator>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!bin_op)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns %s, but instruction is not a BinaryOperator", inst->getOpcodeName());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Value *lhs = inst->getOperand(0);
|
|
|
|
Value *rhs = inst->getOperand(1);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar L;
|
|
|
|
lldb_private::Scalar R;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(L, lhs, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(lhs).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(R, rhs, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(rhs).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar result;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
switch (inst->getOpcode())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case Instruction::Add:
|
|
|
|
result = L + R;
|
|
|
|
break;
|
|
|
|
case Instruction::Mul:
|
|
|
|
result = L * R;
|
|
|
|
break;
|
|
|
|
case Instruction::Sub:
|
|
|
|
result = L - R;
|
|
|
|
break;
|
|
|
|
case Instruction::SDiv:
|
2013-05-25 04:36:56 +08:00
|
|
|
L.MakeSigned();
|
|
|
|
R.MakeSigned();
|
2013-04-18 02:35:47 +08:00
|
|
|
result = L / R;
|
|
|
|
break;
|
|
|
|
case Instruction::UDiv:
|
|
|
|
result = L.GetRawBits64(0) / R.GetRawBits64(1);
|
|
|
|
break;
|
|
|
|
case Instruction::SRem:
|
2013-05-25 04:36:56 +08:00
|
|
|
L.MakeSigned();
|
|
|
|
R.MakeSigned();
|
2013-04-18 02:35:47 +08:00
|
|
|
result = L % R;
|
|
|
|
break;
|
|
|
|
case Instruction::URem:
|
|
|
|
result = L.GetRawBits64(0) % R.GetRawBits64(1);
|
|
|
|
break;
|
|
|
|
case Instruction::Shl:
|
|
|
|
result = L << R;
|
|
|
|
break;
|
|
|
|
case Instruction::AShr:
|
|
|
|
result = L >> R;
|
|
|
|
break;
|
|
|
|
case Instruction::LShr:
|
|
|
|
result = L;
|
|
|
|
result.ShiftRightLogical(R);
|
|
|
|
break;
|
|
|
|
case Instruction::And:
|
|
|
|
result = L & R;
|
|
|
|
break;
|
|
|
|
case Instruction::Or:
|
|
|
|
result = L | R;
|
|
|
|
break;
|
|
|
|
case Instruction::Xor:
|
|
|
|
result = L ^ R;
|
|
|
|
break;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.AssignValue(inst, result, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a %s", inst->getOpcodeName());
|
|
|
|
log->Printf(" L : %s", frame.SummarizeValue(lhs).c_str());
|
|
|
|
log->Printf(" R : %s", frame.SummarizeValue(rhs).c_str());
|
|
|
|
log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::Alloca:
|
|
|
|
{
|
|
|
|
const AllocaInst *alloca_inst = dyn_cast<AllocaInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!alloca_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns Alloca, but instruction is not an AllocaInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (alloca_inst->isArrayAllocation())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("AllocaInsts are not handled if isArrayAllocation() is true");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(unsupported_opcode_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
// The semantics of Alloca are:
|
|
|
|
// Create a region R of virtual memory of type T, backed by a data buffer
|
|
|
|
// Create a region P of virtual memory of type T*, backed by a data buffer
|
|
|
|
// Write the virtual address of R into P
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Type *T = alloca_inst->getAllocatedType();
|
|
|
|
Type *Tptr = alloca_inst->getType();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb::addr_t R = frame.Malloc(T);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (R == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't allocate memory for an AllocaInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_allocation_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb::addr_t P = frame.Malloc(Tptr);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (P == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't allocate the result pointer for an AllocaInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_allocation_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Error write_error;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
memory_map.WritePointerToMemory(P, R, write_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!write_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't write the result pointer for an AllocaInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_write_error);
|
|
|
|
lldb_private::Error free_error;
|
|
|
|
memory_map.Free(P, free_error);
|
|
|
|
memory_map.Free(R, free_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.m_values[alloca_inst] = P;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted an AllocaInst");
|
2013-06-04 02:00:07 +08:00
|
|
|
log->Printf(" R : 0x%" PRIx64, R);
|
|
|
|
log->Printf(" P : 0x%" PRIx64, P);
|
2013-04-18 02:35:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::BitCast:
|
|
|
|
case Instruction::ZExt:
|
|
|
|
{
|
|
|
|
const CastInst *cast_inst = dyn_cast<CastInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!cast_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns %s, but instruction is not a BitCastInst", cast_inst->getOpcodeName());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Value *source = cast_inst->getOperand(0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar S;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(S, source, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(source).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.AssignValue(inst, S, module);
|
|
|
|
}
|
|
|
|
break;
|
2013-06-06 06:07:06 +08:00
|
|
|
case Instruction::SExt:
|
|
|
|
{
|
|
|
|
const CastInst *cast_inst = dyn_cast<CastInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
if (!cast_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns %s, but instruction is not a BitCastInst", cast_inst->getOpcodeName());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
Value *source = cast_inst->getOperand(0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
lldb_private::Scalar S;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
if (!frame.EvaluateValue(S, source, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(source).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
S.MakeSigned();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
lldb_private::Scalar S_signextend(S.SLongLong());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-06-06 06:07:06 +08:00
|
|
|
frame.AssignValue(inst, S_signextend, module);
|
|
|
|
}
|
|
|
|
break;
|
2013-04-18 02:35:47 +08:00
|
|
|
case Instruction::Br:
|
|
|
|
{
|
|
|
|
const BranchInst *br_inst = dyn_cast<BranchInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!br_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns Br, but instruction is not a BranchInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (br_inst->isConditional())
|
|
|
|
{
|
|
|
|
Value *condition = br_inst->getCondition();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar C;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(C, condition, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(condition).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (C.GetRawBits64(0))
|
|
|
|
frame.Jump(br_inst->getSuccessor(0));
|
|
|
|
else
|
|
|
|
frame.Jump(br_inst->getSuccessor(1));
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a BrInst with a condition");
|
|
|
|
log->Printf(" cond : %s", frame.SummarizeValue(condition).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frame.Jump(br_inst->getSuccessor(0));
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a BrInst with no condition");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
case Instruction::GetElementPtr:
|
|
|
|
{
|
|
|
|
const GetElementPtrInst *gep_inst = dyn_cast<GetElementPtrInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!gep_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns GetElementPtr, but instruction is not a GetElementPtrInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
const Value *pointer_operand = gep_inst->getPointerOperand();
|
|
|
|
Type *pointer_type = pointer_operand->getType();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar P;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(P, pointer_operand, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(pointer_operand).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
typedef SmallVector <Value *, 8> IndexVector;
|
|
|
|
typedef IndexVector::iterator IndexIterator;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
SmallVector <Value *, 8> indices (gep_inst->idx_begin(),
|
|
|
|
gep_inst->idx_end());
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
SmallVector <Value *, 8> const_indices;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
for (IndexIterator ii = indices.begin(), ie = indices.end();
|
|
|
|
ii != ie;
|
|
|
|
++ii)
|
|
|
|
{
|
|
|
|
ConstantInt *constant_index = dyn_cast<ConstantInt>(*ii);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!constant_index)
|
|
|
|
{
|
|
|
|
lldb_private::Scalar I;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(I, *ii, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(*ii).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
log->Printf("Evaluated constant index %s as %llu", PrintValue(*ii).c_str(), I.ULongLong(LLDB_INVALID_ADDRESS));
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
constant_index = cast<ConstantInt>(ConstantInt::get((*ii)->getType(), I.ULongLong(LLDB_INVALID_ADDRESS)));
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
const_indices.push_back(constant_index);
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
uint64_t offset = data_layout.getIndexedOffset(pointer_type, const_indices);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar Poffset = P + offset;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.AssignValue(inst, Poffset, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a GetElementPtrInst");
|
|
|
|
log->Printf(" P : %s", frame.SummarizeValue(pointer_operand).c_str());
|
|
|
|
log->Printf(" Poffset : %s", frame.SummarizeValue(inst).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::ICmp:
|
|
|
|
{
|
|
|
|
const ICmpInst *icmp_inst = dyn_cast<ICmpInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!icmp_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns ICmp, but instruction is not an ICmpInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
CmpInst::Predicate predicate = icmp_inst->getPredicate();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Value *lhs = inst->getOperand(0);
|
|
|
|
Value *rhs = inst->getOperand(1);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar L;
|
|
|
|
lldb_private::Scalar R;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(L, lhs, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(lhs).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(R, rhs, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(rhs).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar result;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
switch (predicate)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
case CmpInst::ICMP_EQ:
|
|
|
|
result = (L == R);
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_NE:
|
|
|
|
result = (L != R);
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_UGT:
|
|
|
|
result = (L.GetRawBits64(0) > R.GetRawBits64(0));
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_UGE:
|
|
|
|
result = (L.GetRawBits64(0) >= R.GetRawBits64(0));
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_ULT:
|
|
|
|
result = (L.GetRawBits64(0) < R.GetRawBits64(0));
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_ULE:
|
|
|
|
result = (L.GetRawBits64(0) <= R.GetRawBits64(0));
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_SGT:
|
2013-05-25 04:36:56 +08:00
|
|
|
L.MakeSigned();
|
|
|
|
R.MakeSigned();
|
2013-04-18 02:35:47 +08:00
|
|
|
result = (L > R);
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_SGE:
|
2013-05-25 04:36:56 +08:00
|
|
|
L.MakeSigned();
|
|
|
|
R.MakeSigned();
|
2013-04-18 02:35:47 +08:00
|
|
|
result = (L >= R);
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_SLT:
|
2013-05-25 04:36:56 +08:00
|
|
|
L.MakeSigned();
|
|
|
|
R.MakeSigned();
|
2013-04-18 02:35:47 +08:00
|
|
|
result = (L < R);
|
|
|
|
break;
|
|
|
|
case CmpInst::ICMP_SLE:
|
2013-05-25 04:36:56 +08:00
|
|
|
L.MakeSigned();
|
|
|
|
R.MakeSigned();
|
2013-04-18 02:35:47 +08:00
|
|
|
result = (L <= R);
|
|
|
|
break;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.AssignValue(inst, result, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted an ICmpInst");
|
|
|
|
log->Printf(" L : %s", frame.SummarizeValue(lhs).c_str());
|
|
|
|
log->Printf(" R : %s", frame.SummarizeValue(rhs).c_str());
|
|
|
|
log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::IntToPtr:
|
|
|
|
{
|
|
|
|
const IntToPtrInst *int_to_ptr_inst = dyn_cast<IntToPtrInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!int_to_ptr_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns IntToPtr, but instruction is not an IntToPtrInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Value *src_operand = int_to_ptr_inst->getOperand(0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar I;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(I, src_operand, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.AssignValue(inst, I, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted an IntToPtr");
|
|
|
|
log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str());
|
|
|
|
log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::PtrToInt:
|
|
|
|
{
|
|
|
|
const PtrToIntInst *ptr_to_int_inst = dyn_cast<PtrToIntInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!ptr_to_int_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns PtrToInt, but instruction is not an PtrToIntInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Value *src_operand = ptr_to_int_inst->getOperand(0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Scalar I;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!frame.EvaluateValue(I, src_operand, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
frame.AssignValue(inst, I, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a PtrToInt");
|
|
|
|
log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str());
|
2013-10-12 03:45:00 +08:00
|
|
|
log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::Trunc:
|
|
|
|
{
|
|
|
|
const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-10-12 03:45:00 +08:00
|
|
|
if (!trunc_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns Trunc, but instruction is not a TruncInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-10-12 03:45:00 +08:00
|
|
|
Value *src_operand = trunc_inst->getOperand(0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-10-12 03:45:00 +08:00
|
|
|
lldb_private::Scalar I;
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-10-12 03:45:00 +08:00
|
|
|
if (!frame.EvaluateValue(I, src_operand, module))
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-10-12 03:45:00 +08:00
|
|
|
frame.AssignValue(inst, I, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-10-12 03:45:00 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a Trunc");
|
|
|
|
log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str());
|
2013-04-18 02:35:47 +08:00
|
|
|
log->Printf(" = : %s", frame.SummarizeValue(inst).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::Load:
|
|
|
|
{
|
|
|
|
const LoadInst *load_inst = dyn_cast<LoadInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!load_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns Load, but instruction is not a LoadInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
// The semantics of Load are:
|
|
|
|
// Create a region D that will contain the loaded data
|
|
|
|
// Resolve the region P containing a pointer
|
|
|
|
// Dereference P to get the region R that the data should be loaded from
|
|
|
|
// Transfer a unit of type type(D) from R to D
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
const Value *pointer_operand = load_inst->getPointerOperand();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Type *pointer_ty = pointer_operand->getType();
|
|
|
|
PointerType *pointer_ptr_ty = dyn_cast<PointerType>(pointer_ty);
|
|
|
|
if (!pointer_ptr_ty)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getPointerOperand()->getType() is not a PointerType");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Type *target_ty = pointer_ptr_ty->getElementType();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb::addr_t D = frame.ResolveValue(load_inst, module);
|
|
|
|
lldb::addr_t P = frame.ResolveValue(pointer_operand, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (D == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("LoadInst's value doesn't resolve to anything");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (P == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("LoadInst's pointer doesn't resolve to anything");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb::addr_t R;
|
|
|
|
lldb_private::Error read_error;
|
|
|
|
memory_map.ReadPointerFromMemory(&R, P, read_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!read_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't read the address to be loaded for a LoadInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_read_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
size_t target_size = data_layout.getTypeStoreSize(target_ty);
|
|
|
|
lldb_private::DataBufferHeap buffer(target_size, 0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
read_error.Clear();
|
|
|
|
memory_map.ReadMemory(buffer.GetBytes(), R, buffer.GetByteSize(), read_error);
|
|
|
|
if (!read_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't read from a region on behalf of a LoadInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_read_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Error write_error;
|
|
|
|
memory_map.WriteMemory(D, buffer.GetBytes(), buffer.GetByteSize(), write_error);
|
|
|
|
if (!write_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't write to a region on behalf of a LoadInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_read_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a LoadInst");
|
2013-06-04 02:00:07 +08:00
|
|
|
log->Printf(" P : 0x%" PRIx64, P);
|
|
|
|
log->Printf(" R : 0x%" PRIx64, R);
|
|
|
|
log->Printf(" D : 0x%" PRIx64, D);
|
2013-04-18 02:35:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Instruction::Ret:
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case Instruction::Store:
|
|
|
|
{
|
|
|
|
const StoreInst *store_inst = dyn_cast<StoreInst>(inst);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!store_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns Store, but instruction is not a StoreInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
// The semantics of Store are:
|
|
|
|
// Resolve the region D containing the data to be stored
|
|
|
|
// Resolve the region P containing a pointer
|
|
|
|
// Dereference P to get the region R that the data should be stored in
|
|
|
|
// Transfer a unit of type type(D) from D to R
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
const Value *value_operand = store_inst->getValueOperand();
|
|
|
|
const Value *pointer_operand = store_inst->getPointerOperand();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
Type *pointer_ty = pointer_operand->getType();
|
|
|
|
PointerType *pointer_ptr_ty = dyn_cast<PointerType>(pointer_ty);
|
|
|
|
if (!pointer_ptr_ty)
|
|
|
|
return false;
|
|
|
|
Type *target_ty = pointer_ptr_ty->getElementType();
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb::addr_t D = frame.ResolveValue(value_operand, module);
|
|
|
|
lldb::addr_t P = frame.ResolveValue(pointer_operand, module);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (D == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("StoreInst's value doesn't resolve to anything");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (P == LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("StoreInst's pointer doesn't resolve to anything");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(bad_value_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb::addr_t R;
|
|
|
|
lldb_private::Error read_error;
|
|
|
|
memory_map.ReadPointerFromMemory(&R, P, read_error);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (!read_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't read the address to be loaded for a LoadInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_read_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
size_t target_size = data_layout.getTypeStoreSize(target_ty);
|
|
|
|
lldb_private::DataBufferHeap buffer(target_size, 0);
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
read_error.Clear();
|
|
|
|
memory_map.ReadMemory(buffer.GetBytes(), D, buffer.GetByteSize(), read_error);
|
|
|
|
if (!read_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't read from a region on behalf of a StoreInst");
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(memory_read_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
lldb_private::Error write_error;
|
|
|
|
memory_map.WriteMemory(R, buffer.GetBytes(), buffer.GetByteSize(), write_error);
|
|
|
|
if (!write_error.Success())
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("Couldn't write to a region on behalf of a StoreInst");
|
|
|
|
error.SetErrorToGenericError();
|
2013-04-20 10:39:24 +08:00
|
|
|
error.SetErrorString(memory_write_error);
|
2013-04-18 02:35:47 +08:00
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
log->Printf("Interpreted a StoreInst");
|
2013-06-04 02:00:07 +08:00
|
|
|
log->Printf(" D : 0x%" PRIx64, D);
|
|
|
|
log->Printf(" P : 0x%" PRIx64, P);
|
|
|
|
log->Printf(" R : 0x%" PRIx64, R);
|
2013-04-18 02:35:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
Expression evaluation, a new ThreadPlanCallFunctionUsingABI for executing a function call on target via register manipulation
For Hexagon we want to be able to call functions during debugging, however currently lldb only supports this when there is JIT support.
Although emulation using IR interpretation is an alternative, it is currently limited in that it can't make function calls.
In this patch we have extended the IR interpreter so that it can execute a function call on the target using register manipulation.
To do this we need to handle the Call IR instruction, passing arguments to a new thread plan and collecting any return values to pass back into the IR interpreter.
The new thread plan is needed to call an alternative ABI interface of "ABI::PerpareTrivialCall()", allowing more detailed information about arguments and return values.
Reviewers: jingham, spyffe
Subscribers: emaste, lldb-commits, ted, ADodds, deepak2427
Differential Revision: http://reviews.llvm.org/D9404
llvm-svn: 242137
2015-07-14 18:56:58 +08:00
|
|
|
case Instruction::Call:
|
|
|
|
{
|
|
|
|
const CallInst *call_inst = dyn_cast<CallInst>(inst);
|
|
|
|
|
|
|
|
if (!call_inst)
|
|
|
|
{
|
|
|
|
if (log)
|
|
|
|
log->Printf("getOpcode() returns %s, but instruction is not a CallInst", inst->getOpcodeName());
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(interpreter_internal_error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CanIgnoreCall(call_inst))
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Get the return type
|
|
|
|
llvm::Type *returnType = call_inst->getType();
|
|
|
|
if (returnType == nullptr)
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString("unable to access return type");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Work with void, integer and pointer return types
|
|
|
|
if (!returnType->isVoidTy() &&
|
|
|
|
!returnType->isIntegerTy() &&
|
|
|
|
!returnType->isPointerTy())
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString("return type is not supported");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check we can actually get a thread
|
|
|
|
if (exe_ctx.GetThreadPtr() == nullptr)
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("unable to acquire thread");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we have a valid process
|
|
|
|
if (!exe_ctx.GetProcessPtr())
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("unable to get the process");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the address of the callee function
|
|
|
|
lldb_private::Scalar I;
|
|
|
|
const llvm::Value *val = call_inst->getCalledValue();
|
|
|
|
|
|
|
|
if (!frame.EvaluateValue(I, val, module))
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString("unable to get address of function");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
lldb_private::Address funcAddr(I.ULongLong(LLDB_INVALID_ADDRESS));
|
|
|
|
|
|
|
|
lldb_private::StreamString error_stream;
|
|
|
|
lldb_private::EvaluateExpressionOptions options;
|
|
|
|
|
|
|
|
// We generally receive a function pointer which we must dereference
|
|
|
|
llvm::Type* prototype = val->getType();
|
|
|
|
if (!prototype->isPointerTy())
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString("call need function pointer");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dereference the function pointer
|
|
|
|
prototype = prototype->getPointerElementType();
|
|
|
|
if (!(prototype->isFunctionTy() || prototype->isFunctionVarArg()))
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString("call need function pointer");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find number of arguments
|
|
|
|
const int numArgs = call_inst->getNumArgOperands();
|
|
|
|
|
|
|
|
// We work with a fixed array of 16 arguments which is our upper limit
|
|
|
|
static lldb_private::ABI::CallArgument rawArgs[16];
|
|
|
|
if (numArgs >= 16)
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("function takes too many arguments");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push all function arguments to the argument list that will
|
|
|
|
// be passed to the call function thread plan
|
|
|
|
for (int i = 0; i < numArgs; i++)
|
|
|
|
{
|
|
|
|
// Get details of this argument
|
|
|
|
llvm::Value *arg_op = call_inst->getArgOperand(i);
|
|
|
|
llvm::Type *arg_ty = arg_op->getType();
|
|
|
|
|
|
|
|
// Ensure that this argument is an supported type
|
|
|
|
if (!arg_ty->isIntegerTy() && !arg_ty->isPointerTy())
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("argument %d must be integer type", i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extract the arguments value
|
|
|
|
lldb_private::Scalar tmp_op = 0;
|
|
|
|
if (!frame.EvaluateValue(tmp_op, arg_op, module))
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("unable to evaluate argument %d", i);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if this is a string literal or constant string pointer
|
|
|
|
if (arg_ty->isPointerTy())
|
|
|
|
{
|
|
|
|
// Pointer to just one type
|
|
|
|
assert(arg_ty->getNumContainedTypes() == 1);
|
|
|
|
|
|
|
|
lldb::addr_t addr = tmp_op.ULongLong();
|
|
|
|
size_t dataSize = 0;
|
|
|
|
|
|
|
|
if (memory_map.GetAllocSize(addr, dataSize))
|
|
|
|
{
|
|
|
|
// Create the required buffer
|
|
|
|
rawArgs[i].size = dataSize;
|
|
|
|
rawArgs[i].data_ap.reset(new uint8_t[dataSize + 1]);
|
|
|
|
|
|
|
|
// Read string from host memory
|
|
|
|
memory_map.ReadMemory(rawArgs[i].data_ap.get(), addr, dataSize, error);
|
|
|
|
if (error.Fail())
|
|
|
|
{
|
|
|
|
assert(!"we have failed to read the string from memory");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Add null terminator
|
|
|
|
rawArgs[i].data_ap[dataSize] = '\0';
|
|
|
|
rawArgs[i].type = lldb_private::ABI::CallArgument::HostPointer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert(!"unable to locate host data for transfer to device");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* if ( arg_ty->isPointerTy() ) */
|
|
|
|
{
|
|
|
|
rawArgs[i].type = lldb_private::ABI::CallArgument::TargetValue;
|
|
|
|
// Get argument size in bytes
|
|
|
|
rawArgs[i].size = arg_ty->getIntegerBitWidth() / 8;
|
|
|
|
// Push value into argument list for thread plan
|
|
|
|
rawArgs[i].value = tmp_op.ULongLong();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pack the arguments into an llvm::array
|
|
|
|
llvm::ArrayRef<lldb_private::ABI::CallArgument> args(rawArgs, numArgs);
|
|
|
|
|
|
|
|
// Setup a thread plan to call the target function
|
|
|
|
lldb::ThreadPlanSP call_plan_sp
|
|
|
|
(
|
|
|
|
new lldb_private::ThreadPlanCallFunctionUsingABI
|
|
|
|
(
|
|
|
|
exe_ctx.GetThreadRef(),
|
|
|
|
funcAddr,
|
|
|
|
*prototype,
|
|
|
|
*returnType,
|
|
|
|
args,
|
|
|
|
options
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Check if the plan is valid
|
|
|
|
if (!call_plan_sp || !call_plan_sp->ValidatePlan(&error_stream))
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("unable to make ThreadPlanCallFunctionUsingABI for 0x%llx", I.ULongLong());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
|
|
|
|
|
|
|
|
// Execute the actual function call thread plan
|
|
|
|
lldb::ExpressionResults res = exe_ctx.GetProcessRef().RunThreadPlan(exe_ctx, call_plan_sp, options, error_stream);
|
|
|
|
|
|
|
|
// Check that the thread plan completed successfully
|
|
|
|
if (res != lldb::ExpressionResults::eExpressionCompleted)
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("ThreadPlanCallFunctionUsingABI failed");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
|
|
|
|
|
|
|
|
// Void return type
|
|
|
|
if (returnType->isVoidTy())
|
|
|
|
{
|
|
|
|
// Cant assign to void types, so we leave the frame untouched
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// Integer or pointer return type
|
|
|
|
if (returnType->isIntegerTy() || returnType->isPointerTy())
|
|
|
|
{
|
|
|
|
// Get the encapsulated return value
|
|
|
|
lldb::ValueObjectSP retVal = call_plan_sp.get()->GetReturnValueObject();
|
|
|
|
|
|
|
|
lldb_private::Scalar returnVal = -1;
|
|
|
|
lldb_private::ValueObject *vobj = retVal.get();
|
|
|
|
|
|
|
|
// Check if the return value is valid
|
|
|
|
if (vobj == nullptr || retVal.empty())
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorStringWithFormat("unable to get the return value");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Extract the return value as a integer
|
|
|
|
lldb_private::Value & value = vobj->GetValue();
|
|
|
|
returnVal = value.GetScalar();
|
|
|
|
|
|
|
|
// Push the return value as the result
|
|
|
|
frame.AssignValue(inst, returnVal, module);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-04-18 02:35:47 +08:00
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
++frame.m_ii;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
if (num_insts >= 4096)
|
|
|
|
{
|
|
|
|
error.SetErrorToGenericError();
|
|
|
|
error.SetErrorString(infinite_loop_error);
|
|
|
|
return false;
|
|
|
|
}
|
2014-07-07 01:54:58 +08:00
|
|
|
|
2013-04-18 02:35:47 +08:00
|
|
|
return false;
|
|
|
|
}
|