diff options
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime')
10 files changed, 486 insertions, 611 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 52519c8fd2f..4e50ae0be28 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -79,11 +79,10 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( if (name && strstr(name, vtable_demangled_prefix) == name) { Log *log( lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT)); - if (log) - log->Printf("0x%16.16" PRIx64 - ": static-type = '%s' has vtable symbol '%s'\n", - original_ptr, in_value.GetTypeName().GetCString(), - name); + LLDB_LOGF(log, + "0x%16.16" PRIx64 + ": static-type = '%s' has vtable symbol '%s'\n", + original_ptr, in_value.GetTypeName().GetCString(), name); // We are a C++ class, that's good. Get the class name and look it // up: const char *class_name = name + strlen(vtable_demangled_prefix); @@ -116,9 +115,8 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( lldb::TypeSP type_sp; if (num_matches == 0) { - if (log) - log->Printf("0x%16.16" PRIx64 ": is not dynamic\n", - original_ptr); + LLDB_LOGF(log, "0x%16.16" PRIx64 ": is not dynamic\n", + original_ptr); return TypeAndOrName(); } if (num_matches == 1) { @@ -126,13 +124,13 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( if (type_sp) { if (ClangASTContext::IsCXXClassType( type_sp->GetForwardCompilerType())) { - if (log) - log->Printf( - "0x%16.16" PRIx64 - ": static-type = '%s' has dynamic type: uid={0x%" PRIx64 - "}, type-name='%s'\n", - original_ptr, in_value.GetTypeName().AsCString(), - type_sp->GetID(), type_sp->GetName().GetCString()); + LLDB_LOGF( + log, + "0x%16.16" PRIx64 + ": static-type = '%s' has dynamic type: uid={0x%" PRIx64 + "}, type-name='%s'\n", + original_ptr, in_value.GetTypeName().AsCString(), + type_sp->GetID(), type_sp->GetName().GetCString()); type_info.SetTypeSP(type_sp); } } @@ -142,13 +140,13 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( for (i = 0; i < num_matches; i++) { type_sp = class_types.GetTypeAtIndex(i); if (type_sp) { - if (log) - log->Printf( - "0x%16.16" PRIx64 - ": static-type = '%s' has multiple matching dynamic " - "types: uid={0x%" PRIx64 "}, type-name='%s'\n", - original_ptr, in_value.GetTypeName().AsCString(), - type_sp->GetID(), type_sp->GetName().GetCString()); + LLDB_LOGF( + log, + "0x%16.16" PRIx64 + ": static-type = '%s' has multiple matching dynamic " + "types: uid={0x%" PRIx64 "}, type-name='%s'\n", + original_ptr, in_value.GetTypeName().AsCString(), + type_sp->GetID(), type_sp->GetName().GetCString()); } } } @@ -158,25 +156,24 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress( if (type_sp) { if (ClangASTContext::IsCXXClassType( type_sp->GetForwardCompilerType())) { - if (log) - log->Printf( - "0x%16.16" PRIx64 ": static-type = '%s' has multiple " - "matching dynamic types, picking " - "this one: uid={0x%" PRIx64 - "}, type-name='%s'\n", - original_ptr, in_value.GetTypeName().AsCString(), - type_sp->GetID(), type_sp->GetName().GetCString()); + LLDB_LOGF( + log, + "0x%16.16" PRIx64 ": static-type = '%s' has multiple " + "matching dynamic types, picking " + "this one: uid={0x%" PRIx64 "}, type-name='%s'\n", + original_ptr, in_value.GetTypeName().AsCString(), + type_sp->GetID(), type_sp->GetName().GetCString()); type_info.SetTypeSP(type_sp); } } } if (log && i == num_matches) { - log->Printf( - "0x%16.16" PRIx64 - ": static-type = '%s' has multiple matching dynamic " - "types, didn't find a C++ match\n", - original_ptr, in_value.GetTypeName().AsCString()); + LLDB_LOGF(log, + "0x%16.16" PRIx64 + ": static-type = '%s' has multiple matching dynamic " + "types, didn't find a C++ match\n", + original_ptr, in_value.GetTypeName().AsCString()); } } if (type_info) diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index 18f2a1829a4..078543a86ca 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -38,12 +38,13 @@ public: LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? if (log) { - log->Printf("AppleObjCExternalASTSource::FindExternalVisibleDeclsByName[%" - "u] on (ASTContext*)%p Looking for %s in (%sDecl*)%p", - current_id, - static_cast<void *>(&decl_ctx->getParentASTContext()), - name.getAsString().c_str(), decl_ctx->getDeclKindName(), - static_cast<const void *>(decl_ctx)); + LLDB_LOGF(log, + "AppleObjCExternalASTSource::FindExternalVisibleDeclsByName[%" + "u] on (ASTContext*)%p Looking for %s in (%sDecl*)%p", + current_id, + static_cast<void *>(&decl_ctx->getParentASTContext()), + name.getAsString().c_str(), decl_ctx->getDeclKindName(), + static_cast<const void *>(decl_ctx)); } do { @@ -77,19 +78,20 @@ public: LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? if (log) { - log->Printf("AppleObjCExternalASTSource::CompleteType[%u] on " - "(ASTContext*)%p Completing (TagDecl*)%p named %s", - current_id, static_cast<void *>(&tag_decl->getASTContext()), - static_cast<void *>(tag_decl), - tag_decl->getName().str().c_str()); - - log->Printf(" AOEAS::CT[%u] Before:", current_id); + LLDB_LOGF(log, + "AppleObjCExternalASTSource::CompleteType[%u] on " + "(ASTContext*)%p Completing (TagDecl*)%p named %s", + current_id, static_cast<void *>(&tag_decl->getASTContext()), + static_cast<void *>(tag_decl), + tag_decl->getName().str().c_str()); + + LLDB_LOGF(log, " AOEAS::CT[%u] Before:", current_id); ASTDumper dumper((clang::Decl *)tag_decl); dumper.ToLog(log, " [CT] "); } if (log) { - log->Printf(" AOEAS::CT[%u] After:", current_id); + LLDB_LOGF(log, " AOEAS::CT[%u] After:", current_id); ASTDumper dumper((clang::Decl *)tag_decl); dumper.ToLog(log, " [CT] "); } @@ -104,14 +106,15 @@ public: LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? if (log) { - log->Printf("AppleObjCExternalASTSource::CompleteType[%u] on " - "(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s", - current_id, - static_cast<void *>(&interface_decl->getASTContext()), - static_cast<void *>(interface_decl), - interface_decl->getName().str().c_str()); - - log->Printf(" AOEAS::CT[%u] Before:", current_id); + LLDB_LOGF(log, + "AppleObjCExternalASTSource::CompleteType[%u] on " + "(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s", + current_id, + static_cast<void *>(&interface_decl->getASTContext()), + static_cast<void *>(interface_decl), + interface_decl->getName().str().c_str()); + + LLDB_LOGF(log, " AOEAS::CT[%u] Before:", current_id); ASTDumper dumper((clang::Decl *)interface_decl); dumper.ToLog(log, " [CT] "); } @@ -119,7 +122,7 @@ public: m_decl_vendor.FinishDecl(interface_decl); if (log) { - log->Printf(" [CT] After:"); + LLDB_LOGF(log, " [CT] After:"); ASTDumper dumper((clang::Decl *)interface_decl); dumper.ToLog(log, " [CT] "); } @@ -462,8 +465,7 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { clang::ObjCMethodDecl *method_decl = method_type.BuildMethod(interface_decl, name, true, m_type_realizer_sp); - if (log) - log->Printf("[ AOTV::FD] Instance method [%s] [%s]", name, types); + LLDB_LOGF(log, "[ AOTV::FD] Instance method [%s] [%s]", name, types); if (method_decl) interface_decl->addDecl(method_decl); @@ -481,8 +483,7 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { clang::ObjCMethodDecl *method_decl = method_type.BuildMethod( interface_decl, name, false, m_type_realizer_sp); - if (log) - log->Printf("[ AOTV::FD] Class method [%s] [%s]", name, types); + LLDB_LOGF(log, "[ AOTV::FD] Class method [%s] [%s]", name, types); if (method_decl) interface_decl->addDecl(method_decl); @@ -498,10 +499,9 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { const bool for_expression = false; - if (log) - log->Printf( - "[ AOTV::FD] Instance variable [%s] [%s], offset at %" PRIx64, name, - type, offset_ptr); + LLDB_LOGF(log, + "[ AOTV::FD] Instance variable [%s] [%s], offset at %" PRIx64, + name, type, offset_ptr); CompilerType ivar_type = m_runtime.GetEncodingToType()->RealizeType( m_ast_ctx, type, for_expression); @@ -527,9 +527,10 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { if (log) { ASTDumper method_dumper((clang::Decl *)interface_decl); - log->Printf("[AppleObjCDeclVendor::FinishDecl] Finishing Objective-C " - "interface for %s", - descriptor->GetClassName().AsCString()); + LLDB_LOGF(log, + "[AppleObjCDeclVendor::FinishDecl] Finishing Objective-C " + "interface for %s", + descriptor->GetClassName().AsCString()); } if (!descriptor->Describe(superclass_func, instance_method_func, @@ -539,7 +540,8 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { if (log) { ASTDumper method_dumper((clang::Decl *)interface_decl); - log->Printf( + LLDB_LOGF( + log, "[AppleObjCDeclVendor::FinishDecl] Finished Objective-C interface"); method_dumper.ToLog(log, " [AOTV::FD] "); @@ -558,10 +560,9 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, Log *log(GetLogIfAllCategoriesSet( LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel? - if (log) - log->Printf("AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )", - current_id, (const char *)name.AsCString(), - append ? "true" : "false", max_matches); + LLDB_LOGF(log, "AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )", + current_id, (const char *)name.AsCString(), + append ? "true" : "false", max_matches); if (!append) decls.clear(); @@ -595,24 +596,25 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, if (metadata) isa_value = metadata->GetISAPtr(); - log->Printf("AOCTV::FT [%u] Found %s (isa 0x%" PRIx64 - ") in the ASTContext", - current_id, dumper.GetCString(), isa_value); + LLDB_LOGF(log, + "AOCTV::FT [%u] Found %s (isa 0x%" PRIx64 + ") in the ASTContext", + current_id, dumper.GetCString(), isa_value); } decls.push_back(result_iface_decl); ret++; break; } else { - if (log) - log->Printf("AOCTV::FT [%u] There's something in the ASTContext, but " - "it's not something we know about", - current_id); + LLDB_LOGF(log, + "AOCTV::FT [%u] There's something in the ASTContext, but " + "it's not something we know about", + current_id); break; } } else if (log) { - log->Printf("AOCTV::FT [%u] Couldn't find %s in the ASTContext", - current_id, name.AsCString()); + LLDB_LOGF(log, "AOCTV::FT [%u] Couldn't find %s in the ASTContext", + current_id, name.AsCString()); } // It's not. If it exists, we have to put it into our ASTContext. @@ -620,8 +622,7 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, ObjCLanguageRuntime::ObjCISA isa = m_runtime.GetISA(name); if (!isa) { - if (log) - log->Printf("AOCTV::FT [%u] Couldn't find the isa", current_id); + LLDB_LOGF(log, "AOCTV::FT [%u] Couldn't find the isa", current_id); break; } @@ -629,10 +630,10 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, clang::ObjCInterfaceDecl *iface_decl = GetDeclForISA(isa); if (!iface_decl) { - if (log) - log->Printf("AOCTV::FT [%u] Couldn't get the Objective-C interface for " - "isa 0x%" PRIx64, - current_id, (uint64_t)isa); + LLDB_LOGF(log, + "AOCTV::FT [%u] Couldn't get the Objective-C interface for " + "isa 0x%" PRIx64, + current_id, (uint64_t)isa); break; } @@ -641,8 +642,8 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, clang::QualType new_iface_type = ast_ctx->getObjCInterfaceType(iface_decl); ASTDumper dumper(new_iface_type); - log->Printf("AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")", current_id, - dumper.GetCString(), (uint64_t)isa); + LLDB_LOGF(log, "AOCTV::FT [%u] Created %s (isa 0x%" PRIx64 ")", + current_id, dumper.GetCString(), (uint64_t)isa); } decls.push_back(iface_decl); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp index c8884fd5c9b..88bfe2ce020 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -395,10 +395,11 @@ void AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() { new ClassDescriptorV1(isa, process_sp)); if (log && log->GetVerbose()) - log->Printf("AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 - " from _objc_debug_class_hash to " - "isa->descriptor cache", - isa); + LLDB_LOGF(log, + "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 + " from _objc_debug_class_hash to " + "isa->descriptor cache", + isa); AddClass(isa, descriptor_sp); } @@ -417,7 +418,8 @@ void AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() { new ClassDescriptorV1(isa, process_sp)); if (log && log->GetVerbose()) - log->Printf( + LLDB_LOGF( + log, "AppleObjCRuntimeV1 added (ObjCISA)0x%" PRIx64 " from _objc_debug_class_hash to isa->descriptor " "cache", diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 635eaff637b..cfec2de1fb9 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1209,11 +1209,11 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) { objc_class_sp = GetClassDescriptorFromISA(isa); if (isa && !objc_class_sp) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); - if (log) - log->Printf("0x%" PRIx64 - ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was " - "not in class descriptor cache 0x%" PRIx64, - isa_pointer, isa); + LLDB_LOGF(log, + "0x%" PRIx64 + ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was " + "not in class descriptor cache 0x%" PRIx64, + isa_pointer, isa); } } } @@ -1317,8 +1317,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic( // Read the total number of classes from the hash table const uint32_t num_classes = hash_table.GetCount(); if (num_classes == 0) { - if (log) - log->Printf("No dynamic classes found in gdb_objc_realized_classes."); + LLDB_LOGF(log, "No dynamic classes found in gdb_objc_realized_classes."); return DescriptorMapUpdateResult::Success(0); } @@ -1337,17 +1336,16 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic( g_get_dynamic_class_info_body, eLanguageTypeObjC, g_get_dynamic_class_info_name, error)); if (error.Fail()) { - if (log) - log->Printf( - "Failed to get Utility Function for implementation lookup: %s", - error.AsCString()); + LLDB_LOGF(log, + "Failed to get Utility Function for implementation lookup: %s", + error.AsCString()); m_get_class_info_code.reset(); } else { diagnostics.Clear(); if (!m_get_class_info_code->Install(diagnostics, exe_ctx)) { if (log) { - log->Printf("Failed to install implementation lookup"); + LLDB_LOGF(log, "Failed to install implementation lookup"); diagnostics.Dump(log); } m_get_class_info_code.reset(); @@ -1372,17 +1370,16 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic( clang_uint32_t_type, arguments, thread_sp, error); if (error.Fail()) { - if (log) - log->Printf( - "Failed to make function caller for implementation lookup: %s.", - error.AsCString()); + LLDB_LOGF(log, + "Failed to make function caller for implementation lookup: %s.", + error.AsCString()); return DescriptorMapUpdateResult::Fail(); } } else { get_class_info_function = m_get_class_info_code->GetFunctionCaller(); if (!get_class_info_function) { if (log) { - log->Printf("Failed to get implementation lookup function caller."); + LLDB_LOGF(log, "Failed to get implementation lookup function caller."); diagnostics.Dump(log); } @@ -1399,10 +1396,10 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic( class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err); if (class_infos_addr == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("unable to allocate %" PRIu32 - " bytes in process for shared cache read", - class_infos_byte_size); + LLDB_LOGF(log, + "unable to allocate %" PRIu32 + " bytes in process for shared cache read", + class_infos_byte_size); return DescriptorMapUpdateResult::Fail(); } @@ -1451,8 +1448,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic( if (results == eExpressionCompleted) { // The result is the number of ClassInfo structures that were filled in num_class_infos = return_value.GetScalar().ULong(); - if (log) - log->Printf("Discovered %u ObjC classes\n", num_class_infos); + LLDB_LOGF(log, "Discovered %u ObjC classes\n", num_class_infos); if (num_class_infos > 0) { // Read the ClassInfo structures DataBufferHeap buffer(num_class_infos * class_info_byte_size, 0); @@ -1468,13 +1464,13 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic( success = true; } else { if (log) { - log->Printf("Error evaluating our find class name function."); + LLDB_LOGF(log, "Error evaluating our find class name function."); diagnostics.Dump(log); } } } else { if (log) { - log->Printf("Error writing function arguments."); + LLDB_LOGF(log, "Error writing function arguments."); diagnostics.Dump(log); } } @@ -1507,17 +1503,18 @@ uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data, if (isa == 0) { if (should_log) - log->Printf( - "AppleObjCRuntimeV2 found NULL isa, ignoring this class info"); + LLDB_LOGF( + log, "AppleObjCRuntimeV2 found NULL isa, ignoring this class info"); continue; } // Check if we already know about this ISA, if we do, the info will never // change, so we can just skip it. if (ISAIsCached(isa)) { if (should_log) - log->Printf("AppleObjCRuntimeV2 found cached isa=0x%" PRIx64 - ", ignoring this class info", - isa); + LLDB_LOGF(log, + "AppleObjCRuntimeV2 found cached isa=0x%" PRIx64 + ", ignoring this class info", + isa); offset += 4; } else { // Read the 32 bit hash for the class name @@ -1536,15 +1533,16 @@ uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data, AddClass(isa, descriptor_sp, descriptor_sp->GetClassName().AsCString(nullptr)); num_parsed++; if (should_log) - log->Printf("AppleObjCRuntimeV2 added isa=0x%" PRIx64 - ", hash=0x%8.8x, name=%s", - isa, name_hash, - descriptor_sp->GetClassName().AsCString("<unknown>")); + LLDB_LOGF(log, + "AppleObjCRuntimeV2 added isa=0x%" PRIx64 + ", hash=0x%8.8x, name=%s", + isa, name_hash, + descriptor_sp->GetClassName().AsCString("<unknown>")); } } if (should_log) - log->Printf("AppleObjCRuntimeV2 parsed %" PRIu32 " class infos", - num_parsed); + LLDB_LOGF(log, "AppleObjCRuntimeV2 parsed %" PRIu32 " class infos", + num_parsed); return num_parsed; } @@ -1646,17 +1644,16 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() { shared_class_expression.c_str(), eLanguageTypeObjC, g_get_shared_cache_class_info_name, error)); if (error.Fail()) { - if (log) - log->Printf( - "Failed to get Utility function for implementation lookup: %s.", - error.AsCString()); + LLDB_LOGF(log, + "Failed to get Utility function for implementation lookup: %s.", + error.AsCString()); m_get_shared_cache_class_info_code.reset(); } else { diagnostics.Clear(); if (!m_get_shared_cache_class_info_code->Install(diagnostics, exe_ctx)) { if (log) { - log->Printf("Failed to install implementation lookup."); + LLDB_LOGF(log, "Failed to install implementation lookup."); diagnostics.Dump(log); } m_get_shared_cache_class_info_code.reset(); @@ -1703,10 +1700,10 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() { class_infos_byte_size, ePermissionsReadable | ePermissionsWritable, err); if (class_infos_addr == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("unable to allocate %" PRIu32 - " bytes in process for shared cache read", - class_infos_byte_size); + LLDB_LOGF(log, + "unable to allocate %" PRIu32 + " bytes in process for shared cache read", + class_infos_byte_size); return DescriptorMapUpdateResult::Fail(); } @@ -1757,9 +1754,8 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() { if (results == eExpressionCompleted) { // The result is the number of ClassInfo structures that were filled in num_class_infos = return_value.GetScalar().ULong(); - if (log) - log->Printf("Discovered %u ObjC classes in shared cache\n", - num_class_infos); + LLDB_LOGF(log, "Discovered %u ObjC classes in shared cache\n", + num_class_infos); assert(num_class_infos <= num_classes); if (num_class_infos > 0) { if (num_class_infos > num_classes) { @@ -1786,13 +1782,13 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() { } } else { if (log) { - log->Printf("Error evaluating our find class name function."); + LLDB_LOGF(log, "Error evaluating our find class name function."); diagnostics.Dump(log); } } } else { if (log) { - log->Printf("Error writing function arguments."); + LLDB_LOGF(log, "Error writing function arguments."); diagnostics.Dump(log); } } @@ -1827,9 +1823,10 @@ bool AppleObjCRuntimeV2::UpdateISAToDescriptorMapFromMemory( new ClassDescriptorV2(*this, elt.second, elt.first.AsCString())); if (log && log->GetVerbose()) - log->Printf("AppleObjCRuntimeV2 added (ObjCISA)0x%" PRIx64 - " (%s) from dynamic table to isa->descriptor cache", - elt.second, elt.first.AsCString()); + LLDB_LOGF(log, + "AppleObjCRuntimeV2 added (ObjCISA)0x%" PRIx64 + " (%s) from dynamic table to isa->descriptor cache", + elt.second, elt.first.AsCString()); AddClass(elt.second, descriptor_sp, elt.first.AsCString()); } @@ -1912,14 +1909,14 @@ void AppleObjCRuntimeV2::UpdateISAToDescriptorMapIfNeeded() { DescriptorMapUpdateResult shared_cache_update_result = UpdateISAToDescriptorMapSharedCache(); - if (log) - log->Printf("attempted to read objc class data - results: " - "[dynamic_update]: ran: %s, count: %" PRIu32 - " [shared_cache_update]: ran: %s, count: %" PRIu32, - dynamic_update_result.m_update_ran ? "yes" : "no", - dynamic_update_result.m_num_found, - shared_cache_update_result.m_update_ran ? "yes" : "no", - shared_cache_update_result.m_num_found); + LLDB_LOGF(log, + "attempted to read objc class data - results: " + "[dynamic_update]: ran: %s, count: %" PRIu32 + " [shared_cache_update]: ran: %s, count: %" PRIu32, + dynamic_update_result.m_update_ran ? "yes" : "no", + dynamic_update_result.m_num_found, + shared_cache_update_result.m_update_ran ? "yes" : "no", + shared_cache_update_result.m_num_found); // warn if: // - we could not run either expression @@ -2516,8 +2513,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( ObjCISA isa, ObjCISA &ret_isa) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES)); - if (log) - log->Printf("AOCRT::NPI Evalulate(isa = 0x%" PRIx64 ")", (uint64_t)isa); + LLDB_LOGF(log, "AOCRT::NPI Evalulate(isa = 0x%" PRIx64 ")", (uint64_t)isa); if ((isa & ~m_objc_debug_isa_class_mask) == 0) return false; @@ -2543,10 +2539,10 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( // read the count again, and update the cache if the count has been // updated. if (index > m_indexed_isa_cache.size()) { - if (log) - log->Printf("AOCRT::NPI (index = %" PRIu64 - ") exceeds cache (size = %" PRIu64 ")", - (uint64_t)index, (uint64_t)m_indexed_isa_cache.size()); + LLDB_LOGF(log, + "AOCRT::NPI (index = %" PRIu64 + ") exceeds cache (size = %" PRIu64 ")", + (uint64_t)index, (uint64_t)m_indexed_isa_cache.size()); Process *process(m_runtime.GetProcess()); @@ -2561,9 +2557,8 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( if (error.Fail()) return false; - if (log) - log->Printf("AOCRT::NPI (new class count = %" PRIu64 ")", - (uint64_t)objc_indexed_classes_count); + LLDB_LOGF(log, "AOCRT::NPI (new class count = %" PRIu64 ")", + (uint64_t)objc_indexed_classes_count); if (objc_indexed_classes_count > m_indexed_isa_cache.size()) { // Read the class entries we don't have. We should just read all of @@ -2581,9 +2576,8 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( if (error.Fail() || bytes_read != buffer.GetByteSize()) return false; - if (log) - log->Printf("AOCRT::NPI (read new classes count = %" PRIu64 ")", - (uint64_t)num_new_classes); + LLDB_LOGF(log, "AOCRT::NPI (read new classes count = %" PRIu64 ")", + (uint64_t)num_new_classes); // Append the new entries to the existing cache. DataExtractor data(buffer.GetBytes(), buffer.GetByteSize(), @@ -2600,9 +2594,8 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA( if (index > m_indexed_isa_cache.size()) return false; - if (log) - log->Printf("AOCRT::NPI Evalulate(ret_isa = 0x%" PRIx64 ")", - (uint64_t)m_indexed_isa_cache[index]); + LLDB_LOGF(log, "AOCRT::NPI Evalulate(ret_isa = 0x%" PRIx64 ")", + (uint64_t)m_indexed_isa_cache[index]); ret_isa = m_indexed_isa_cache[index]; return (ret_isa != 0); // this is a pointer so 0 is not a valid value diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index b3eb09caa86..f46cc1f8522 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -593,7 +593,7 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::ReadRegions( if (log) { StreamString s; m_regions.back().Dump(s); - log->Printf("Read vtable region: \n%s", s.GetData()); + LLDB_LOGF(log, "Read vtable region: \n%s", s.GetData()); } next_region = m_regions.back().GetNextRegionAddr(); @@ -779,25 +779,24 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread, m_lookup_implementation_function_code, eLanguageTypeObjC, g_lookup_implementation_function_name, error)); if (error.Fail()) { - if (log) - log->Printf( - "Failed to get Utility Function for implementation lookup: %s.", - error.AsCString()); + LLDB_LOGF( + log, + "Failed to get Utility Function for implementation lookup: %s.", + error.AsCString()); m_impl_code.reset(); return args_addr; } if (!m_impl_code->Install(diagnostics, exe_ctx)) { if (log) { - log->Printf("Failed to install implementation lookup."); + LLDB_LOGF(log, "Failed to install implementation lookup."); diagnostics.Dump(log); } m_impl_code.reset(); return args_addr; } } else { - if (log) - log->Printf("No method lookup implementation code."); + LLDB_LOGF(log, "No method lookup implementation code."); return LLDB_INVALID_ADDRESS; } @@ -811,10 +810,9 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread, impl_function_caller = m_impl_code->MakeFunctionCaller( clang_void_ptr_type, dispatch_values, thread_sp, error); if (error.Fail()) { - if (log) - log->Printf( - "Error getting function caller for dispatch lookup: \"%s\".", - error.AsCString()); + LLDB_LOGF(log, + "Error getting function caller for dispatch lookup: \"%s\".", + error.AsCString()); return args_addr; } } else { @@ -833,7 +831,7 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread, if (!impl_function_caller->WriteFunctionArguments( exe_ctx, args_addr, dispatch_values, diagnostics)) { if (log) { - log->Printf("Error writing function arguments."); + LLDB_LOGF(log, "Error writing function arguments."); diagnostics.Dump(log); } return args_addr; @@ -934,9 +932,9 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, lldb::addr_t obj_addr = argument_values.GetValueAtIndex(obj_index)->GetScalar().ULongLong(); if (obj_addr == 0x0) { - if (log) - log->Printf( - "Asked to step to dispatch to nil object, returning empty plan."); + LLDB_LOGF( + log, + "Asked to step to dispatch to nil object, returning empty plan."); return ret_plan_sp; } @@ -976,13 +974,11 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, if (super_value.GetScalar().IsValid()) isa_addr = super_value.GetScalar().ULongLong(); else { - if (log) - log->Printf("Failed to extract the super class value from the " - "class in objc_super."); + LLDB_LOGF(log, "Failed to extract the super class value from the " + "class in objc_super."); } } else { - if (log) - log->Printf("Failed to extract the class value from objc_super."); + LLDB_LOGF(log, "Failed to extract the class value from objc_super."); } } else { // In the objc_msgSendSuper case, we don't get the object @@ -998,8 +994,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, if (super_value.GetScalar().IsValid()) { isa_addr = super_value.GetScalar().ULongLong(); } else { - if (log) - log->Printf("Failed to extract the class value from objc_super."); + LLDB_LOGF(log, "Failed to extract the class value from objc_super."); } } } else { @@ -1022,8 +1017,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, if (isa_value.GetScalar().IsValid()) { isa_addr = isa_value.GetScalar().ULongLong(); } else { - if (log) - log->Printf("Failed to extract the isa value from object."); + LLDB_LOGF(log, "Failed to extract the isa value from object."); } } @@ -1033,9 +1027,10 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, if (isa_addr != LLDB_INVALID_ADDRESS) { if (log) { - log->Printf("Resolving call for class - 0x%" PRIx64 - " and selector - 0x%" PRIx64, - isa_addr, sel_addr); + LLDB_LOGF(log, + "Resolving call for class - 0x%" PRIx64 + " and selector - 0x%" PRIx64, + isa_addr, sel_addr); } ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*thread.GetProcess()); @@ -1047,9 +1042,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, if (impl_addr != LLDB_INVALID_ADDRESS) { // Yup, it was in the cache, so we can run to that address directly. - if (log) - log->Printf("Found implementation address in cache: 0x%" PRIx64, - impl_addr); + LLDB_LOGF(log, "Found implementation address in cache: 0x%" PRIx64, + impl_addr); ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(thread, impl_addr, stop_others); @@ -1137,7 +1131,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread, if (log) { StreamString s; ret_plan_sp->GetDescription(&s, eDescriptionLevelFull); - log->Printf("Using ObjC step plan: %s.\n", s.GetData()); + LLDB_LOGF(log, "Using ObjC step plan: %s.\n", s.GetData()); } } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp index d18435c9c6d..af630eee726 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -141,17 +141,15 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) { target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr()); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); if (target_addr == 0) { - if (log) - log->Printf("Got target implementation of 0x0, stopping."); + LLDB_LOGF(log, "Got target implementation of 0x0, stopping."); SetPlanComplete(); return true; } if (m_trampoline_handler->AddrIsMsgForward(target_addr)) { - if (log) - log->Printf( - "Implementation lookup returned msgForward function: 0x%" PRIx64 - ", stopping.", - target_addr); + LLDB_LOGF(log, + "Implementation lookup returned msgForward function: 0x%" PRIx64 + ", stopping.", + target_addr); SymbolContext sc = m_thread.GetStackFrameAtIndex(0)->GetSymbolContext( eSymbolContextEverything); @@ -167,18 +165,17 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) { return false; } - if (log) - log->Printf("Running to ObjC method implementation: 0x%" PRIx64, - target_addr); + LLDB_LOGF(log, "Running to ObjC method implementation: 0x%" PRIx64, + target_addr); ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*GetThread().GetProcess()); assert(objc_runtime != nullptr); objc_runtime->AddToMethodCache(m_isa_addr, m_sel_addr, target_addr); - if (log) - log->Printf("Adding {isa-addr=0x%" PRIx64 ", sel-addr=0x%" PRIx64 - "} = addr=0x%" PRIx64 " to cache.", - m_isa_addr, m_sel_addr, target_addr); + LLDB_LOGF(log, + "Adding {isa-addr=0x%" PRIx64 ", sel-addr=0x%" PRIx64 + "} = addr=0x%" PRIx64 " to cache.", + m_isa_addr, m_sel_addr, target_addr); // Extract the target address from the value: diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp index 631c15c46ce..1e39ff14a89 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp @@ -64,9 +64,10 @@ void ObjCLanguageRuntime::AddToMethodCache(lldb::addr_t class_addr, lldb::addr_t impl_addr) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); if (log) { - log->Printf("Caching: class 0x%" PRIx64 " selector 0x%" PRIx64 - " implementation 0x%" PRIx64 ".", - class_addr, selector, impl_addr); + LLDB_LOGF(log, + "Caching: class 0x%" PRIx64 " selector 0x%" PRIx64 + " implementation 0x%" PRIx64 ".", + class_addr, selector, impl_addr); } m_impl_cache.insert(std::pair<ClassAndSel, lldb::addr_t>( ClassAndSel(class_addr, selector), impl_addr)); diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp index 60549663db6..b396781e672 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp @@ -140,10 +140,10 @@ bool RenderScriptRuntimeModulePass::runOnModule(llvm::Module &module) { // We've been using a triple and datalayout of some ARM variant all along, // so we need to let the backend know that this is no longer the case. if (log) { - log->Printf("%s - Changing RS target triple to '%s'", __FUNCTION__, - real_triple.str().c_str()); - log->Printf( - "%s - Changing RS datalayout to '%s'", __FUNCTION__, + LLDB_LOGF(log, "%s - Changing RS target triple to '%s'", __FUNCTION__, + real_triple.str().c_str()); + LLDB_LOGF( + log, "%s - Changing RS datalayout to '%s'", __FUNCTION__, target_machine->createDataLayout().getStringRepresentation().c_str()); } module.setTargetTriple(real_triple); diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index c9cd34cf379..f45c9b74721 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -138,9 +138,8 @@ bool GetArgsX86(const GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { size_t read = ctx.process->ReadMemory(sp, &arg.value, sizeof(uint32_t), err); if (read != arg_size || !err.Success()) { - if (log) - log->Printf("%s - error reading argument: %" PRIu64 " '%s'", - __FUNCTION__, uint64_t(i), err.AsCString()); + LLDB_LOGF(log, "%s - error reading argument: %" PRIu64 " '%s'", + __FUNCTION__, uint64_t(i), err.AsCString()); return false; } } @@ -173,8 +172,7 @@ bool GetArgsX86_64(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { // check the stack alignment was correct (16 byte aligned) if ((sp & 0xf) != 0x0) { - if (log) - log->Printf("%s - stack misaligned", __FUNCTION__); + LLDB_LOGF(log, "%s - stack misaligned", __FUNCTION__); return false; } @@ -213,9 +211,8 @@ bool GetArgsX86_64(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { } // fail if we couldn't read this argument if (!success) { - if (log) - log->Printf("%s - error reading argument: %" PRIu64 ", reason: %s", - __FUNCTION__, uint64_t(i), err.AsCString("n/a")); + LLDB_LOGF(log, "%s - error reading argument: %" PRIu64 ", reason: %s", + __FUNCTION__, uint64_t(i), err.AsCString("n/a")); return false; } } @@ -258,9 +255,8 @@ bool GetArgsArm(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { } // fail if we couldn't read this argument if (!success) { - if (log) - log->Printf("%s - error reading argument: %" PRIu64 ", reason: %s", - __FUNCTION__, uint64_t(i), err.AsCString("n/a")); + LLDB_LOGF(log, "%s - error reading argument: %" PRIu64 ", reason: %s", + __FUNCTION__, uint64_t(i), err.AsCString("n/a")); return false; } } @@ -285,15 +281,13 @@ bool GetArgsAarch64(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { } // arguments passed on the stack else { - if (log) - log->Printf("%s - reading arguments spilled to stack not implemented", - __FUNCTION__); + LLDB_LOGF(log, "%s - reading arguments spilled to stack not implemented", + __FUNCTION__); } // fail if we couldn't read this argument if (!success) { - if (log) - log->Printf("%s - error reading argument: %" PRIu64, __FUNCTION__, - uint64_t(i)); + LLDB_LOGF(log, "%s - error reading argument: %" PRIu64, __FUNCTION__, + uint64_t(i)); return false; } } @@ -337,9 +331,8 @@ bool GetArgsMipsel(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { } // fail if we couldn't read this argument if (!success) { - if (log) - log->Printf("%s - error reading argument: %" PRIu64 ", reason: %s", - __FUNCTION__, uint64_t(i), err.AsCString("n/a")); + LLDB_LOGF(log, "%s - error reading argument: %" PRIu64 ", reason: %s", + __FUNCTION__, uint64_t(i), err.AsCString("n/a")); return false; } } @@ -385,9 +378,8 @@ bool GetArgsMips64el(GetArgsCtx &ctx, ArgItem *arg_list, size_t num_args) { } // fail if we couldn't read this argument if (!success) { - if (log) - log->Printf("%s - error reading argument: %" PRIu64 ", reason: %s", - __FUNCTION__, uint64_t(i), err.AsCString("n/a")); + LLDB_LOGF(log, "%s - error reading argument: %" PRIu64 ", reason: %s", + __FUNCTION__, uint64_t(i), err.AsCString("n/a")); return false; } } @@ -399,8 +391,7 @@ bool GetArgs(ExecutionContext &exe_ctx, ArgItem *arg_list, size_t num_args) { // verify that we have a target if (!exe_ctx.GetTargetPtr()) { - if (log) - log->Printf("%s - invalid target", __FUNCTION__); + LLDB_LOGF(log, "%s - invalid target", __FUNCTION__); return false; } @@ -430,9 +421,8 @@ bool GetArgs(ExecutionContext &exe_ctx, ArgItem *arg_list, size_t num_args) { default: // unsupported architecture if (log) { - log->Printf( - "%s - architecture not supported: '%s'", __FUNCTION__, - exe_ctx.GetTargetRef().GetArchitecture().GetArchitectureName()); + LLDB_LOGF(log, "%s - architecture not supported: '%s'", __FUNCTION__, + exe_ctx.GetTargetRef().GetArchitecture().GetArchitectureName()); } return false; } @@ -492,9 +482,8 @@ bool SkipPrologue(lldb::ModuleSP &module, Address &addr) { ConstString name = sc.GetFunctionName(); if (offset) addr.Slide(offset); - if (log) - log->Printf("%s: Prologue offset for %s is %" PRIu32, __FUNCTION__, - name.AsCString(), offset); + LLDB_LOGF(log, "%s: Prologue offset for %s is %" PRIu32, __FUNCTION__, + name.AsCString(), offset); } return true; } else @@ -884,14 +873,13 @@ RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter, if (filter.AddressPasses(address)) { bool new_bp; if (!SkipPrologue(module, address)) { - if (log) - log->Printf("%s: Error trying to skip prologue", __FUNCTION__); + LLDB_LOGF(log, "%s: Error trying to skip prologue", __FUNCTION__); } m_breakpoint->AddLocation(address, &new_bp); - if (log) - log->Printf("%s: %s reduction breakpoint on %s in %s", __FUNCTION__, - new_bp ? "new" : "existing", kernel_name.GetCString(), - address.GetModule()->GetFileSpec().GetCString()); + LLDB_LOGF(log, "%s: %s reduction breakpoint on %s in %s", + __FUNCTION__, new_bp ? "new" : "existing", + kernel_name.GetCString(), + address.GetModule()->GetFileSpec().GetCString()); } } } @@ -920,48 +908,43 @@ Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback( for (auto &name : names) { const RSScriptGroupDescriptorSP sg = FindScriptGroup(ConstString(name)); if (!sg) { - if (log) - log->Printf("%s: could not find script group for %s", __FUNCTION__, - name.c_str()); + LLDB_LOGF(log, "%s: could not find script group for %s", __FUNCTION__, + name.c_str()); continue; } - if (log) - log->Printf("%s: Found ScriptGroup for %s", __FUNCTION__, name.c_str()); + LLDB_LOGF(log, "%s: Found ScriptGroup for %s", __FUNCTION__, name.c_str()); for (const RSScriptGroupDescriptor::Kernel &k : sg->m_kernels) { if (log) { - log->Printf("%s: Adding breakpoint for %s", __FUNCTION__, - k.m_name.AsCString()); - log->Printf("%s: Kernel address 0x%" PRIx64, __FUNCTION__, k.m_addr); + LLDB_LOGF(log, "%s: Adding breakpoint for %s", __FUNCTION__, + k.m_name.AsCString()); + LLDB_LOGF(log, "%s: Kernel address 0x%" PRIx64, __FUNCTION__, k.m_addr); } const lldb_private::Symbol *sym = module->FindFirstSymbolWithNameAndType(k.m_name, eSymbolTypeCode); if (!sym) { - if (log) - log->Printf("%s: Unable to find symbol for %s", __FUNCTION__, - k.m_name.AsCString()); + LLDB_LOGF(log, "%s: Unable to find symbol for %s", __FUNCTION__, + k.m_name.AsCString()); continue; } if (log) { - log->Printf("%s: Found symbol name is %s", __FUNCTION__, - sym->GetName().AsCString()); + LLDB_LOGF(log, "%s: Found symbol name is %s", __FUNCTION__, + sym->GetName().AsCString()); } auto address = sym->GetAddress(); if (!SkipPrologue(module, address)) { - if (log) - log->Printf("%s: Error trying to skip prologue", __FUNCTION__); + LLDB_LOGF(log, "%s: Error trying to skip prologue", __FUNCTION__); } bool new_bp; m_breakpoint->AddLocation(address, &new_bp); - if (log) - log->Printf("%s: Placed %sbreakpoint on %s", __FUNCTION__, - new_bp ? "new " : "", k.m_name.AsCString()); + LLDB_LOGF(log, "%s: Placed %sbreakpoint on %s", __FUNCTION__, + new_bp ? "new " : "", k.m_name.AsCString()); // exit after placing the first breakpoint if we do not intend to stop on // all kernels making up this script group @@ -1136,8 +1119,7 @@ void RenderScriptRuntime::HookCallback(RuntimeHook *hook, ExecutionContext &exe_ctx) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); - if (log) - log->Printf("%s - '%s'", __FUNCTION__, hook->defn->name); + LLDB_LOGF(log, "%s - '%s'", __FUNCTION__, hook->defn->name); if (hook->defn->grabber) { (this->*(hook->defn->grabber))(hook, exe_ctx); @@ -1163,19 +1145,18 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( }}; if (!GetArgs(context, args.data(), args.size())) { - if (log) - log->Printf("%s - Error while reading the function parameters", - __FUNCTION__); + LLDB_LOGF(log, "%s - Error while reading the function parameters", + __FUNCTION__); return; } else if (log) { - log->Printf("%s - groupName : 0x%" PRIx64, __FUNCTION__, - addr_t(args[eGroupName])); - log->Printf("%s - groupNameSize: %" PRIu64, __FUNCTION__, - uint64_t(args[eGroupNameSize])); - log->Printf("%s - kernel : 0x%" PRIx64, __FUNCTION__, - addr_t(args[eKernel])); - log->Printf("%s - kernelCount : %" PRIu64, __FUNCTION__, - uint64_t(args[eKernelCount])); + LLDB_LOGF(log, "%s - groupName : 0x%" PRIx64, __FUNCTION__, + addr_t(args[eGroupName])); + LLDB_LOGF(log, "%s - groupNameSize: %" PRIu64, __FUNCTION__, + uint64_t(args[eGroupNameSize])); + LLDB_LOGF(log, "%s - kernel : 0x%" PRIx64, __FUNCTION__, + addr_t(args[eKernel])); + LLDB_LOGF(log, "%s - kernelCount : %" PRIu64, __FUNCTION__, + uint64_t(args[eKernelCount])); } // parse script group name @@ -1187,12 +1168,10 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( m_process->ReadMemory(addr_t(args[eGroupName]), buffer.get(), len, err); buffer.get()[len] = '\0'; if (!err.Success()) { - if (log) - log->Printf("Error reading scriptgroup name from target"); + LLDB_LOGF(log, "Error reading scriptgroup name from target"); return; } else { - if (log) - log->Printf("Extracted scriptgroup name %s", buffer.get()); + LLDB_LOGF(log, "Extracted scriptgroup name %s", buffer.get()); } // write back the script group name group_name.SetCString(buffer.get()); @@ -1214,9 +1193,8 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( m_scriptGroups.push_back(group); } else { // already have this script group - if (log) - log->Printf("Attempt to add duplicate script group %s", - group_name.AsCString()); + LLDB_LOGF(log, "Attempt to add duplicate script group %s", + group_name.AsCString()); return; } } @@ -1234,21 +1212,18 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( size_t read = m_process->ReadMemory(ptr_addr, &kernel_addr, target_ptr_size, err); if (!err.Success() || read != target_ptr_size) { - if (log) - log->Printf("Error parsing kernel address %" PRIu64 " in script group", - i); + LLDB_LOGF(log, "Error parsing kernel address %" PRIu64 " in script group", + i); return; } - if (log) - log->Printf("Extracted scriptgroup kernel address - 0x%" PRIx64, - kernel_addr); + LLDB_LOGF(log, "Extracted scriptgroup kernel address - 0x%" PRIx64, + kernel_addr); kernel.m_addr = kernel_addr; // try to resolve the associated kernel name if (!ResolveKernelName(kernel.m_addr, kernel.m_name)) { - if (log) - log->Printf("Parsed scriptgroup kernel %" PRIu64 " - 0x%" PRIx64, i, - kernel_addr); + LLDB_LOGF(log, "Parsed scriptgroup kernel %" PRIu64 " - 0x%" PRIx64, i, + kernel_addr); return; } @@ -1261,9 +1236,8 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( // verify this function is a valid kernel if (IsKnownKernel(base_kernel)) { kernel.m_name = base_kernel; - if (log) - log->Printf("%s - found non expand version '%s'", __FUNCTION__, - base_kernel.GetCString()); + LLDB_LOGF(log, "%s - found non expand version '%s'", __FUNCTION__, + base_kernel.GetCString()); } } } @@ -1276,15 +1250,13 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2( Target &target = m_process->GetTarget(); const BreakpointList &list = target.GetBreakpointList(); const size_t num_breakpoints = list.GetSize(); - if (log) - log->Printf("Resolving %zu breakpoints", num_breakpoints); + LLDB_LOGF(log, "Resolving %zu breakpoints", num_breakpoints); for (size_t i = 0; i < num_breakpoints; ++i) { const BreakpointSP bp = list.GetBreakpointAtIndex(i); if (bp) { if (bp->MatchesName(group_name.AsCString())) { - if (log) - log->Printf("Found breakpoint with name %s", - group_name.AsCString()); + LLDB_LOGF(log, "Found breakpoint with name %s", + group_name.AsCString()); bp->ResolveBreakpoint(); } } @@ -1322,9 +1294,8 @@ void RenderScriptRuntime::CaptureScriptInvokeForEachMulti( bool success = GetArgs(exe_ctx, &args[0], args.size()); if (!success) { - if (log) - log->Printf("%s - Error while reading the function parameters", - __FUNCTION__); + LLDB_LOGF(log, "%s - Error while reading the function parameters", + __FUNCTION__); return; } @@ -1342,10 +1313,9 @@ void RenderScriptRuntime::CaptureScriptInvokeForEachMulti( uint64_t result = 0; size_t read = m_process->ReadMemory(addr, &result, target_ptr_size, err); if (read != target_ptr_size || !err.Success()) { - if (log) - log->Printf( - "%s - Error while reading allocation list argument %" PRIu64, - __FUNCTION__, i); + LLDB_LOGF(log, + "%s - Error while reading allocation list argument %" PRIu64, + __FUNCTION__, i); } else { allocs.push_back(result); } @@ -1375,8 +1345,8 @@ void RenderScriptRuntime::CaptureScriptInvokeForEachMulti( if (log) { if (alloc->context.isValid() && *alloc->context.get() != addr_t(args[eRsContext])) - log->Printf("%s - Allocation used by multiple contexts", - __FUNCTION__); + LLDB_LOGF(log, "%s - Allocation used by multiple contexts", + __FUNCTION__); } alloc->context = addr_t(args[eRsContext]); } @@ -1388,7 +1358,7 @@ void RenderScriptRuntime::CaptureScriptInvokeForEachMulti( if (log) { if (script->context.isValid() && *script->context.get() != addr_t(args[eRsContext])) - log->Printf("%s - Script used by multiple contexts", __FUNCTION__); + LLDB_LOGF(log, "%s - Script used by multiple contexts", __FUNCTION__); } script->context = addr_t(args[eRsContext]); } @@ -1416,26 +1386,26 @@ void RenderScriptRuntime::CaptureSetGlobalVar(RuntimeHook *hook, bool success = GetArgs(context, &args[0], args.size()); if (!success) { - if (log) - log->Printf("%s - error reading the function parameters.", __FUNCTION__); + LLDB_LOGF(log, "%s - error reading the function parameters.", __FUNCTION__); return; } if (log) { - log->Printf("%s - 0x%" PRIx64 ",0x%" PRIx64 " slot %" PRIu64 " = 0x%" PRIx64 - ":%" PRIu64 "bytes.", - __FUNCTION__, uint64_t(args[eRsContext]), - uint64_t(args[eRsScript]), uint64_t(args[eRsId]), - uint64_t(args[eRsData]), uint64_t(args[eRsLength])); + LLDB_LOGF(log, + "%s - 0x%" PRIx64 ",0x%" PRIx64 " slot %" PRIu64 " = 0x%" PRIx64 + ":%" PRIu64 "bytes.", + __FUNCTION__, uint64_t(args[eRsContext]), + uint64_t(args[eRsScript]), uint64_t(args[eRsId]), + uint64_t(args[eRsData]), uint64_t(args[eRsLength])); addr_t script_addr = addr_t(args[eRsScript]); if (m_scriptMappings.find(script_addr) != m_scriptMappings.end()) { auto rsm = m_scriptMappings[script_addr]; if (uint64_t(args[eRsId]) < rsm->m_globals.size()) { auto rsg = rsm->m_globals[uint64_t(args[eRsId])]; - log->Printf("%s - Setting of '%s' within '%s' inferred", __FUNCTION__, - rsg.m_name.AsCString(), - rsm->m_module->GetFileSpec().GetFilename().AsCString()); + LLDB_LOGF(log, "%s - Setting of '%s' within '%s' inferred", + __FUNCTION__, rsg.m_name.AsCString(), + rsm->m_module->GetFileSpec().GetFilename().AsCString()); } } } @@ -1455,16 +1425,14 @@ void RenderScriptRuntime::CaptureAllocationInit(RuntimeHook *hook, bool success = GetArgs(exe_ctx, &args[0], args.size()); if (!success) { - if (log) - log->Printf("%s - error while reading the function parameters", - __FUNCTION__); + LLDB_LOGF(log, "%s - error while reading the function parameters", + __FUNCTION__); return; } - if (log) - log->Printf("%s - 0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 " .", - __FUNCTION__, uint64_t(args[eRsContext]), - uint64_t(args[eRsAlloc]), uint64_t(args[eRsForceZero])); + LLDB_LOGF(log, "%s - 0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 " .", + __FUNCTION__, uint64_t(args[eRsContext]), uint64_t(args[eRsAlloc]), + uint64_t(args[eRsForceZero])); AllocationDetails *alloc = CreateAllocation(uint64_t(args[eRsAlloc])); if (alloc) @@ -1487,29 +1455,25 @@ void RenderScriptRuntime::CaptureAllocationDestroy(RuntimeHook *hook, bool success = GetArgs(exe_ctx, &args[0], args.size()); if (!success) { - if (log) - log->Printf("%s - error while reading the function parameters.", - __FUNCTION__); + LLDB_LOGF(log, "%s - error while reading the function parameters.", + __FUNCTION__); return; } - if (log) - log->Printf("%s - 0x%" PRIx64 ", 0x%" PRIx64 ".", __FUNCTION__, - uint64_t(args[eRsContext]), uint64_t(args[eRsAlloc])); + LLDB_LOGF(log, "%s - 0x%" PRIx64 ", 0x%" PRIx64 ".", __FUNCTION__, + uint64_t(args[eRsContext]), uint64_t(args[eRsAlloc])); for (auto iter = m_allocations.begin(); iter != m_allocations.end(); ++iter) { auto &allocation_up = *iter; // get the unique pointer if (allocation_up->address.isValid() && *allocation_up->address.get() == addr_t(args[eRsAlloc])) { m_allocations.erase(iter); - if (log) - log->Printf("%s - deleted allocation entry.", __FUNCTION__); + LLDB_LOGF(log, "%s - deleted allocation entry.", __FUNCTION__); return; } } - if (log) - log->Printf("%s - couldn't find destroyed allocation.", __FUNCTION__); + LLDB_LOGF(log, "%s - couldn't find destroyed allocation.", __FUNCTION__); } void RenderScriptRuntime::CaptureScriptInit(RuntimeHook *hook, @@ -1526,32 +1490,28 @@ void RenderScriptRuntime::CaptureScriptInit(RuntimeHook *hook, ArgItem{ArgItem::ePointer, 0}, ArgItem{ArgItem::ePointer, 0}}}; bool success = GetArgs(exe_ctx, &args[0], args.size()); if (!success) { - if (log) - log->Printf("%s - error while reading the function parameters.", - __FUNCTION__); + LLDB_LOGF(log, "%s - error while reading the function parameters.", + __FUNCTION__); return; } std::string res_name; process->ReadCStringFromMemory(addr_t(args[eRsResNamePtr]), res_name, err); if (err.Fail()) { - if (log) - log->Printf("%s - error reading res_name: %s.", __FUNCTION__, - err.AsCString()); + LLDB_LOGF(log, "%s - error reading res_name: %s.", __FUNCTION__, + err.AsCString()); } std::string cache_dir; process->ReadCStringFromMemory(addr_t(args[eRsCachedDirPtr]), cache_dir, err); if (err.Fail()) { - if (log) - log->Printf("%s - error reading cache_dir: %s.", __FUNCTION__, - err.AsCString()); + LLDB_LOGF(log, "%s - error reading cache_dir: %s.", __FUNCTION__, + err.AsCString()); } - if (log) - log->Printf("%s - 0x%" PRIx64 ",0x%" PRIx64 " => '%s' at '%s' .", - __FUNCTION__, uint64_t(args[eRsContext]), - uint64_t(args[eRsScript]), res_name.c_str(), cache_dir.c_str()); + LLDB_LOGF(log, "%s - 0x%" PRIx64 ",0x%" PRIx64 " => '%s' at '%s' .", + __FUNCTION__, uint64_t(args[eRsContext]), uint64_t(args[eRsScript]), + res_name.c_str(), cache_dir.c_str()); if (res_name.size() > 0) { StreamString strm; @@ -1566,13 +1526,14 @@ void RenderScriptRuntime::CaptureScriptInit(RuntimeHook *hook, script->context = addr_t(args[eRsContext]); } - if (log) - log->Printf("%s - '%s' tagged with context 0x%" PRIx64 - " and script 0x%" PRIx64 ".", - __FUNCTION__, strm.GetData(), uint64_t(args[eRsContext]), - uint64_t(args[eRsScript])); + LLDB_LOGF(log, + "%s - '%s' tagged with context 0x%" PRIx64 + " and script 0x%" PRIx64 ".", + __FUNCTION__, strm.GetData(), uint64_t(args[eRsContext]), + uint64_t(args[eRsScript])); } else if (log) { - log->Printf("%s - resource name invalid, Script not tagged.", __FUNCTION__); + LLDB_LOGF(log, "%s - resource name invalid, Script not tagged.", + __FUNCTION__); } } @@ -1593,8 +1554,7 @@ void RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, machine != llvm::Triple::ArchType::mipsel && machine != llvm::Triple::ArchType::mips64el && machine != llvm::Triple::ArchType::x86_64) { - if (log) - log->Printf("%s - unable to hook runtime functions.", __FUNCTION__); + LLDB_LOGF(log, "%s - unable to hook runtime functions.", __FUNCTION__); return; } @@ -1618,23 +1578,22 @@ void RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, ConstString(symbol_name), eSymbolTypeCode); if (!sym) { if (log) { - log->Printf("%s - symbol '%s' related to the function %s not found", - __FUNCTION__, symbol_name, hook_defn->name); + LLDB_LOGF(log, "%s - symbol '%s' related to the function %s not found", + __FUNCTION__, symbol_name, hook_defn->name); } continue; } addr_t addr = sym->GetLoadAddress(&target); if (addr == LLDB_INVALID_ADDRESS) { - if (log) - log->Printf("%s - unable to resolve the address of hook function '%s' " - "with symbol '%s'.", - __FUNCTION__, hook_defn->name, symbol_name); + LLDB_LOGF(log, + "%s - unable to resolve the address of hook function '%s' " + "with symbol '%s'.", + __FUNCTION__, hook_defn->name, symbol_name); continue; } else { - if (log) - log->Printf("%s - function %s, address resolved at 0x%" PRIx64, - __FUNCTION__, hook_defn->name, addr); + LLDB_LOGF(log, "%s - function %s, address resolved at 0x%" PRIx64, + __FUNCTION__, hook_defn->name, addr); } RuntimeHookSP hook(new RuntimeHook()); @@ -1644,11 +1603,12 @@ void RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, hook->bp_sp->SetCallback(HookCallback, hook.get(), true); m_runtimeHooks[addr] = hook; if (log) { - log->Printf("%s - successfully hooked '%s' in '%s' version %" PRIu64 - " at 0x%" PRIx64 ".", - __FUNCTION__, hook_defn->name, - module->GetFileSpec().GetFilename().AsCString(), - (uint64_t)hook_defn->version, (uint64_t)addr); + LLDB_LOGF(log, + "%s - successfully hooked '%s' in '%s' version %" PRIu64 + " at 0x%" PRIx64 ".", + __FUNCTION__, hook_defn->name, + module->GetFileSpec().GetFilename().AsCString(), + (uint64_t)hook_defn->version, (uint64_t)addr); } hook_placed[idx] = true; } @@ -1661,8 +1621,8 @@ void RenderScriptRuntime::LoadRuntimeHooks(lldb::ModuleSP module, const HookDefn &hook_defn = s_runtimeHookDefns[i]; if (hook_defn.kind != kind) continue; - log->Printf("%s - function %s was not hooked", __FUNCTION__, - hook_defn.name); + LLDB_LOGF(log, "%s - function %s was not hooked", __FUNCTION__, + hook_defn.name); } } } @@ -1697,11 +1657,11 @@ void RenderScriptRuntime::FixupScriptDetails(RSModuleDescriptorSP rsmodule_sp) { if (m_scriptMappings.find(script) != m_scriptMappings.end()) { // if the module we have stored is different to the one we just received. if (m_scriptMappings[script] != rsmodule_sp) { - if (log) - log->Printf( - "%s - script %" PRIx64 " wants reassigned to new rsmodule '%s'.", - __FUNCTION__, (uint64_t)script, - rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString()); + LLDB_LOGF( + log, + "%s - script %" PRIx64 " wants reassigned to new rsmodule '%s'.", + __FUNCTION__, (uint64_t)script, + rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString()); } } // We don't have a script mapping for the current script. @@ -1713,11 +1673,9 @@ void RenderScriptRuntime::FixupScriptDetails(RSModuleDescriptorSP rsmodule_sp) { rsmodule_sp->m_resname = res_name; // Add Script/Module pair to map. m_scriptMappings[script] = rsmodule_sp; - if (log) - log->Printf( - "%s - script %" PRIx64 " associated with rsmodule '%s'.", - __FUNCTION__, (uint64_t)script, - rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString()); + LLDB_LOGF(log, "%s - script %" PRIx64 " associated with rsmodule '%s'.", + __FUNCTION__, (uint64_t)script, + rsmodule_sp->m_module->GetFileSpec().GetFilename().AsCString()); } } } @@ -1730,8 +1688,7 @@ bool RenderScriptRuntime::EvalRSExpression(const char *expr, StackFrame *frame_ptr, uint64_t *result) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); - if (log) - log->Printf("%s(%s)", __FUNCTION__, expr); + LLDB_LOGF(log, "%s(%s)", __FUNCTION__, expr); ValueObjectSP expr_result; EvaluateExpressionOptions options; @@ -1741,8 +1698,7 @@ bool RenderScriptRuntime::EvalRSExpression(const char *expr, target.EvaluateExpression(expr, frame_ptr, expr_result, options); if (!expr_result) { - if (log) - log->Printf("%s: couldn't evaluate expression.", __FUNCTION__); + LLDB_LOGF(log, "%s: couldn't evaluate expression.", __FUNCTION__); return false; } @@ -1751,16 +1707,14 @@ bool RenderScriptRuntime::EvalRSExpression(const char *expr, Status err = expr_result->GetError(); // Expression returned is void, so this is actually a success if (err.GetError() == UserExpression::kNoResult) { - if (log) - log->Printf("%s - expression returned void.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression returned void.", __FUNCTION__); result = nullptr; return true; } - if (log) - log->Printf("%s - error evaluating expression result: %s", __FUNCTION__, - err.AsCString()); + LLDB_LOGF(log, "%s - error evaluating expression result: %s", __FUNCTION__, + err.AsCString()); return false; } @@ -1769,9 +1723,8 @@ bool RenderScriptRuntime::EvalRSExpression(const char *expr, *result = expr_result->GetValueAsUnsigned(0, &success); if (!success) { - if (log) - log->Printf("%s - couldn't convert expression result to uint32_t", - __FUNCTION__); + LLDB_LOGF(log, "%s - couldn't convert expression result to uint32_t", + __FUNCTION__); return false; } @@ -1884,8 +1837,7 @@ bool RenderScriptRuntime::JITDataPointer(AllocationDetails *alloc, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!alloc->address.isValid()) { - if (log) - log->Printf("%s - failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - failed to find allocation details.", __FUNCTION__); return false; } @@ -1895,12 +1847,10 @@ bool RenderScriptRuntime::JITDataPointer(AllocationDetails *alloc, int written = snprintf(expr_buf, jit_max_expr_size, fmt_str, *alloc->address.get(), x, y, z); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -1922,8 +1872,7 @@ bool RenderScriptRuntime::JITTypePointer(AllocationDetails *alloc, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!alloc->address.isValid() || !alloc->context.isValid()) { - if (log) - log->Printf("%s - failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - failed to find allocation details.", __FUNCTION__); return false; } @@ -1933,12 +1882,10 @@ bool RenderScriptRuntime::JITTypePointer(AllocationDetails *alloc, int written = snprintf(expr_buf, jit_max_expr_size, fmt_str, *alloc->context.get(), *alloc->address.get()); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -1960,8 +1907,7 @@ bool RenderScriptRuntime::JITTypePacked(AllocationDetails *alloc, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!alloc->type_ptr.isValid() || !alloc->context.isValid()) { - if (log) - log->Printf("%s - Failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - Failed to find allocation details.", __FUNCTION__); return false; } @@ -1983,12 +1929,10 @@ bool RenderScriptRuntime::JITTypePacked(AllocationDetails *alloc, int written = snprintf(expr_bufs[i], jit_max_expr_size, fmt_str, *alloc->context.get(), bits, *alloc->type_ptr.get()); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -2007,10 +1951,10 @@ bool RenderScriptRuntime::JITTypePacked(AllocationDetails *alloc, addr_t element_ptr = static_cast<lldb::addr_t>(results[3]); alloc->element.element_ptr = element_ptr; - if (log) - log->Printf("%s - dims (%" PRIu32 ", %" PRIu32 ", %" PRIu32 - ") Element*: 0x%" PRIx64 ".", - __FUNCTION__, dims.dim_1, dims.dim_2, dims.dim_3, element_ptr); + LLDB_LOGF(log, + "%s - dims (%" PRIu32 ", %" PRIu32 ", %" PRIu32 + ") Element*: 0x%" PRIx64 ".", + __FUNCTION__, dims.dim_1, dims.dim_2, dims.dim_3, element_ptr); return true; } @@ -2024,8 +1968,7 @@ bool RenderScriptRuntime::JITElementPacked(Element &elem, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!elem.element_ptr.isValid()) { - if (log) - log->Printf("%s - failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - failed to find allocation details.", __FUNCTION__); return false; } @@ -2042,12 +1985,10 @@ bool RenderScriptRuntime::JITElementPacked(Element &elem, int written = snprintf(expr_bufs[i], jit_max_expr_size, fmt_str, context, *elem.element_ptr.get()); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -2063,11 +2004,11 @@ bool RenderScriptRuntime::JITElementPacked(Element &elem, elem.type_vec_size = static_cast<uint32_t>(results[2]); elem.field_count = static_cast<uint32_t>(results[3]); - if (log) - log->Printf("%s - data type %" PRIu32 ", pixel type %" PRIu32 - ", vector size %" PRIu32 ", field count %" PRIu32, - __FUNCTION__, *elem.type.get(), *elem.type_kind.get(), - *elem.type_vec_size.get(), *elem.field_count.get()); + LLDB_LOGF(log, + "%s - data type %" PRIu32 ", pixel type %" PRIu32 + ", vector size %" PRIu32 ", field count %" PRIu32, + __FUNCTION__, *elem.type.get(), *elem.type_kind.get(), + *elem.type_vec_size.get(), *elem.field_count.get()); // If this Element has subelements then JIT rsaElementGetSubElements() for // details about its fields @@ -2084,8 +2025,7 @@ bool RenderScriptRuntime::JITSubelements(Element &elem, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!elem.element_ptr.isValid() || !elem.field_count.isValid()) { - if (log) - log->Printf("%s - failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - failed to find allocation details.", __FUNCTION__); return false; } @@ -2107,12 +2047,10 @@ bool RenderScriptRuntime::JITSubelements(Element &elem, context, field_count, field_count, field_count, *elem.element_ptr.get(), field_count, field_index); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -2120,8 +2058,7 @@ bool RenderScriptRuntime::JITSubelements(Element &elem, if (!EvalRSExpression(expr_buffer, frame_ptr, &results)) return false; - if (log) - log->Printf("%s - expr result 0x%" PRIx64 ".", __FUNCTION__, results); + LLDB_LOGF(log, "%s - expr result 0x%" PRIx64 ".", __FUNCTION__, results); switch (expr_index) { case 0: // Element* of child @@ -2136,9 +2073,8 @@ bool RenderScriptRuntime::JITSubelements(Element &elem, if (!err.Fail()) child.type_name = ConstString(name); else { - if (log) - log->Printf("%s - warning: Couldn't read field name.", - __FUNCTION__); + LLDB_LOGF(log, "%s - warning: Couldn't read field name.", + __FUNCTION__); } break; } @@ -2173,8 +2109,7 @@ bool RenderScriptRuntime::JITAllocationSize(AllocationDetails *alloc, if (!alloc->address.isValid() || !alloc->dimension.isValid() || !alloc->data_ptr.isValid() || !alloc->element.datum_size.isValid()) { - if (log) - log->Printf("%s - failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - failed to find allocation details.", __FUNCTION__); return false; } @@ -2196,9 +2131,8 @@ bool RenderScriptRuntime::JITAllocationSize(AllocationDetails *alloc, alloc->size = dim_x * dim_y * dim_z * *alloc->element.datum_size.get(); - if (log) - log->Printf("%s - inferred size of struct allocation %" PRIu32 ".", - __FUNCTION__, *alloc->size.get()); + LLDB_LOGF(log, "%s - inferred size of struct allocation %" PRIu32 ".", + __FUNCTION__, *alloc->size.get()); return true; } @@ -2213,12 +2147,10 @@ bool RenderScriptRuntime::JITAllocationSize(AllocationDetails *alloc, int written = snprintf(expr_buf, jit_max_expr_size, fmt_str, *alloc->address.get(), dim_x, dim_y, dim_z); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -2242,8 +2174,7 @@ bool RenderScriptRuntime::JITAllocationStride(AllocationDetails *alloc, Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!alloc->address.isValid() || !alloc->data_ptr.isValid()) { - if (log) - log->Printf("%s - failed to find allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - failed to find allocation details.", __FUNCTION__); return false; } @@ -2253,12 +2184,10 @@ bool RenderScriptRuntime::JITAllocationStride(AllocationDetails *alloc, int written = snprintf(expr_buf, jit_max_expr_size, fmt_str, *alloc->address.get(), 0, 1, 0); if (written < 0) { - if (log) - log->Printf("%s - encoding error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - encoding error in snprintf().", __FUNCTION__); return false; } else if (written >= jit_max_expr_size) { - if (log) - log->Printf("%s - expression too long.", __FUNCTION__); + LLDB_LOGF(log, "%s - expression too long.", __FUNCTION__); return false; } @@ -2354,9 +2283,8 @@ void RenderScriptRuntime::FindStructTypeName(Element &elem, // '#rs_padding_[0-9]+' if (found && num_children < elem.children.size()) { const uint32_t size_diff = elem.children.size() - num_children; - if (log) - log->Printf("%s - %" PRIu32 " padding struct entries", __FUNCTION__, - size_diff); + LLDB_LOGF(log, "%s - %" PRIu32 " padding struct entries", __FUNCTION__, + size_diff); for (uint32_t i = 0; i < size_diff; ++i) { ConstString name = elem.children[num_children + i].type_name; @@ -2377,9 +2305,8 @@ void RenderScriptRuntime::FindStructTypeName(Element &elem, // Save name of variable in Element. elem.type_name = valobj_sp->GetTypeName(); - if (log) - log->Printf("%s - element name set to %s", __FUNCTION__, - elem.type_name.AsCString()); + LLDB_LOGF(log, "%s - element name set to %s", __FUNCTION__, + elem.type_name.AsCString()); return; } @@ -2424,9 +2351,8 @@ void RenderScriptRuntime::SetElementSize(Element &elem) { elem.padding = padding; elem.datum_size = data_size + padding; - if (log) - log->Printf("%s - element size set to %" PRIu32, __FUNCTION__, - data_size + padding); + LLDB_LOGF(log, "%s - element size set to %" PRIu32, __FUNCTION__, + data_size + padding); } // Given an allocation, this function copies the allocation contents from @@ -2439,13 +2365,11 @@ RenderScriptRuntime::GetAllocationData(AllocationDetails *alloc, // JIT all the allocation details if (alloc->ShouldRefresh()) { - if (log) - log->Printf("%s - allocation details not calculated yet, jitting info", - __FUNCTION__); + LLDB_LOGF(log, "%s - allocation details not calculated yet, jitting info", + __FUNCTION__); if (!RefreshAllocation(alloc, frame_ptr)) { - if (log) - log->Printf("%s - couldn't JIT allocation details", __FUNCTION__); + LLDB_LOGF(log, "%s - couldn't JIT allocation details", __FUNCTION__); return nullptr; } } @@ -2458,9 +2382,8 @@ RenderScriptRuntime::GetAllocationData(AllocationDetails *alloc, const uint32_t size = *alloc->size.get(); std::shared_ptr<uint8_t> buffer(new uint8_t[size]); if (!buffer) { - if (log) - log->Printf("%s - couldn't allocate a %" PRIu32 " byte buffer", - __FUNCTION__, size); + LLDB_LOGF(log, "%s - couldn't allocate a %" PRIu32 " byte buffer", + __FUNCTION__, size); return nullptr; } @@ -2469,10 +2392,10 @@ RenderScriptRuntime::GetAllocationData(AllocationDetails *alloc, lldb::addr_t data_ptr = *alloc->data_ptr.get(); GetProcess()->ReadMemory(data_ptr, buffer.get(), size, err); if (err.Fail()) { - if (log) - log->Printf("%s - '%s' Couldn't read %" PRIu32 - " bytes of allocation data from 0x%" PRIx64, - __FUNCTION__, err.AsCString(), size, data_ptr); + LLDB_LOGF(log, + "%s - '%s' Couldn't read %" PRIu32 + " bytes of allocation data from 0x%" PRIx64, + __FUNCTION__, err.AsCString(), size, data_ptr); return nullptr; } @@ -2493,19 +2416,16 @@ bool RenderScriptRuntime::LoadAllocation(Stream &strm, const uint32_t alloc_id, if (!alloc) return false; - if (log) - log->Printf("%s - found allocation 0x%" PRIx64, __FUNCTION__, - *alloc->address.get()); + LLDB_LOGF(log, "%s - found allocation 0x%" PRIx64, __FUNCTION__, + *alloc->address.get()); // JIT all the allocation details if (alloc->ShouldRefresh()) { - if (log) - log->Printf("%s - allocation details not calculated yet, jitting info.", - __FUNCTION__); + LLDB_LOGF(log, "%s - allocation details not calculated yet, jitting info.", + __FUNCTION__); if (!RefreshAllocation(alloc, frame_ptr)) { - if (log) - log->Printf("%s - couldn't JIT allocation details", __FUNCTION__); + LLDB_LOGF(log, "%s - couldn't JIT allocation details", __FUNCTION__); return false; } } @@ -2559,9 +2479,8 @@ bool RenderScriptRuntime::LoadAllocation(Stream &strm, const uint32_t alloc_id, sizeof(AllocationDetails::FileHeader), sizeof(AllocationDetails::ElementHeader)); - if (log) - log->Printf("%s - header type %" PRIu32 ", element size %" PRIu32, - __FUNCTION__, root_el_hdr.type, root_el_hdr.element_size); + LLDB_LOGF(log, "%s - header type %" PRIu32 ", element size %" PRIu32, + __FUNCTION__, root_el_hdr.type, root_el_hdr.element_size); // Check if the target allocation and file both have the same number of bytes // for an Element @@ -2717,19 +2636,16 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id, if (!alloc) return false; - if (log) - log->Printf("%s - found allocation 0x%" PRIx64 ".", __FUNCTION__, - *alloc->address.get()); + LLDB_LOGF(log, "%s - found allocation 0x%" PRIx64 ".", __FUNCTION__, + *alloc->address.get()); // JIT all the allocation details if (alloc->ShouldRefresh()) { - if (log) - log->Printf("%s - allocation details not calculated yet, jitting info.", - __FUNCTION__); + LLDB_LOGF(log, "%s - allocation details not calculated yet, jitting info.", + __FUNCTION__); if (!RefreshAllocation(alloc, frame_ptr)) { - if (log) - log->Printf("%s - couldn't JIT allocation details.", __FUNCTION__); + LLDB_LOGF(log, "%s - couldn't JIT allocation details.", __FUNCTION__); return false; } } @@ -2779,9 +2695,8 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id, // Write the file header size_t num_bytes = sizeof(AllocationDetails::FileHeader); - if (log) - log->Printf("%s - writing File Header, 0x%" PRIx64 " bytes", __FUNCTION__, - (uint64_t)num_bytes); + LLDB_LOGF(log, "%s - writing File Header, 0x%" PRIx64 " bytes", __FUNCTION__, + (uint64_t)num_bytes); Status err = file.Write(&head, num_bytes); if (!err.Success()) { @@ -2805,9 +2720,8 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id, // Write headers for allocation element type to file num_bytes = element_header_size; - if (log) - log->Printf("%s - writing element headers, 0x%" PRIx64 " bytes.", - __FUNCTION__, (uint64_t)num_bytes); + LLDB_LOGF(log, "%s - writing element headers, 0x%" PRIx64 " bytes.", + __FUNCTION__, (uint64_t)num_bytes); err = file.Write(element_header_buffer.get(), num_bytes); if (!err.Success()) { @@ -2818,9 +2732,8 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id, // Write allocation data to file num_bytes = static_cast<size_t>(*alloc->size.get()); - if (log) - log->Printf("%s - writing 0x%" PRIx64 " bytes", __FUNCTION__, - (uint64_t)num_bytes); + LLDB_LOGF(log, "%s - writing 0x%" PRIx64 " bytes", __FUNCTION__, + (uint64_t)num_bytes); err = file.Write(buffer.get(), num_bytes); if (!err.Success()) { @@ -2894,17 +2807,17 @@ bool RenderScriptRuntime::LoadModule(const lldb::ModuleSP &module_sp) { addr_t addr = debug_present->GetLoadAddress(&target); GetProcess()->WriteMemory(addr, &flag, sizeof(flag), err); if (err.Success()) { - if (log) - log->Printf("%s - debugger present flag set on debugee.", - __FUNCTION__); + LLDB_LOGF(log, "%s - debugger present flag set on debugee.", + __FUNCTION__); m_debuggerPresentFlagged = true; } else if (log) { - log->Printf("%s - error writing debugger present flags '%s' ", - __FUNCTION__, err.AsCString()); + LLDB_LOGF(log, "%s - error writing debugger present flags '%s' ", + __FUNCTION__, err.AsCString()); } } else if (log) { - log->Printf( + LLDB_LOGF( + log, "%s - error writing debugger present flags - symbol not found", __FUNCTION__); } @@ -3004,8 +2917,7 @@ bool RSModuleDescriptor::ParseExportReduceCount(llvm::StringRef *lines, return false; } - if (log) - log->Printf("Found RenderScript reduction '%s'", spec[2].str().c_str()); + LLDB_LOGF(log, "Found RenderScript reduction '%s'", spec[2].str().c_str()); m_reductions.push_back(RSReductionDescriptor(this, sig, accum_data_size, spec[2], spec[3], spec[4], @@ -3082,10 +2994,8 @@ bool RSModuleDescriptor::ParseRSInfo() { { const llvm::StringRef raw_rs_info((const char *)buffer->GetBytes()); raw_rs_info.split(info_lines, '\n'); - if (log) - log->Printf("'.rs.info symbol for '%s':\n%s", - m_module->GetFileSpec().GetCString(), - raw_rs_info.str().c_str()); + LLDB_LOGF(log, "'.rs.info symbol for '%s':\n%s", + m_module->GetFileSpec().GetCString(), raw_rs_info.str().c_str()); } enum { @@ -3153,9 +3063,8 @@ bool RSModuleDescriptor::ParseRSInfo() { success = ParseVersionInfo(line, n_lines); break; default: { - if (log) - log->Printf("%s - skipping .rs.info field '%s'", __FUNCTION__, - line->str().c_str()); + LLDB_LOGF(log, "%s - skipping .rs.info field '%s'", __FUNCTION__, + line->str().c_str()); continue; } } @@ -3276,15 +3185,13 @@ bool RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame *frame_ptr, if (!alloc) return false; // FindAllocByID() will print error message for us here - if (log) - log->Printf("%s - found allocation 0x%" PRIx64, __FUNCTION__, - *alloc->address.get()); + LLDB_LOGF(log, "%s - found allocation 0x%" PRIx64, __FUNCTION__, + *alloc->address.get()); // Check we have information about the allocation, if not calculate it if (alloc->ShouldRefresh()) { - if (log) - log->Printf("%s - allocation details not calculated yet, jitting info.", - __FUNCTION__); + LLDB_LOGF(log, "%s - allocation details not calculated yet, jitting info.", + __FUNCTION__); // JIT all the allocation information if (!RefreshAllocation(alloc, frame_ptr)) { @@ -3313,9 +3220,8 @@ bool RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame *frame_ptr, const uint32_t data_size = *alloc->element.datum_size.get(); - if (log) - log->Printf("%s - element size %" PRIu32 " bytes, including padding", - __FUNCTION__, data_size); + LLDB_LOGF(log, "%s - element size %" PRIu32 " bytes, including padding", + __FUNCTION__, data_size); // Allocate a buffer to copy data into std::shared_ptr<uint8_t> buffer = GetAllocationData(alloc, frame_ptr); @@ -3340,10 +3246,10 @@ bool RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame *frame_ptr, const uint32_t size = *alloc->size.get(); // Size of whole allocation const uint32_t padding = alloc->element.padding.isValid() ? *alloc->element.padding.get() : 0; - if (log) - log->Printf("%s - stride %" PRIu32 " bytes, size %" PRIu32 - " bytes, padding %" PRIu32, - __FUNCTION__, stride, size, padding); + LLDB_LOGF(log, + "%s - stride %" PRIu32 " bytes, size %" PRIu32 + " bytes, padding %" PRIu32, + __FUNCTION__, stride, size, padding); // Find dimensions used to index loops, so need to be non-zero uint32_t dim_x = alloc->dimension.get()->dim_1; @@ -3395,8 +3301,7 @@ bool RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame *frame_ptr, *alloc->data_ptr.get() + offset); if (written < 0 || written >= jit_max_expr_size) { - if (log) - log->Printf("%s - error in snprintf().", __FUNCTION__); + LLDB_LOGF(log, "%s - error in snprintf().", __FUNCTION__); continue; } @@ -3573,17 +3478,16 @@ void RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target) { for (const auto &module : m_rsmodules) BreakOnModuleKernels(module); - if (log) - log->Printf("%s(True) - breakpoints set on all currently loaded kernels.", - __FUNCTION__); + LLDB_LOGF(log, + "%s(True) - breakpoints set on all currently loaded kernels.", + __FUNCTION__); } else if (!do_break && m_breakAllKernels) // Breakpoints won't be set on any new kernels. { m_breakAllKernels = false; - if (log) - log->Printf("%s(False) - breakpoints no longer automatically set.", - __FUNCTION__); + LLDB_LOGF(log, "%s(False) - breakpoints no longer automatically set.", + __FUNCTION__); } } @@ -3595,8 +3499,8 @@ RenderScriptRuntime::CreateKernelBreakpoint(ConstString name) { GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS)); if (!m_filtersp) { - if (log) - log->Printf("%s - error, no breakpoint search filter set.", __FUNCTION__); + LLDB_LOGF(log, "%s - error, no breakpoint search filter set.", + __FUNCTION__); return nullptr; } @@ -3610,9 +3514,8 @@ RenderScriptRuntime::CreateKernelBreakpoint(ConstString name) { Status err; target.AddNameToBreakpoint(bp, "RenderScriptKernel", err); if (err.Fail() && log) - if (log) - log->Printf("%s - error setting break name, '%s'.", __FUNCTION__, - err.AsCString()); + LLDB_LOGF(log, "%s - error setting break name, '%s'.", __FUNCTION__, + err.AsCString()); return bp; } @@ -3624,8 +3527,8 @@ RenderScriptRuntime::CreateReductionBreakpoint(ConstString name, GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS)); if (!m_filtersp) { - if (log) - log->Printf("%s - error, no breakpoint search filter set.", __FUNCTION__); + LLDB_LOGF(log, "%s - error, no breakpoint search filter set.", + __FUNCTION__); return nullptr; } @@ -3640,8 +3543,8 @@ RenderScriptRuntime::CreateReductionBreakpoint(ConstString name, Status err; target.AddNameToBreakpoint(bp, "RenderScriptReduction", err); if (err.Fail() && log) - log->Printf("%s - error setting break name, '%s'.", __FUNCTION__, - err.AsCString()); + LLDB_LOGF(log, "%s - error setting break name, '%s'.", __FUNCTION__, + err.AsCString()); return bp; } @@ -3663,9 +3566,8 @@ bool RenderScriptRuntime::GetFrameVarAsUnsigned(const StackFrameSP frame_sp, StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, var_sp, err)); if (!err.Success()) { - if (log) - log->Printf("%s - error, couldn't find '%s' in frame", __FUNCTION__, - var_name); + LLDB_LOGF(log, "%s - error, couldn't find '%s' in frame", __FUNCTION__, + var_name); return false; } @@ -3673,9 +3575,8 @@ bool RenderScriptRuntime::GetFrameVarAsUnsigned(const StackFrameSP frame_sp, bool success = false; val = value_sp->GetValueAsUnsigned(0, &success); if (!success) { - if (log) - log->Printf("%s - error, couldn't parse '%s' as an uint32_t.", - __FUNCTION__, var_name); + LLDB_LOGF(log, "%s - error, couldn't parse '%s' as an uint32_t.", + __FUNCTION__, var_name); return false; } @@ -3695,8 +3596,7 @@ bool RenderScriptRuntime::GetKernelCoordinate(RSCoordinate &coord, Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE)); if (!thread_ptr) { - if (log) - log->Printf("%s - Error, No thread pointer", __FUNCTION__); + LLDB_LOGF(log, "%s - Error, No thread pointer", __FUNCTION__); return false; } @@ -3718,17 +3618,15 @@ bool RenderScriptRuntime::GetKernelCoordinate(RSCoordinate &coord, if (!func_name) continue; - if (log) - log->Printf("%s - Inspecting function '%s'", __FUNCTION__, - func_name.GetCString()); + LLDB_LOGF(log, "%s - Inspecting function '%s'", __FUNCTION__, + func_name.GetCString()); // Check if function name has .expand suffix if (!func_name.GetStringRef().endswith(".expand")) continue; - if (log) - log->Printf("%s - Found .expand function '%s'", __FUNCTION__, - func_name.GetCString()); + LLDB_LOGF(log, "%s - Found .expand function '%s'", __FUNCTION__, + func_name.GetCString()); // Get values for variables in .expand frame that tell us the current // kernel invocation @@ -3770,9 +3668,8 @@ bool RenderScriptRuntime::KernelBreakpointHit(void *baton, // Coordinate we want to stop on RSCoordinate target_coord = *static_cast<RSCoordinate *>(baton); - if (log) - log->Printf("%s - Break ID %" PRIu64 ", " FMT_COORD, __FUNCTION__, break_id, - target_coord.x, target_coord.y, target_coord.z); + LLDB_LOGF(log, "%s - Break ID %" PRIu64 ", " FMT_COORD, __FUNCTION__, + break_id, target_coord.x, target_coord.y, target_coord.z); // Select current thread ExecutionContext context(ctx->exe_ctx_ref); @@ -3782,22 +3679,19 @@ bool RenderScriptRuntime::KernelBreakpointHit(void *baton, // Find current kernel invocation from .expand frame variables RSCoordinate current_coord{}; if (!GetKernelCoordinate(current_coord, thread_ptr)) { - if (log) - log->Printf("%s - Error, couldn't select .expand stack frame", - __FUNCTION__); + LLDB_LOGF(log, "%s - Error, couldn't select .expand stack frame", + __FUNCTION__); return false; } - if (log) - log->Printf("%s - " FMT_COORD, __FUNCTION__, current_coord.x, - current_coord.y, current_coord.z); + LLDB_LOGF(log, "%s - " FMT_COORD, __FUNCTION__, current_coord.x, + current_coord.y, current_coord.z); // Check if the current kernel invocation coordinate matches our target // coordinate if (target_coord == current_coord) { - if (log) - log->Printf("%s, BREAKING " FMT_COORD, __FUNCTION__, current_coord.x, - current_coord.y, current_coord.z); + LLDB_LOGF(log, "%s, BREAKING " FMT_COORD, __FUNCTION__, current_coord.x, + current_coord.y, current_coord.z); BreakpointSP breakpoint_sp = context.GetTargetPtr()->GetBreakpointByID(break_id); @@ -3865,8 +3759,8 @@ RenderScriptRuntime::CreateScriptGroupBreakpoint(ConstString name, GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS)); if (!m_filtersp) { - if (log) - log->Printf("%s - error, no breakpoint search filter set.", __FUNCTION__); + LLDB_LOGF(log, "%s - error, no breakpoint search filter set.", + __FUNCTION__); return nullptr; } @@ -3880,8 +3774,8 @@ RenderScriptRuntime::CreateScriptGroupBreakpoint(ConstString name, Status err; target.AddNameToBreakpoint(bp, name.GetCString(), err); if (err.Fail() && log) - log->Printf("%s - error setting break name, '%s'.", __FUNCTION__, - err.AsCString()); + LLDB_LOGF(log, "%s - error setting break name, '%s'.", __FUNCTION__, + err.AsCString()); // ask the breakpoint to resolve itself bp->ResolveBreakpoint(); return bp; @@ -3964,9 +3858,8 @@ RenderScriptRuntime::CreateAllocation(addr_t address) { auto it = m_allocations.begin(); while (it != m_allocations.end()) { if (*((*it)->address) == address) { - if (log) - log->Printf("%s - Removing allocation id: %d, address: 0x%" PRIx64, - __FUNCTION__, (*it)->id, address); + LLDB_LOGF(log, "%s - Removing allocation id: %d, address: 0x%" PRIx64, + __FUNCTION__, (*it)->id, address); it = m_allocations.erase(it); } else { @@ -3988,9 +3881,8 @@ bool RenderScriptRuntime::ResolveKernelName(lldb::addr_t kernel_addr, Address resolved; // RenderScript module if (!target.GetSectionLoadList().ResolveLoadAddress(kernel_addr, resolved)) { - if (log) - log->Printf("%s: unable to resolve 0x%" PRIx64 " to a loaded symbol", - __FUNCTION__, kernel_addr); + LLDB_LOGF(log, "%s: unable to resolve 0x%" PRIx64 " to a loaded symbol", + __FUNCTION__, kernel_addr); return false; } @@ -4000,9 +3892,8 @@ bool RenderScriptRuntime::ResolveKernelName(lldb::addr_t kernel_addr, name = sym->GetName(); assert(IsRenderScriptModule(resolved.CalculateSymbolContextModule())); - if (log) - log->Printf("%s: 0x%" PRIx64 " resolved to the symbol '%s'", __FUNCTION__, - kernel_addr, name.GetCString()); + LLDB_LOGF(log, "%s: 0x%" PRIx64 " resolved to the symbol '%s'", __FUNCTION__, + kernel_addr, name.GetCString()); return true; } diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp index 4725e8c5b0e..a6d225d2fbd 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp @@ -93,9 +93,8 @@ llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) { assert(orig && "CallInst has no called function"); llvm::FunctionType *orig_type = orig->getFunctionType(); auto name = orig->getName(); - if (log) - log->Printf("%s - cloning to StructRet function for '%s'", __FUNCTION__, - name.str().c_str()); + LLDB_LOGF(log, "%s - cloning to StructRet function for '%s'", __FUNCTION__, + name.str().c_str()); unsigned num_params = orig_type->getNumParams(); std::vector<llvm::Type *> new_params{num_params + 1, nullptr}; @@ -113,9 +112,9 @@ llvm::FunctionType *cloneToStructRetFnTy(llvm::CallInst *call_inst) { if (!return_type_ptr_type) return nullptr; - if (log) - log->Printf("%s - return type pointer type for StructRet clone @ '0x%p':\n", - __FUNCTION__, (void *)return_type_ptr_type); + LLDB_LOGF(log, + "%s - return type pointer type for StructRet clone @ '0x%p':\n", + __FUNCTION__, (void *)return_type_ptr_type); // put the sret pointer argument in place at the beginning of the // argument list. params.emplace(params.begin(), return_type_ptr_type); |