Skip to content

Commit 69573cb

Browse files
committed
Make some SwiftLanguageRuntime logs HEALTH logs
1 parent 0defaba commit 69573cb

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "SwiftMetadataCache.h"
1818

1919
#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
20+
#include "Plugins/Language/Swift/LogChannelSwift.h"
2021
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
2122
#include "Plugins/TypeSystem/Swift/SwiftDemangle.h"
2223
#include "lldb/Core/ValueObjectMemory.h"
@@ -41,6 +42,12 @@
4142

4243
#include <sstream>
4344

45+
#define HEALTH_LOG(FMT, ...) \
46+
do { \
47+
LLDB_LOG(GetLog(LLDBLog::Types), FMT, ##__VA_ARGS__); \
48+
LLDB_LOG(lldb_private::GetSwiftHealthLog(), FMT, ##__VA_ARGS__); \
49+
} while (0)
50+
4451
using namespace lldb;
4552
using namespace lldb_private;
4653

@@ -328,10 +335,9 @@ class LLDBTypeInfoProvider : public swift::remote::TypeInfoProvider {
328335
bool is_imported =
329336
ts->IsImportedType(swift_type.GetOpaqueQualType(), &clang_type);
330337
if (!is_imported || !clang_type) {
331-
LLDB_LOG(GetLog(LLDBLog::Types),
332-
"[LLDBTypeInfoProvider] Could not find clang debug type info "
333-
"for {0}",
334-
mangledName);
338+
HEALTH_LOG("[LLDBTypeInfoProvider] Could not find clang debug type info "
339+
"for {0}",
340+
mangledName);
335341
return nullptr;
336342
}
337343

@@ -630,8 +636,8 @@ GetExistentialSyntheticChildren(std::shared_ptr<TypeSystemSwiftTypeRef> ts,
630636
/// Log the fact that a type kind is not supported.
631637
void LogUnimplementedTypeKind(const char *function, CompilerType type) {
632638
// When running the test suite assert that all cases are covered.
633-
LLDB_LOG(GetLog(LLDBLog::Types), "{0}: unimplemented type info in {1}",
634-
type.GetMangledTypeName(), function);
639+
HEALTH_LOG("{0}: unimplemented type info in {1}", type.GetMangledTypeName(),
640+
function);
635641
#ifndef NDEBUG
636642
llvm::dbgs() << function << ": unimplemented type info in"
637643
<< type.GetMangledTypeName() << "\n";
@@ -1768,17 +1774,15 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
17681774
ts.GetDescriptorFinder());
17691775

17701776
if (!typeref) {
1771-
LLDB_LOGF(log,
1772-
"could not read typeref for type: %s (instance_ptr = 0x%" PRIx64
1773-
")",
1774-
class_type.GetMangledTypeName().GetCString(), instance_ptr);
1777+
HEALTH_LOG("could not read typeref for type: {0} (instance_ptr = {0:x})",
1778+
class_type.GetMangledTypeName(), instance_ptr);
17751779
return false;
17761780
}
17771781
swift::Demangle::Demangler dem;
17781782
swift::Demangle::NodePointer node = typeref->getDemangling(dem);
17791783
CompilerType dynamic_type = ts.RemangleAsType(dem, node);
1780-
LLDB_LOGF(log, "dynamic type of instance_ptr 0x%" PRIx64 " is %s",
1781-
instance_ptr, class_type.GetMangledTypeName().GetCString());
1784+
LLDB_LOG(log, "dynamic type of instance_ptr {0:x} is {1}", instance_ptr,
1785+
class_type.GetMangledTypeName());
17821786
class_type_or_name.SetCompilerType(dynamic_type);
17831787

17841788
#ifndef NDEBUG

0 commit comments

Comments
 (0)