summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Expression')
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp20
-rw-r--r--lldb/source/Expression/ExpressionVariable.cpp18
-rw-r--r--lldb/source/Expression/FunctionCaller.cpp42
-rw-r--r--lldb/source/Expression/IRExecutionUnit.cpp83
-rw-r--r--lldb/source/Expression/IRInterpreter.cpp309
-rw-r--r--lldb/source/Expression/IRMemoryMap.cpp64
-rw-r--r--lldb/source/Expression/LLVMUserExpression.cpp16
-rw-r--r--lldb/source/Expression/Materializer.cpp89
-rw-r--r--lldb/source/Expression/UserExpression.cpp41
9 files changed, 320 insertions, 362 deletions
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index a9d365325d9..978ff7032de 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1206,15 +1206,16 @@ bool DWARFExpression::Evaluate(
if (log && log->GetVerbose()) {
size_t count = stack.size();
- log->Printf("Stack before operation has %" PRIu64 " values:",
- (uint64_t)count);
+ LLDB_LOGF(log, "Stack before operation has %" PRIu64 " values:",
+ (uint64_t)count);
for (size_t i = 0; i < count; ++i) {
StreamString new_value;
new_value.Printf("[%" PRIu64 "]", (uint64_t)i);
stack[i].Dump(&new_value);
- log->Printf(" %s", new_value.GetData());
+ LLDB_LOGF(log, " %s", new_value.GetData());
}
- log->Printf("0x%8.8" PRIx64 ": %s", op_offset, DW_OP_value_to_name(op));
+ LLDB_LOGF(log, "0x%8.8" PRIx64 ": %s", op_offset,
+ DW_OP_value_to_name(op));
}
switch (op) {
@@ -2686,9 +2687,8 @@ bool DWARFExpression::Evaluate(
} break;
default:
- if (log)
- log->Printf("Unhandled opcode %s in DWARFExpression.",
- DW_OP_value_to_name(op));
+ LLDB_LOGF(log, "Unhandled opcode %s in DWARFExpression.",
+ DW_OP_value_to_name(op));
break;
}
}
@@ -2706,13 +2706,13 @@ bool DWARFExpression::Evaluate(
} else {
if (log && log->GetVerbose()) {
size_t count = stack.size();
- log->Printf("Stack after operation has %" PRIu64 " values:",
- (uint64_t)count);
+ LLDB_LOGF(log, "Stack after operation has %" PRIu64 " values:",
+ (uint64_t)count);
for (size_t i = 0; i < count; ++i) {
StreamString new_value;
new_value.Printf("[%" PRIu64 "]", (uint64_t)i);
stack[i].Dump(&new_value);
- log->Printf(" %s", new_value.GetData());
+ LLDB_LOGF(log, " %s", new_value.GetData());
}
}
result = stack.back();
diff --git a/lldb/source/Expression/ExpressionVariable.cpp b/lldb/source/Expression/ExpressionVariable.cpp
index 97305dcf5a0..ed8da0ad867 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -45,8 +45,7 @@ void PersistentExpressionState::RegisterExecutionUnit(
m_execution_units.insert(execution_unit_sp);
- if (log)
- log->Printf("Registering JITted Functions:\n");
+ LLDB_LOGF(log, "Registering JITted Functions:\n");
for (const IRExecutionUnit::JittedFunction &jitted_function :
execution_unit_sp->GetJittedFunctions()) {
@@ -55,15 +54,13 @@ void PersistentExpressionState::RegisterExecutionUnit(
jitted_function.m_remote_addr != LLDB_INVALID_ADDRESS) {
m_symbol_map[jitted_function.m_name.GetCString()] =
jitted_function.m_remote_addr;
- if (log)
- log->Printf(" Function: %s at 0x%" PRIx64 ".",
- jitted_function.m_name.GetCString(),
- jitted_function.m_remote_addr);
+ LLDB_LOGF(log, " Function: %s at 0x%" PRIx64 ".",
+ jitted_function.m_name.GetCString(),
+ jitted_function.m_remote_addr);
}
}
- if (log)
- log->Printf("Registering JIIted Symbols:\n");
+ LLDB_LOGF(log, "Registering JIIted Symbols:\n");
for (const IRExecutionUnit::JittedGlobalVariable &global_var :
execution_unit_sp->GetJittedGlobalVariables()) {
@@ -74,9 +71,8 @@ void PersistentExpressionState::RegisterExecutionUnit(
Mangled mangler(global_var.m_name);
mangler.GetDemangledName(lldb::eLanguageTypeUnknown);
m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
- if (log)
- log->Printf(" Symbol: %s at 0x%" PRIx64 ".",
- global_var.m_name.GetCString(), global_var.m_remote_addr);
+ LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",
+ global_var.m_name.GetCString(), global_var.m_remote_addr);
}
}
}
diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp
index 618c1a13212..203cfff63d8 100644
--- a/lldb/source/Expression/FunctionCaller.cpp
+++ b/lldb/source/Expression/FunctionCaller.cpp
@@ -217,9 +217,8 @@ bool FunctionCaller::InsertFunction(ExecutionContext &exe_ctx,
return false;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("Call Address: 0x%" PRIx64 " Struct Address: 0x%" PRIx64 ".\n",
- m_jit_start_addr, args_addr_ref);
+ LLDB_LOGF(log, "Call Address: 0x%" PRIx64 " Struct Address: 0x%" PRIx64 ".\n",
+ m_jit_start_addr, args_addr_ref);
return true;
}
@@ -231,10 +230,10 @@ lldb::ThreadPlanSP FunctionCaller::GetThreadPlanToCallFunction(
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("-- [FunctionCaller::GetThreadPlanToCallFunction] Creating "
- "thread plan to call function \"%s\" --",
- m_name.c_str());
+ LLDB_LOGF(log,
+ "-- [FunctionCaller::GetThreadPlanToCallFunction] Creating "
+ "thread plan to call function \"%s\" --",
+ m_name.c_str());
// FIXME: Use the errors Stream for better error reporting.
Thread *thread = exe_ctx.GetThreadPtr();
@@ -271,10 +270,10 @@ bool FunctionCaller::FetchFunctionResults(ExecutionContext &exe_ctx,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
LIBLLDB_LOG_STEP));
- if (log)
- log->Printf("-- [FunctionCaller::FetchFunctionResults] Fetching function "
- "results for \"%s\"--",
- m_name.c_str());
+ LLDB_LOGF(log,
+ "-- [FunctionCaller::FetchFunctionResults] Fetching function "
+ "results for \"%s\"--",
+ m_name.c_str());
Process *process = exe_ctx.GetProcessPtr();
@@ -341,10 +340,9 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
LIBLLDB_LOG_STEP));
- if (log)
- log->Printf(
- "== [FunctionCaller::ExecuteFunction] Executing function \"%s\" ==",
- m_name.c_str());
+ LLDB_LOGF(log,
+ "== [FunctionCaller::ExecuteFunction] Executing function \"%s\" ==",
+ m_name.c_str());
lldb::ThreadPlanSP call_plan_sp = GetThreadPlanToCallFunction(
exe_ctx, args_addr, real_options, diagnostic_manager);
@@ -362,13 +360,15 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
if (log) {
if (return_value != lldb::eExpressionCompleted) {
- log->Printf("== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
- "completed abnormally ==",
- m_name.c_str());
+ LLDB_LOGF(log,
+ "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
+ "completed abnormally ==",
+ m_name.c_str());
} else {
- log->Printf("== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
- "completed normally ==",
- m_name.c_str());
+ LLDB_LOGF(log,
+ "== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
+ "completed normally ==",
+ m_name.c_str());
}
}
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index 25404ad313e..b98a56b6e79 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -122,10 +122,10 @@ Status IRExecutionUnit::DisassembleFunction(Stream &stream,
return ret;
}
- if (log)
- log->Printf("Found function, has local address 0x%" PRIx64
- " and remote address 0x%" PRIx64,
- (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
+ LLDB_LOGF(log,
+ "Found function, has local address 0x%" PRIx64
+ " and remote address 0x%" PRIx64,
+ (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
std::pair<lldb::addr_t, lldb::addr_t> func_range;
@@ -138,9 +138,8 @@ Status IRExecutionUnit::DisassembleFunction(Stream &stream,
return ret;
}
- if (log)
- log->Printf("Function's code range is [0x%" PRIx64 "+0x%" PRIx64 "]",
- func_range.first, func_range.second);
+ LLDB_LOGF(log, "Function's code range is [0x%" PRIx64 "+0x%" PRIx64 "]",
+ func_range.first, func_range.second);
Target *target = exe_ctx.GetTargetPtr();
if (!target) {
@@ -188,7 +187,7 @@ Status IRExecutionUnit::DisassembleFunction(Stream &stream,
target->GetArchitecture().GetAddressByteSize());
if (log) {
- log->Printf("Function data has contents:");
+ LLDB_LOGF(log, "Function data has contents:");
extractor.PutToLog(log, 0, extractor.GetByteSize(), func_remote_addr, 16,
DataExtractor::TypeUInt8);
}
@@ -255,7 +254,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
oss.flush();
- log->Printf("Module being sent to JIT: \n%s", s.c_str());
+ LLDB_LOGF(log, "Module being sent to JIT: \n%s", s.c_str());
}
m_module_up->getContext().setInlineAsmDiagnosticHandler(ReportInlineAsmError,
@@ -433,20 +432,20 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
}
if (log) {
- log->Printf("Code can be run in the target.");
+ LLDB_LOGF(log, "Code can be run in the target.");
StreamString disassembly_stream;
Status err = DisassembleFunction(disassembly_stream, process_sp);
if (!err.Success()) {
- log->Printf("Couldn't disassemble function : %s",
- err.AsCString("unknown error"));
+ LLDB_LOGF(log, "Couldn't disassemble function : %s",
+ err.AsCString("unknown error"));
} else {
- log->Printf("Function disassembly:\n%s", disassembly_stream.GetData());
+ LLDB_LOGF(log, "Function disassembly:\n%s", disassembly_stream.GetData());
}
- log->Printf("Sections: ");
+ LLDB_LOGF(log, "Sections: ");
for (AllocationRecord &record : m_records) {
if (record.m_process_address != LLDB_INVALID_ADDRESS) {
record.dump(log);
@@ -599,11 +598,10 @@ uint8_t *IRExecutionUnit::MemoryManager::allocateCodeSection(
GetSectionTypeFromSectionName(SectionName, AllocationKind::Code), Size,
Alignment, SectionID, SectionName.str().c_str()));
- if (log) {
- log->Printf("IRExecutionUnit::allocateCodeSection(Size=0x%" PRIx64
- ", Alignment=%u, SectionID=%u) = %p",
- (uint64_t)Size, Alignment, SectionID, (void *)return_value);
- }
+ LLDB_LOGF(log,
+ "IRExecutionUnit::allocateCodeSection(Size=0x%" PRIx64
+ ", Alignment=%u, SectionID=%u) = %p",
+ (uint64_t)Size, Alignment, SectionID, (void *)return_value);
if (m_parent.m_reported_allocations) {
Status err;
@@ -631,11 +629,10 @@ uint8_t *IRExecutionUnit::MemoryManager::allocateDataSection(
(uintptr_t)return_value, permissions,
GetSectionTypeFromSectionName(SectionName, AllocationKind::Data), Size,
Alignment, SectionID, SectionName.str().c_str()));
- if (log) {
- log->Printf("IRExecutionUnit::allocateDataSection(Size=0x%" PRIx64
- ", Alignment=%u, SectionID=%u) = %p",
- (uint64_t)Size, Alignment, SectionID, (void *)return_value);
- }
+ LLDB_LOGF(log,
+ "IRExecutionUnit::allocateDataSection(Size=0x%" PRIx64
+ ", Alignment=%u, SectionID=%u) = %p",
+ (uint64_t)Size, Alignment, SectionID, (void *)return_value);
if (m_parent.m_reported_allocations) {
Status err;
@@ -1042,17 +1039,15 @@ IRExecutionUnit::MemoryManager::GetSymbolAddressAndPresence(
lldb::addr_t ret = m_parent.FindSymbol(name_cs, missing_weak);
if (ret == LLDB_INVALID_ADDRESS) {
- if (log)
- log->Printf(
- "IRExecutionUnit::getSymbolAddress(Name=\"%s\") = <not found>",
- Name.c_str());
+ LLDB_LOGF(log,
+ "IRExecutionUnit::getSymbolAddress(Name=\"%s\") = <not found>",
+ Name.c_str());
m_parent.ReportSymbolLookupError(name_cs);
return 0;
} else {
- if (log)
- log->Printf("IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64,
- Name.c_str(), ret);
+ LLDB_LOGF(log, "IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64,
+ Name.c_str(), ret);
return ret;
}
}
@@ -1075,15 +1070,14 @@ IRExecutionUnit::GetRemoteAddressForLocal(lldb::addr_t local_address) {
lldb::addr_t ret =
record.m_process_address + (local_address - record.m_host_address);
- if (log) {
- log->Printf(
- "IRExecutionUnit::GetRemoteAddressForLocal() found 0x%" PRIx64
- " in [0x%" PRIx64 "..0x%" PRIx64 "], and returned 0x%" PRIx64
- " from [0x%" PRIx64 "..0x%" PRIx64 "].",
- local_address, (uint64_t)record.m_host_address,
- (uint64_t)record.m_host_address + (uint64_t)record.m_size, ret,
- record.m_process_address, record.m_process_address + record.m_size);
- }
+ LLDB_LOGF(log,
+ "IRExecutionUnit::GetRemoteAddressForLocal() found 0x%" PRIx64
+ " in [0x%" PRIx64 "..0x%" PRIx64 "], and returned 0x%" PRIx64
+ " from [0x%" PRIx64 "..0x%" PRIx64 "].",
+ local_address, (uint64_t)record.m_host_address,
+ (uint64_t)record.m_host_address + (uint64_t)record.m_size, ret,
+ record.m_process_address,
+ record.m_process_address + record.m_size);
return ret;
}
@@ -1210,10 +1204,11 @@ void IRExecutionUnit::AllocationRecord::dump(Log *log) {
if (!log)
return;
- log->Printf("[0x%llx+0x%llx]->0x%llx (alignment %d, section ID %d, name %s)",
- (unsigned long long)m_host_address, (unsigned long long)m_size,
- (unsigned long long)m_process_address, (unsigned)m_alignment,
- (unsigned)m_section_id, m_name.c_str());
+ LLDB_LOGF(log,
+ "[0x%llx+0x%llx]->0x%llx (alignment %d, section ID %d, name %s)",
+ (unsigned long long)m_host_address, (unsigned long long)m_size,
+ (unsigned long long)m_process_address, (unsigned)m_alignment,
+ (unsigned)m_section_id, m_name.c_str());
}
lldb::ByteOrder IRExecutionUnit::GetByteOrder() const {
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index 5a9814d1536..856c9a0244f 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/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;
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp
index 70e62ac12b0..5fdf452bf94 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -327,12 +327,12 @@ lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment,
break;
case eAllocationPolicyMirror:
process_sp = m_process_wp.lock();
- if (log)
- log->Printf("IRMemoryMap::%s process_sp=0x%" PRIx64
- ", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s",
- __FUNCTION__, (lldb::addr_t)process_sp.get(),
- process_sp && process_sp->CanJIT() ? "true" : "false",
- process_sp && process_sp->IsAlive() ? "true" : "false");
+ LLDB_LOGF(log,
+ "IRMemoryMap::%s process_sp=0x%" PRIx64
+ ", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s",
+ __FUNCTION__, (lldb::addr_t)process_sp.get(),
+ process_sp && process_sp->CanJIT() ? "true" : "false",
+ process_sp && process_sp->IsAlive() ? "true" : "false");
if (process_sp && process_sp->CanJIT() && process_sp->IsAlive()) {
if (!zero_memory)
allocation_address =
@@ -344,10 +344,10 @@ lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment,
if (!error.Success())
return LLDB_INVALID_ADDRESS;
} else {
- if (log)
- log->Printf("IRMemoryMap::%s switching to eAllocationPolicyHostOnly "
- "due to failed condition (see previous expr log message)",
- __FUNCTION__);
+ LLDB_LOGF(log,
+ "IRMemoryMap::%s switching to eAllocationPolicyHostOnly "
+ "due to failed condition (see previous expr log message)",
+ __FUNCTION__);
policy = eAllocationPolicyHostOnly;
allocation_address = FindSpace(allocation_size);
if (allocation_address == LLDB_INVALID_ADDRESS) {
@@ -417,10 +417,11 @@ lldb::addr_t IRMemoryMap::Malloc(size_t size, uint8_t alignment,
break;
}
- log->Printf("IRMemoryMap::Malloc (%" PRIu64 ", 0x%" PRIx64 ", 0x%" PRIx64
- ", %s) -> 0x%" PRIx64,
- (uint64_t)allocation_size, (uint64_t)alignment,
- (uint64_t)permissions, policy_string, aligned_address);
+ LLDB_LOGF(log,
+ "IRMemoryMap::Malloc (%" PRIu64 ", 0x%" PRIx64 ", 0x%" PRIx64
+ ", %s) -> 0x%" PRIx64,
+ (uint64_t)allocation_size, (uint64_t)alignment,
+ (uint64_t)permissions, policy_string, aligned_address);
}
return aligned_address;
@@ -477,10 +478,11 @@ void IRMemoryMap::Free(lldb::addr_t process_address, Status &error) {
if (lldb_private::Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf("IRMemoryMap::Free (0x%" PRIx64 ") freed [0x%" PRIx64
- "..0x%" PRIx64 ")",
- (uint64_t)process_address, iter->second.m_process_start,
- iter->second.m_process_start + iter->second.m_size);
+ LLDB_LOGF(log,
+ "IRMemoryMap::Free (0x%" PRIx64 ") freed [0x%" PRIx64
+ "..0x%" PRIx64 ")",
+ (uint64_t)process_address, iter->second.m_process_start,
+ iter->second.m_process_start + iter->second.m_size);
}
m_allocations.erase(iter);
@@ -574,12 +576,13 @@ void IRMemoryMap::WriteMemory(lldb::addr_t process_address,
if (lldb_private::Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf("IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
- ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
- (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
- (uint64_t)allocation.m_process_start,
- (uint64_t)allocation.m_process_start +
- (uint64_t)allocation.m_size);
+ LLDB_LOGF(log,
+ "IRMemoryMap::WriteMemory (0x%" PRIx64 ", 0x%" PRIx64
+ ", 0x%" PRId64 ") went to [0x%" PRIx64 "..0x%" PRIx64 ")",
+ (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
+ (uint64_t)allocation.m_process_start,
+ (uint64_t)allocation.m_process_start +
+ (uint64_t)allocation.m_size);
}
}
@@ -704,12 +707,13 @@ void IRMemoryMap::ReadMemory(uint8_t *bytes, lldb::addr_t process_address,
if (lldb_private::Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf("IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIx64
- ", 0x%" PRId64 ") came from [0x%" PRIx64 "..0x%" PRIx64 ")",
- (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
- (uint64_t)allocation.m_process_start,
- (uint64_t)allocation.m_process_start +
- (uint64_t)allocation.m_size);
+ LLDB_LOGF(log,
+ "IRMemoryMap::ReadMemory (0x%" PRIx64 ", 0x%" PRIx64
+ ", 0x%" PRId64 ") came from [0x%" PRIx64 "..0x%" PRIx64 ")",
+ (uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
+ (uint64_t)allocation.m_process_start,
+ (uint64_t)allocation.m_process_start +
+ (uint64_t)allocation.m_size);
}
}
diff --git a/lldb/source/Expression/LLVMUserExpression.cpp b/lldb/source/Expression/LLVMUserExpression.cpp
index a49e23cea6e..3463a088e8a 100644
--- a/lldb/source/Expression/LLVMUserExpression.cpp
+++ b/lldb/source/Expression/LLVMUserExpression.cpp
@@ -161,9 +161,9 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
function_stack_bottom = function_stack_pointer - HostInfo::GetPageSize();
function_stack_top = function_stack_pointer;
- if (log)
- log->Printf(
- "-- [UserExpression::Execute] Execution of expression begins --");
+ LLDB_LOGF(
+ log,
+ "-- [UserExpression::Execute] Execution of expression begins --");
if (exe_ctx.GetProcessPtr())
exe_ctx.GetProcessPtr()->SetRunningUserExpression(true);
@@ -175,9 +175,8 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
if (exe_ctx.GetProcessPtr())
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
- if (log)
- log->Printf("-- [UserExpression::Execute] Execution of expression "
- "completed --");
+ LLDB_LOGF(log, "-- [UserExpression::Execute] Execution of expression "
+ "completed --");
if (execution_result == lldb::eExpressionInterrupted ||
execution_result == lldb::eExpressionHitBreakpoint) {
@@ -251,9 +250,8 @@ bool LLVMUserExpression::FinalizeJITExecution(
lldb::addr_t function_stack_top) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf("-- [UserExpression::FinalizeJITExecution] Dematerializing "
- "after execution --");
+ LLDB_LOGF(log, "-- [UserExpression::FinalizeJITExecution] Dematerializing "
+ "after execution --");
if (!m_dematerializer_sp) {
diagnostic_manager.Printf(eDiagnosticSeverityError,
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index d4e887119c7..e86afb6018a 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -93,9 +93,8 @@ public:
return;
}
- if (log)
- log->Printf("Allocated %s (0x%" PRIx64 ") successfully",
- m_persistent_variable_sp->GetName().GetCString(), mem);
+ LLDB_LOGF(log, "Allocated %s (0x%" PRIx64 ") successfully",
+ m_persistent_variable_sp->GetName().GetCString(), mem);
// Put the location of the spare memory into the live data of the
// ValueObject.
@@ -157,11 +156,12 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityPersistentVariable::Materialize [address = 0x%" PRIx64
- ", m_name = %s, m_flags = 0x%hx]",
- (uint64_t)load_addr,
- m_persistent_variable_sp->GetName().AsCString(),
- m_persistent_variable_sp->m_flags);
+ LLDB_LOGF(log,
+ "EntityPersistentVariable::Materialize [address = 0x%" PRIx64
+ ", m_name = %s, m_flags = 0x%hx]",
+ (uint64_t)load_addr,
+ m_persistent_variable_sp->GetName().AsCString(),
+ m_persistent_variable_sp->m_flags);
}
if (m_persistent_variable_sp->m_flags &
@@ -208,12 +208,12 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf(
- "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64
- ", m_name = %s, m_flags = 0x%hx]",
- (uint64_t)process_address + m_offset,
- m_persistent_variable_sp->GetName().AsCString(),
- m_persistent_variable_sp->m_flags);
+ LLDB_LOGF(log,
+ "EntityPersistentVariable::Dematerialize [address = 0x%" PRIx64
+ ", m_name = %s, m_flags = 0x%hx]",
+ (uint64_t)process_address + m_offset,
+ m_persistent_variable_sp->GetName().AsCString(),
+ m_persistent_variable_sp->m_flags);
}
if (m_delegate) {
@@ -290,11 +290,10 @@ public:
ExpressionVariable::EVNeedsFreezeDry ||
m_persistent_variable_sp->m_flags &
ExpressionVariable::EVKeepInTarget) {
- if (log)
- log->Printf(
- "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
- m_persistent_variable_sp->GetName().GetCString(), (uint64_t)mem,
- (unsigned long long)m_persistent_variable_sp->GetByteSize());
+ LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",
+ m_persistent_variable_sp->GetName().GetCString(),
+ (uint64_t)mem,
+ (unsigned long long)m_persistent_variable_sp->GetByteSize());
// Read the contents of the spare memory area
@@ -440,9 +439,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityVariable::Materialize [address = 0x%" PRIx64
- ", m_variable_sp = %s]",
- (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntityVariable::Materialize [address = 0x%" PRIx64
+ ", m_variable_sp = %s]",
+ (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
}
ExecutionContextScope *scope = frame_sp.get();
@@ -605,9 +605,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityVariable::Dematerialize [address = 0x%" PRIx64
- ", m_variable_sp = %s]",
- (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntityVariable::Dematerialize [address = 0x%" PRIx64
+ ", m_variable_sp = %s]",
+ (uint64_t)load_addr, m_variable_sp->GetName().AsCString());
}
if (m_temporary_allocation != LLDB_INVALID_ADDRESS) {
@@ -1063,9 +1064,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntitySymbol::Materialize [address = 0x%" PRIx64
- ", m_symbol = %s]",
- (uint64_t)load_addr, m_symbol.GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntitySymbol::Materialize [address = 0x%" PRIx64
+ ", m_symbol = %s]",
+ (uint64_t)load_addr, m_symbol.GetName().AsCString());
}
const Address sym_address = m_symbol.GetAddress();
@@ -1109,9 +1111,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntitySymbol::Dematerialize [address = 0x%" PRIx64
- ", m_symbol = %s]",
- (uint64_t)load_addr, m_symbol.GetName().AsCString());
+ LLDB_LOGF(log,
+ "EntitySymbol::Dematerialize [address = 0x%" PRIx64
+ ", m_symbol = %s]",
+ (uint64_t)load_addr, m_symbol.GetName().AsCString());
}
// no work needs to be done
@@ -1178,9 +1181,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityRegister::Materialize [address = 0x%" PRIx64
- ", m_register_info = %s]",
- (uint64_t)load_addr, m_register_info.name);
+ LLDB_LOGF(log,
+ "EntityRegister::Materialize [address = 0x%" PRIx64
+ ", m_register_info = %s]",
+ (uint64_t)load_addr, m_register_info.name);
}
RegisterValue reg_value;
@@ -1240,9 +1244,10 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
if (log) {
- log->Printf("EntityRegister::Dematerialize [address = 0x%" PRIx64
- ", m_register_info = %s]",
- (uint64_t)load_addr, m_register_info.name);
+ LLDB_LOGF(log,
+ "EntityRegister::Dematerialize [address = 0x%" PRIx64
+ ", m_register_info = %s]",
+ (uint64_t)load_addr, m_register_info.name);
}
Status extract_error;
@@ -1379,7 +1384,8 @@ Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
if (Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"Materializer::Materialize (frame_sp = %p, process_address = 0x%" PRIx64
") materialized:",
static_cast<void *>(frame_sp.get()), process_address);
@@ -1414,9 +1420,10 @@ void Materializer::Dematerializer::Dematerialize(Status &error,
} else {
if (Log *log =
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
- log->Printf("Materializer::Dematerialize (frame_sp = %p, process_address "
- "= 0x%" PRIx64 ") about to dematerialize:",
- static_cast<void *>(frame_sp.get()), m_process_address);
+ LLDB_LOGF(log,
+ "Materializer::Dematerialize (frame_sp = %p, process_address "
+ "= 0x%" PRIx64 ") about to dematerialize:",
+ static_cast<void *>(frame_sp.get()), m_process_address);
for (EntityUP &entity_up : m_materializer->m_entities)
entity_up->DumpToLog(*m_map, m_process_address, log);
}
diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index a72e2a07599..ea54cec7b1f 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -165,9 +165,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
Target *target = exe_ctx.GetTargetPtr();
if (!target) {
- if (log)
- log->Printf("== [UserExpression::Evaluate] Passed a NULL target, can't "
- "run expressions.");
+ LLDB_LOGF(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
+ "run expressions.");
error.SetErrorString("expression passed a null target");
return lldb::eExpressionSetupError;
}
@@ -176,9 +175,9 @@ lldb::ExpressionResults UserExpression::Evaluate(
if (process == nullptr || process->GetState() != lldb::eStateStopped) {
if (execution_policy == eExecutionPolicyAlways) {
- if (log)
- log->Printf("== [UserExpression::Evaluate] Expression may not run, but "
- "is not constant ==");
+ LLDB_LOGF(log,
+ "== [UserExpression::Evaluate] Expression may not run, but "
+ "is not constant ==");
error.SetErrorString("expression needed to run but couldn't");
@@ -224,14 +223,14 @@ lldb::ExpressionResults UserExpression::Evaluate(
error));
if (error.Fail()) {
if (log)
- log->Printf("== [UserExpression::Evaluate] Getting expression: %s ==",
- error.AsCString());
+ LLDB_LOGF(log, "== [UserExpression::Evaluate] Getting expression: %s ==",
+ error.AsCString());
return lldb::eExpressionSetupError;
}
if (log)
- log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==",
- expr.str().c_str());
+ LLDB_LOGF(log, "== [UserExpression::Evaluate] Parsing expression %s ==",
+ expr.str().c_str());
const bool keep_expression_in_memory = true;
const bool generate_debug_info = options.GetGenerateDebugInfo();
@@ -310,8 +309,9 @@ lldb::ExpressionResults UserExpression::Evaluate(
if (execution_policy == eExecutionPolicyNever &&
!user_expression_sp->CanInterpret()) {
if (log)
- log->Printf("== [UserExpression::Evaluate] Expression may not run, but "
- "is not constant ==");
+ LLDB_LOGF(log,
+ "== [UserExpression::Evaluate] Expression may not run, but "
+ "is not constant ==");
if (!diagnostic_manager.Diagnostics().size())
error.SetExpressionError(lldb::eExpressionSetupError,
@@ -332,7 +332,7 @@ lldb::ExpressionResults UserExpression::Evaluate(
diagnostic_manager.Clear();
if (log)
- log->Printf("== [UserExpression::Evaluate] Executing expression ==");
+ LLDB_LOGF(log, "== [UserExpression::Evaluate] Executing expression ==");
execution_results =
user_expression_sp->Execute(diagnostic_manager, exe_ctx, options,
@@ -340,8 +340,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
if (execution_results != lldb::eExpressionCompleted) {
if (log)
- log->Printf("== [UserExpression::Evaluate] Execution completed "
- "abnormally ==");
+ LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
+ "abnormally ==");
if (!diagnostic_manager.Diagnostics().size())
error.SetExpressionError(
@@ -354,13 +354,14 @@ lldb::ExpressionResults UserExpression::Evaluate(
result_valobj_sp = expr_result->GetValueObject();
if (log)
- log->Printf("== [UserExpression::Evaluate] Execution completed "
- "normally with result %s ==",
- result_valobj_sp->GetValueAsCString());
+ LLDB_LOGF(log,
+ "== [UserExpression::Evaluate] Execution completed "
+ "normally with result %s ==",
+ result_valobj_sp->GetValueAsCString());
} else {
if (log)
- log->Printf("== [UserExpression::Evaluate] Execution completed "
- "normally with no result ==");
+ LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
+ "normally with no result ==");
error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric);
}
OpenPOWER on IntegriCloud