@@ -270,7 +270,36 @@ class TargetReflectionContext
270
270
const swift::reflection::TypeInfo *
271
271
getTypeInfo (const swift::reflection::TypeRef *type_ref,
272
272
swift::remote::TypeInfoProvider *provider) override {
273
- return m_reflection_ctx.getTypeInfo (type_ref, provider);
273
+ if (!type_ref)
274
+ return nullptr ;
275
+
276
+ Log *log (GetLog (LLDBLog::Types));
277
+ if (log && log->GetVerbose ()) {
278
+ std::stringstream ss;
279
+ type_ref->dump (ss);
280
+ LLDB_LOGF (log, " [TargetReflectionContext::getTypeInfo] Getting "
281
+ " type info for typeref:\n %s" ,
282
+ ss.str ().c_str ());
283
+ }
284
+
285
+ auto type_info = m_reflection_ctx.getTypeInfo (type_ref, provider);
286
+ if (log && !type_info) {
287
+ std::stringstream ss;
288
+ type_ref->dump (ss);
289
+ LLDB_LOGF (log,
290
+ " [TargetReflectionContext::getTypeInfo] Could not get "
291
+ " type info for typeref:\n %s" ,
292
+ ss.str ().c_str ());
293
+ }
294
+
295
+ if (log && log->GetVerbose ()) {
296
+ std::stringstream ss;
297
+ type_info->dump (ss);
298
+ log->Printf (" [TargetReflectionContext::getTypeInfo] Found "
299
+ " type info:\n %s" ,
300
+ ss.str ().c_str ());
301
+ }
302
+ return type_info;
274
303
}
275
304
276
305
swift::reflection::MemoryReader &getReader () override {
@@ -991,6 +1020,7 @@ llvm::Optional<unsigned>
991
1020
SwiftLanguageRuntimeImpl::GetNumChildren (CompilerType type,
992
1021
ExecutionContextScope *exe_scope) {
993
1022
LLDB_SCOPED_TIMER ();
1023
+
994
1024
auto ts = type.GetTypeSystem ().dyn_cast_or_null <TypeSystemSwiftTypeRef>();
995
1025
if (!ts)
996
1026
return {};
@@ -1004,14 +1034,14 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
1004
1034
const swift::reflection::TypeRef *tr = nullptr ;
1005
1035
auto *ti = GetSwiftRuntimeTypeInfo (type, exe_scope, &tr);
1006
1036
if (!ti) {
1007
- LLDB_LOG (GetLog (LLDBLog::Types), " GetSwiftRuntimeTypeInfo() failed for {0} " ,
1008
- type.GetMangledTypeName ());
1037
+ LLDB_LOGF (GetLog (LLDBLog::Types), " GetSwiftRuntimeTypeInfo() failed for %s " ,
1038
+ type.GetMangledTypeName (). GetCString ());
1009
1039
return {};
1010
1040
}
1011
1041
// Structs and Tuples.
1012
1042
if (auto *rti = llvm::dyn_cast<swift::reflection::RecordTypeInfo>(ti)) {
1013
- LLDB_LOG (GetLog (LLDBLog::Types), " {0} : RecordTypeInfo(num_fields={1} )" ,
1014
- type.GetMangledTypeName (), rti->getNumFields ());
1043
+ LLDB_LOGF (GetLog (LLDBLog::Types), " %s : RecordTypeInfo(num_fields=%i )" ,
1044
+ type.GetMangledTypeName (). GetCString () , rti->getNumFields ());
1015
1045
switch (rti->getRecordKind ()) {
1016
1046
case swift::reflection::RecordKind::ExistentialMetatype:
1017
1047
case swift::reflection::RecordKind::ThickFunction:
@@ -1029,14 +1059,15 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
1029
1059
}
1030
1060
}
1031
1061
if (auto *eti = llvm::dyn_cast<swift::reflection::EnumTypeInfo>(ti)) {
1032
- LLDB_LOG (GetLog (LLDBLog::Types), " {0}: EnumTypeInfo(num_payload_cases={1})" ,
1033
- type.GetMangledTypeName (), eti->getNumPayloadCases ());
1062
+ LLDB_LOGF (GetLog (LLDBLog::Types), " %s: EnumTypeInfo(num_payload_cases=%i)" ,
1063
+ type.GetMangledTypeName ().GetCString (),
1064
+ eti->getNumPayloadCases ());
1034
1065
return eti->getNumPayloadCases ();
1035
1066
}
1036
1067
// Objects.
1037
1068
if (auto *rti = llvm::dyn_cast<swift::reflection::ReferenceTypeInfo>(ti)) {
1038
- LLDB_LOG (GetLog (LLDBLog::Types), " {0} : ReferenceTypeInfo()" ,
1039
- type.GetMangledTypeName ());
1069
+ LLDB_LOGF (GetLog (LLDBLog::Types), " %s : ReferenceTypeInfo()" ,
1070
+ type.GetMangledTypeName (). GetCString ());
1040
1071
switch (rti->getReferenceKind ()) {
1041
1072
case swift::reflection::ReferenceKind::Weak:
1042
1073
case swift::reflection::ReferenceKind::Unowned:
@@ -1061,8 +1092,8 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
1061
1092
if (auto *rti =
1062
1093
llvm::dyn_cast_or_null<swift::reflection::RecordTypeInfo>(cti)) {
1063
1094
LLDB_LOG (GetLog (LLDBLog::Types),
1064
- " {0} : class RecordTypeInfo(num_fields={1} )" ,
1065
- type.GetMangledTypeName (), rti->getNumFields ());
1095
+ " %s : class RecordTypeInfo(num_fields=%i )" ,
1096
+ type.GetMangledTypeName (). GetCString () , rti->getNumFields ());
1066
1097
1067
1098
// The superclass, if any, is an extra child.
1068
1099
if (builder.lookupSuperclass (tr))
@@ -1073,8 +1104,8 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
1073
1104
return {};
1074
1105
}
1075
1106
// FIXME: Implement more cases.
1076
- LLDB_LOG (GetLog (LLDBLog::Types), " {0} : unimplemented type info" ,
1077
- type.GetMangledTypeName ());
1107
+ LLDB_LOG (GetLog (LLDBLog::Types), " %s : unimplemented type info" ,
1108
+ type.GetMangledTypeName (). GetCString ());
1078
1109
return {};
1079
1110
}
1080
1111
@@ -1824,7 +1855,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Pack(
1824
1855
auto typeref_or_err =
1825
1856
decodeMangledType (reflection_ctx->getBuilder (), pack_element);
1826
1857
if (typeref_or_err.isError ()) {
1827
- LLDB_LOG (log, " Couldn't get TypeRef for %s" ,
1858
+ LLDB_LOGF (log, " Couldn't get TypeRef for %s" ,
1828
1859
pack_type.GetMangledTypeName ().GetCString ());
1829
1860
return false ;
1830
1861
}
@@ -2439,8 +2470,9 @@ SwiftLanguageRuntimeImpl::BindGenericTypeParameters(StackFrame &stack_frame,
2439
2470
return ts.GetTypeFromMangledTypename (mangled_name);
2440
2471
}
2441
2472
CompilerType bound_type = scratch_ctx->RemangleAsType (dem, node);
2442
- LLDB_LOG (GetLog (LLDBLog::Expressions | LLDBLog::Types), " Bound {0} -> {1}." ,
2443
- mangled_name, bound_type.GetMangledTypeName ());
2473
+ LLDB_LOGF (GetLog (LLDBLog::Expressions | LLDBLog::Types), " Bound %s -> %s." ,
2474
+ mangled_name.GetCString (),
2475
+ bound_type.GetMangledTypeName ().GetCString ());
2444
2476
return bound_type;
2445
2477
}
2446
2478
@@ -3173,6 +3205,12 @@ lldb::addr_t SwiftLanguageRuntimeImpl::FixupAddress(lldb::addr_t addr,
3173
3205
const swift::reflection::TypeRef *
3174
3206
SwiftLanguageRuntimeImpl::GetTypeRef (CompilerType type,
3175
3207
TypeSystemSwiftTypeRef *module_holder) {
3208
+ Log *log (GetLog (LLDBLog::Types));
3209
+ if (log && log->GetVerbose ())
3210
+ LLDB_LOGF (log, " [SwiftLanguageRuntimeImpl::GetTypeRef] Getting typeref for "
3211
+ " type: %s\n " ,
3212
+ type.GetMangledTypeName ().GetCString ());
3213
+
3176
3214
// Demangle the mangled name.
3177
3215
swift::Demangle::Demangler dem;
3178
3216
ConstString mangled_name = type.GetMangledTypeName ();
@@ -3190,17 +3228,37 @@ SwiftLanguageRuntimeImpl::GetTypeRef(CompilerType type,
3190
3228
return nullptr ;
3191
3229
3192
3230
auto type_ref_or_err =
3193
- swift::Demangle::decodeMangledType (reflection_ctx->getBuilder (), node);
3194
- if (type_ref_or_err.isError ())
3231
+ swift::Demangle::decodeMangledType (reflection_ctx->getBuilder (), node);
3232
+ if (type_ref_or_err.isError ()) {
3233
+ LLDB_LOGF (log,
3234
+ " [SwiftLanguageRuntimeImpl::GetTypeRef] Could not find typeref "
3235
+ " for type: %s. Decode mangled type failed. Error: %s\n ." ,
3236
+ type.GetMangledTypeName ().GetCString (),
3237
+ type_ref_or_err.getError ()->copyErrorString ());
3195
3238
return nullptr ;
3239
+ }
3196
3240
const swift::reflection::TypeRef *type_ref = type_ref_or_err.getType ();
3241
+ if (log && log->GetVerbose ()) {
3242
+ std::stringstream ss;
3243
+ type_ref->dump (ss);
3244
+ LLDB_LOGF (log, " [SwiftLanguageRuntimeImpl::GetTypeRef] Found typeref for "
3245
+ " type: %s:\n %s" ,
3246
+ type.GetMangledTypeName ().GetCString (), ss.str ().c_str ());
3247
+ }
3197
3248
return type_ref;
3198
3249
}
3199
3250
3200
3251
const swift::reflection::TypeInfo *
3201
3252
SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo (
3202
3253
CompilerType type, ExecutionContextScope *exe_scope,
3203
3254
swift::reflection::TypeRef const **out_tr) {
3255
+ Log *log (GetLog (LLDBLog::Types));
3256
+
3257
+ if (log && log->GetVerbose ())
3258
+ LLDB_LOGF (log, " [SwiftLanguageRuntimeImpl::GetSwiftRuntimeTypeInfo] Getting "
3259
+ " type info for type: %s\n " ,
3260
+ type.GetMangledTypeName ().GetCString ());
3261
+
3204
3262
auto ts = type.GetTypeSystem ().dyn_cast_or_null <TypeSystemSwift>();
3205
3263
if (!ts)
3206
3264
return nullptr ;
0 commit comments