[Lldb-commits] [lldb] r183344 - Fixes for the IR interpreter:
Sean Callanan
scallanan at apple.com
Wed Jun 5 15:07:07 PDT 2013
Author: spyffe
Date: Wed Jun 5 17:07:06 2013
New Revision: 183344
URL: http://llvm.org/viewvc/llvm-project?rev=183344&view=rev
Log:
Fixes for the IR interpreter:
- Implemented the SExt instruction, and
- eliminated redundant codepaths for constant
handling.
Added test cases.
<rdar://problem/13244258>
<rdar://problem/13955820>
Modified:
lldb/trunk/source/Expression/IRInterpreter.cpp
lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py
lldb/trunk/test/lang/c/struct_types/TestStructTypes.py
Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=183344&r1=183343&r2=183344&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Wed Jun 5 17:07:06 2013
@@ -151,14 +151,12 @@ public:
if (constant)
{
- if (isa<ConstantPointerNull>(constant))
- {
- return AssignToMatchType(scalar, 0, value->getType());
- }
- else if (const ConstantInt *constant_int = dyn_cast<ConstantInt>(constant))
- {
- return AssignToMatchType(scalar, constant_int->getLimitedValue(), value->getType());
- }
+ APInt value_apint;
+
+ if (!ResolveConstantValue(value_apint, constant))
+ return false;
+
+ return AssignToMatchType(scalar, value_apint.getLimitedValue(), value->getType());
}
else
{
@@ -500,6 +498,7 @@ IRInterpreter::CanInterpret (llvm::Modul
case Instruction::Or:
case Instruction::Ret:
case Instruction::SDiv:
+ case Instruction::SExt:
case Instruction::Shl:
case Instruction::SRem:
case Instruction::Store:
@@ -821,6 +820,39 @@ IRInterpreter::Interpret (llvm::Module &
frame.AssignValue(inst, S, module);
}
break;
+ case Instruction::SExt:
+ {
+ const CastInst *cast_inst = dyn_cast<CastInst>(inst);
+
+ 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;
+ }
+
+ Value *source = cast_inst->getOperand(0);
+
+ lldb_private::Scalar S;
+
+ 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;
+ }
+
+ S.MakeSigned();
+
+ lldb_private::Scalar S_signextend(S.SLongLong());
+
+ frame.AssignValue(inst, S_signextend, module);
+ }
+ break;
case Instruction::Br:
{
const BranchInst *br_inst = dyn_cast<BranchInst>(inst);
Modified: lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py?rev=183344&r1=183343&r2=183344&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py (original)
+++ lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py Wed Jun 5 17:07:06 2013
@@ -47,6 +47,9 @@ class PersistentVariablesTestCase(TestBa
self.expect("expression $4 > (int)31",
startstr = "(bool) $5 = false")
+ self.expect("expression (long)$4",
+ startstr = "(long) $6 = -2")
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
Modified: lldb/trunk/test/lang/c/struct_types/TestStructTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/struct_types/TestStructTypes.py?rev=183344&r1=183343&r2=183344&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/struct_types/TestStructTypes.py (original)
+++ lldb/trunk/test/lang/c/struct_types/TestStructTypes.py Wed Jun 5 17:07:06 2013
@@ -89,7 +89,8 @@ class StructTypesTestCase(TestBase):
DATA_TYPES_DISPLAYED_CORRECTLY,
substrs = ['padding[]']) # Once rdar://problem/12566646 is fixed, this should display correctly
-
+ self.expect("expression -- &pt == (struct point_tag*)0",
+ substrs = ['false'])
if __name__ == '__main__':
import atexit
More information about the lldb-commits
mailing list