diff options
Diffstat (limited to 'source/Expression/IRInterpreter.cpp')
-rw-r--r-- | source/Expression/IRInterpreter.cpp | 309 |
1 files changed, 133 insertions, 176 deletions
diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp index 5a9814d15362d..856c9a0244fb3 100644 --- a/source/Expression/IRInterpreter.cpp +++ b/source/Expression/IRInterpreter.cpp @@ -327,10 +327,11 @@ public: 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); + LLDB_LOGF(log, "Made an allocation for argument %s", + PrintValue(value).c_str()); + LLDB_LOGF(log, " Data region : %llx", (unsigned long long)address); + LLDB_LOGF(log, " Ref region : %llx", + (unsigned long long)data_address); } return true; @@ -494,8 +495,7 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, ++fi) { if (fi->begin() != fi->end()) { if (saw_function_with_body) { - if (log) - log->Printf("More than one function in the module has a body"); + LLDB_LOGF(log, "More than one function in the module has a body"); error.SetErrorToGenericError(); error.SetErrorString(too_many_functions_error); return false; @@ -510,8 +510,7 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, ++ii) { switch (ii->getOpcode()) { default: { - if (log) - log->Printf("Unsupported instruction: %s", PrintValue(&*ii).c_str()); + LLDB_LOGF(log, "Unsupported instruction: %s", PrintValue(&*ii).c_str()); error.SetErrorToGenericError(); error.SetErrorString(unsupported_opcode_error); return false; @@ -532,9 +531,8 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, } if (!CanIgnoreCall(call_inst) && !support_function_calls) { - if (log) - log->Printf("Unsupported instruction: %s", - PrintValue(&*ii).c_str()); + LLDB_LOGF(log, "Unsupported instruction: %s", + PrintValue(&*ii).c_str()); error.SetErrorToGenericError(); error.SetErrorString(unsupported_opcode_error); return false; @@ -553,9 +551,8 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, switch (icmp_inst->getPredicate()) { default: { - if (log) - log->Printf("Unsupported ICmp predicate: %s", - PrintValue(&*ii).c_str()); + LLDB_LOGF(log, "Unsupported ICmp predicate: %s", + PrintValue(&*ii).c_str()); error.SetErrorToGenericError(); error.SetErrorString(unsupported_opcode_error); @@ -605,9 +602,8 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, default: break; case Type::VectorTyID: { - if (log) - log->Printf("Unsupported operand type: %s", - PrintType(operand_type).c_str()); + LLDB_LOGF(log, "Unsupported operand type: %s", + PrintType(operand_type).c_str()); error.SetErrorString(unsupported_operand_error); return false; } @@ -618,18 +614,16 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function, // we can just fall back to the JIT rather than // choking. if (operand_type->getPrimitiveSizeInBits() > 64) { - if (log) - log->Printf("Unsupported operand type: %s", - PrintType(operand_type).c_str()); + LLDB_LOGF(log, "Unsupported operand type: %s", + PrintType(operand_type).c_str()); error.SetErrorString(unsupported_operand_error); return false; } if (Constant *constant = llvm::dyn_cast<Constant>(operand)) { if (!CanResolveConstant(constant)) { - if (log) - log->Printf("Unsupported constant: %s", - PrintValue(constant).c_str()); + LLDB_LOGF(log, "Unsupported constant: %s", + PrintValue(constant).c_str()); error.SetErrorString(unsupported_operand_error); return false; } @@ -659,8 +653,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, oss.flush(); - log->Printf("Module as passed in to IRInterpreter::Interpret: \n\"%s\"", - s.c_str()); + LLDB_LOGF(log, "Module as passed in to IRInterpreter::Interpret: \n\"%s\"", + s.c_str()); } DataLayout data_layout(&module); @@ -694,8 +688,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, while (frame.m_ii != frame.m_ie && (++num_insts < 4096)) { const Instruction *inst = &*frame.m_ii; - if (log) - log->Printf("Interpreting %s", PrintValue(inst).c_str()); + LLDB_LOGF(log, "Interpreting %s", PrintValue(inst).c_str()); switch (inst->getOpcode()) { default: @@ -717,10 +710,10 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, const BinaryOperator *bin_op = dyn_cast<BinaryOperator>(inst); if (!bin_op) { - if (log) - log->Printf( - "getOpcode() returns %s, but instruction is not a BinaryOperator", - inst->getOpcodeName()); + LLDB_LOGF( + log, + "getOpcode() returns %s, but instruction is not a BinaryOperator", + inst->getOpcodeName()); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -733,16 +726,14 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar R; if (!frame.EvaluateValue(L, lhs, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(lhs).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(lhs).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; } if (!frame.EvaluateValue(R, rhs, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(rhs).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(rhs).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -806,28 +797,26 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, result, module); 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()); + LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); + LLDB_LOGF(log, " L : %s", frame.SummarizeValue(lhs).c_str()); + LLDB_LOGF(log, " R : %s", frame.SummarizeValue(rhs).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } } break; case Instruction::Alloca: { const AllocaInst *alloca_inst = dyn_cast<AllocaInst>(inst); if (!alloca_inst) { - if (log) - log->Printf("getOpcode() returns Alloca, but instruction is not an " - "AllocaInst"); + LLDB_LOGF(log, "getOpcode() returns Alloca, but instruction is not an " + "AllocaInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; } if (alloca_inst->isArrayAllocation()) { - if (log) - log->Printf( - "AllocaInsts are not handled if isArrayAllocation() is true"); + LLDB_LOGF(log, + "AllocaInsts are not handled if isArrayAllocation() is true"); error.SetErrorToGenericError(); error.SetErrorString(unsupported_opcode_error); return false; @@ -846,8 +835,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb::addr_t R = frame.Malloc(T); if (R == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("Couldn't allocate memory for an AllocaInst"); + LLDB_LOGF(log, "Couldn't allocate memory for an AllocaInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_allocation_error); return false; @@ -856,8 +844,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb::addr_t P = frame.Malloc(Tptr); if (P == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("Couldn't allocate the result pointer for an AllocaInst"); + LLDB_LOGF(log, + "Couldn't allocate the result pointer for an AllocaInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_allocation_error); return false; @@ -868,8 +856,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.WritePointerToMemory(P, R, write_error); if (!write_error.Success()) { - if (log) - log->Printf("Couldn't write the result pointer for an AllocaInst"); + LLDB_LOGF(log, "Couldn't write the result pointer for an AllocaInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_write_error); lldb_private::Status free_error; @@ -881,9 +868,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.m_values[alloca_inst] = P; if (log) { - log->Printf("Interpreted an AllocaInst"); - log->Printf(" R : 0x%" PRIx64, R); - log->Printf(" P : 0x%" PRIx64, P); + LLDB_LOGF(log, "Interpreted an AllocaInst"); + LLDB_LOGF(log, " R : 0x%" PRIx64, R); + LLDB_LOGF(log, " P : 0x%" PRIx64, P); } } break; case Instruction::BitCast: @@ -891,10 +878,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, 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()); + LLDB_LOGF( + log, "getOpcode() returns %s, but instruction is not a BitCastInst", + cast_inst->getOpcodeName()); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -905,8 +891,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar S; if (!frame.EvaluateValue(S, source, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(source).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(source).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -918,10 +903,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, 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()); + LLDB_LOGF( + log, "getOpcode() returns %s, but instruction is not a BitCastInst", + cast_inst->getOpcodeName()); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -932,8 +916,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar S; if (!frame.EvaluateValue(S, source, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(source).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(source).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -949,9 +932,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, const BranchInst *br_inst = dyn_cast<BranchInst>(inst); if (!br_inst) { - if (log) - log->Printf( - "getOpcode() returns Br, but instruction is not a BranchInst"); + LLDB_LOGF( + log, "getOpcode() returns Br, but instruction is not a BranchInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -963,8 +945,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar C; if (!frame.EvaluateValue(C, condition, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(condition).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(condition).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -976,14 +957,15 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.Jump(br_inst->getSuccessor(1)); if (log) { - log->Printf("Interpreted a BrInst with a condition"); - log->Printf(" cond : %s", frame.SummarizeValue(condition).c_str()); + LLDB_LOGF(log, "Interpreted a BrInst with a condition"); + LLDB_LOGF(log, " cond : %s", + frame.SummarizeValue(condition).c_str()); } } else { frame.Jump(br_inst->getSuccessor(0)); if (log) { - log->Printf("Interpreted a BrInst with no condition"); + LLDB_LOGF(log, "Interpreted a BrInst with no condition"); } } } @@ -992,17 +974,16 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, const PHINode *phi_inst = dyn_cast<PHINode>(inst); if (!phi_inst) { - if (log) - log->Printf( - "getOpcode() returns PHI, but instruction is not a PHINode"); + LLDB_LOGF(log, + "getOpcode() returns PHI, but instruction is not a PHINode"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; } if (!frame.m_prev_bb) { - if (log) - log->Printf("Encountered PHI node without having jumped from another " - "basic block"); + LLDB_LOGF(log, + "Encountered PHI node without having jumped from another " + "basic block"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1011,8 +992,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, Value *value = phi_inst->getIncomingValueForBlock(frame.m_prev_bb); lldb_private::Scalar result; if (!frame.EvaluateValue(result, value, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(value).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(value).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1020,18 +1000,17 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, result, module); if (log) { - log->Printf("Interpreted a %s", inst->getOpcodeName()); - log->Printf(" Incoming value : %s", - frame.SummarizeValue(value).c_str()); + LLDB_LOGF(log, "Interpreted a %s", inst->getOpcodeName()); + LLDB_LOGF(log, " Incoming value : %s", + frame.SummarizeValue(value).c_str()); } } break; case Instruction::GetElementPtr: { const GetElementPtrInst *gep_inst = dyn_cast<GetElementPtrInst>(inst); if (!gep_inst) { - if (log) - log->Printf("getOpcode() returns GetElementPtr, but instruction is " - "not a GetElementPtrInst"); + LLDB_LOGF(log, "getOpcode() returns GetElementPtr, but instruction is " + "not a GetElementPtrInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1043,9 +1022,8 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar P; if (!frame.EvaluateValue(P, pointer_operand, module)) { - if (log) - log->Printf("Couldn't evaluate %s", - PrintValue(pointer_operand).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", + PrintValue(pointer_operand).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1067,17 +1045,14 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar I; if (!frame.EvaluateValue(I, *ii, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(*ii).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(*ii).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; } - if (log) - log->Printf("Evaluated constant index %s as %llu", - PrintValue(*ii).c_str(), - I.ULongLong(LLDB_INVALID_ADDRESS)); + LLDB_LOGF(log, "Evaluated constant index %s as %llu", + PrintValue(*ii).c_str(), I.ULongLong(LLDB_INVALID_ADDRESS)); constant_index = cast<ConstantInt>(ConstantInt::get( (*ii)->getType(), I.ULongLong(LLDB_INVALID_ADDRESS))); @@ -1094,19 +1069,19 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, Poffset, module); 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()); + LLDB_LOGF(log, "Interpreted a GetElementPtrInst"); + LLDB_LOGF(log, " P : %s", + frame.SummarizeValue(pointer_operand).c_str()); + LLDB_LOGF(log, " Poffset : %s", frame.SummarizeValue(inst).c_str()); } } break; case Instruction::ICmp: { const ICmpInst *icmp_inst = dyn_cast<ICmpInst>(inst); if (!icmp_inst) { - if (log) - log->Printf( - "getOpcode() returns ICmp, but instruction is not an ICmpInst"); + LLDB_LOGF( + log, + "getOpcode() returns ICmp, but instruction is not an ICmpInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1121,16 +1096,14 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar R; if (!frame.EvaluateValue(L, lhs, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(lhs).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(lhs).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; } if (!frame.EvaluateValue(R, rhs, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(rhs).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(rhs).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1192,19 +1165,19 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, result, module); 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()); + LLDB_LOGF(log, "Interpreted an ICmpInst"); + LLDB_LOGF(log, " L : %s", frame.SummarizeValue(lhs).c_str()); + LLDB_LOGF(log, " R : %s", frame.SummarizeValue(rhs).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } } break; case Instruction::IntToPtr: { const IntToPtrInst *int_to_ptr_inst = dyn_cast<IntToPtrInst>(inst); if (!int_to_ptr_inst) { - if (log) - log->Printf("getOpcode() returns IntToPtr, but instruction is not an " - "IntToPtrInst"); + LLDB_LOGF(log, + "getOpcode() returns IntToPtr, but instruction is not an " + "IntToPtrInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1215,8 +1188,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar I; if (!frame.EvaluateValue(I, src_operand, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(src_operand).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1225,18 +1197,18 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, I, module); 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()); + LLDB_LOGF(log, "Interpreted an IntToPtr"); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } } break; case Instruction::PtrToInt: { const PtrToIntInst *ptr_to_int_inst = dyn_cast<PtrToIntInst>(inst); if (!ptr_to_int_inst) { - if (log) - log->Printf("getOpcode() returns PtrToInt, but instruction is not an " - "PtrToIntInst"); + LLDB_LOGF(log, + "getOpcode() returns PtrToInt, but instruction is not an " + "PtrToIntInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1247,8 +1219,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar I; if (!frame.EvaluateValue(I, src_operand, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(src_operand).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1257,18 +1228,18 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, I, module); if (log) { - log->Printf("Interpreted a PtrToInt"); - log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str()); - log->Printf(" = : %s", frame.SummarizeValue(inst).c_str()); + LLDB_LOGF(log, "Interpreted a PtrToInt"); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } } break; case Instruction::Trunc: { const TruncInst *trunc_inst = dyn_cast<TruncInst>(inst); if (!trunc_inst) { - if (log) - log->Printf( - "getOpcode() returns Trunc, but instruction is not a TruncInst"); + LLDB_LOGF( + log, + "getOpcode() returns Trunc, but instruction is not a TruncInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1279,8 +1250,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb_private::Scalar I; if (!frame.EvaluateValue(I, src_operand, module)) { - if (log) - log->Printf("Couldn't evaluate %s", PrintValue(src_operand).c_str()); + LLDB_LOGF(log, "Couldn't evaluate %s", PrintValue(src_operand).c_str()); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1289,18 +1259,17 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, frame.AssignValue(inst, I, module); if (log) { - log->Printf("Interpreted a Trunc"); - log->Printf(" Src : %s", frame.SummarizeValue(src_operand).c_str()); - log->Printf(" = : %s", frame.SummarizeValue(inst).c_str()); + LLDB_LOGF(log, "Interpreted a Trunc"); + LLDB_LOGF(log, " Src : %s", frame.SummarizeValue(src_operand).c_str()); + LLDB_LOGF(log, " = : %s", frame.SummarizeValue(inst).c_str()); } } break; case Instruction::Load: { const LoadInst *load_inst = dyn_cast<LoadInst>(inst); if (!load_inst) { - if (log) - log->Printf( - "getOpcode() returns Load, but instruction is not a LoadInst"); + LLDB_LOGF( + log, "getOpcode() returns Load, but instruction is not a LoadInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1317,8 +1286,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, 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"); + LLDB_LOGF(log, "getPointerOperand()->getType() is not a PointerType"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1329,16 +1297,14 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb::addr_t P = frame.ResolveValue(pointer_operand, module); if (D == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("LoadInst's value doesn't resolve to anything"); + LLDB_LOGF(log, "LoadInst's value doesn't resolve to anything"); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; } if (P == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("LoadInst's pointer doesn't resolve to anything"); + LLDB_LOGF(log, "LoadInst's pointer doesn't resolve to anything"); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1349,8 +1315,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.ReadPointerFromMemory(&R, P, read_error); if (!read_error.Success()) { - if (log) - log->Printf("Couldn't read the address to be loaded for a LoadInst"); + LLDB_LOGF(log, "Couldn't read the address to be loaded for a LoadInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_read_error); return false; @@ -1363,8 +1328,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.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"); + LLDB_LOGF(log, "Couldn't read from a region on behalf of a LoadInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_read_error); return false; @@ -1374,18 +1338,17 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.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"); + LLDB_LOGF(log, "Couldn't write to a region on behalf of a LoadInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_read_error); return false; } if (log) { - log->Printf("Interpreted a LoadInst"); - log->Printf(" P : 0x%" PRIx64, P); - log->Printf(" R : 0x%" PRIx64, R); - log->Printf(" D : 0x%" PRIx64, D); + LLDB_LOGF(log, "Interpreted a LoadInst"); + LLDB_LOGF(log, " P : 0x%" PRIx64, P); + LLDB_LOGF(log, " R : 0x%" PRIx64, R); + LLDB_LOGF(log, " D : 0x%" PRIx64, D); } } break; case Instruction::Ret: { @@ -1395,9 +1358,9 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, const StoreInst *store_inst = dyn_cast<StoreInst>(inst); if (!store_inst) { - if (log) - log->Printf( - "getOpcode() returns Store, but instruction is not a StoreInst"); + LLDB_LOGF( + log, + "getOpcode() returns Store, but instruction is not a StoreInst"); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; @@ -1422,16 +1385,14 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, lldb::addr_t P = frame.ResolveValue(pointer_operand, module); if (D == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("StoreInst's value doesn't resolve to anything"); + LLDB_LOGF(log, "StoreInst's value doesn't resolve to anything"); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; } if (P == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("StoreInst's pointer doesn't resolve to anything"); + LLDB_LOGF(log, "StoreInst's pointer doesn't resolve to anything"); error.SetErrorToGenericError(); error.SetErrorString(bad_value_error); return false; @@ -1442,8 +1403,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.ReadPointerFromMemory(&R, P, read_error); if (!read_error.Success()) { - if (log) - log->Printf("Couldn't read the address to be loaded for a LoadInst"); + LLDB_LOGF(log, "Couldn't read the address to be loaded for a LoadInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_read_error); return false; @@ -1456,8 +1416,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.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"); + LLDB_LOGF(log, "Couldn't read from a region on behalf of a StoreInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_read_error); return false; @@ -1467,28 +1426,26 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function, execution_unit.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"); + LLDB_LOGF(log, "Couldn't write to a region on behalf of a StoreInst"); error.SetErrorToGenericError(); error.SetErrorString(memory_write_error); return false; } if (log) { - log->Printf("Interpreted a StoreInst"); - log->Printf(" D : 0x%" PRIx64, D); - log->Printf(" P : 0x%" PRIx64, P); - log->Printf(" R : 0x%" PRIx64, R); + LLDB_LOGF(log, "Interpreted a StoreInst"); + LLDB_LOGF(log, " D : 0x%" PRIx64, D); + LLDB_LOGF(log, " P : 0x%" PRIx64, P); + LLDB_LOGF(log, " R : 0x%" PRIx64, R); } } break; 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()); + LLDB_LOGF(log, + "getOpcode() returns %s, but instruction is not a CallInst", + inst->getOpcodeName()); error.SetErrorToGenericError(); error.SetErrorString(interpreter_internal_error); return false; |