@@ -1835,31 +1835,34 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1835
1835
return false ;
1836
1836
}
1837
1837
Log *log (GetLog (LLDBLog::Types));
1838
- ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1839
- if (!reflection_ctx)
1840
- return false ;
1838
+ // Scope reflection_ctx to minimize its lock scope.
1839
+ {
1840
+ ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1841
+ if (!reflection_ctx)
1842
+ return false ;
1841
1843
1842
- const auto *typeref = reflection_ctx->ReadTypeFromInstance (
1843
- instance_ptr, ts->GetDescriptorFinder (), true );
1844
+ const auto *typeref = reflection_ctx->ReadTypeFromInstance (
1845
+ instance_ptr, ts->GetDescriptorFinder (), true );
1844
1846
1845
- // If we couldn't find the typeref from the instance, the best we can do is
1846
- // use the static type. This is a valid use case when the binary doesn't
1847
- // contain any metadata (for example, embedded Swift).
1848
- if (!typeref)
1849
- typeref = reflection_ctx->GetTypeRefOrNull (class_type. GetMangledTypeName (),
1850
- ts->GetDescriptorFinder ());
1847
+ // If we couldn't find the typeref from the instance, the best we can do is
1848
+ // use the static type. This is a valid use case when the binary doesn't
1849
+ // contain any metadata (for example, embedded Swift).
1850
+ if (!typeref)
1851
+ typeref = reflection_ctx->GetTypeRefOrNull (
1852
+ class_type. GetMangledTypeName (), ts->GetDescriptorFinder ());
1851
1853
1852
- if (!typeref) {
1853
- HEALTH_LOG (" could not read typeref for type: {0} (instance_ptr = {0:x})" ,
1854
- class_type.GetMangledTypeName (), instance_ptr);
1855
- return false ;
1854
+ if (!typeref) {
1855
+ HEALTH_LOG (" could not read typeref for type: {0} (instance_ptr = {0:x})" ,
1856
+ class_type.GetMangledTypeName (), instance_ptr);
1857
+ return false ;
1858
+ }
1859
+ swift::Demangle::Demangler dem;
1860
+ swift::Demangle::NodePointer node = typeref->getDemangling (dem);
1861
+ CompilerType dynamic_type = ts->RemangleAsType (dem, node);
1862
+ LLDB_LOG (log , " dynamic type of instance_ptr {0:x} is {1}" , instance_ptr,
1863
+ class_type.GetMangledTypeName ());
1864
+ class_type_or_name.SetCompilerType (dynamic_type);
1856
1865
}
1857
- swift::Demangle::Demangler dem;
1858
- swift::Demangle::NodePointer node = typeref->getDemangling (dem);
1859
- CompilerType dynamic_type = ts->RemangleAsType (dem, node);
1860
- LLDB_LOG (log , " dynamic type of instance_ptr {0:x} is {1}" , instance_ptr,
1861
- class_type.GetMangledTypeName ());
1862
- class_type_or_name.SetCompilerType (dynamic_type);
1863
1866
1864
1867
#ifndef NDEBUG
1865
1868
if (ModuleList::GetGlobalModuleListProperties ()
0 commit comments