@@ -134,6 +134,27 @@ LLDBMemoryReader::getSymbolAddress(const std::string &name) {
134134 return swift::remote::RemoteAddress (load_addr);
135135}
136136
137+ static std::unique_ptr<swift::SwiftObjectFileFormat>
138+ GetSwiftObjectFileFormat (llvm::Triple::ObjectFormatType obj_format_type) {
139+ std::unique_ptr<swift::SwiftObjectFileFormat> obj_file_format;
140+ switch (obj_format_type) {
141+ case llvm::Triple::MachO:
142+ obj_file_format = std::make_unique<swift::SwiftObjectFileFormatMachO>();
143+ break ;
144+ case llvm::Triple::ELF:
145+ obj_file_format = std::make_unique<swift::SwiftObjectFileFormatELF>();
146+ break ;
147+ case llvm::Triple::COFF:
148+ obj_file_format = std::make_unique<swift::SwiftObjectFileFormatCOFF>();
149+ break ;
150+ default :
151+ LLDB_LOG (GetLog (LLDBLog::Types), " Could not determine swift reflection "
152+ " section names for object format type" );
153+ break ;
154+ }
155+ return obj_file_format;
156+ }
157+
137158llvm::Optional<swift::remote::RemoteAbsolutePointer>
138159LLDBMemoryReader::resolvePointerAsSymbol (swift::remote::RemoteAddress address) {
139160 // If an address has a symbol, that symbol provides additional useful data to
@@ -161,8 +182,18 @@ LLDBMemoryReader::resolvePointerAsSymbol(swift::remote::RemoteAddress address) {
161182 return {};
162183 }
163184
164- if (!addr.GetSection ()->CanContainSwiftReflectionData ())
165- return {};
185+ if (auto section_sp = addr.GetSection ()) {
186+ if (auto *obj_file = section_sp->GetObjectFile ()) {
187+ auto obj_file_format_type =
188+ obj_file->GetArchitecture ().GetTriple ().getObjectFormat ();
189+ if (auto swift_obj_file_format =
190+ GetSwiftObjectFileFormat (obj_file_format_type)) {
191+ if (!swift_obj_file_format->sectionContainsReflectionData (
192+ section_sp->GetName ().GetStringRef ()))
193+ return {};
194+ }
195+ }
196+ }
166197
167198 if (auto *symbol = addr.CalculateSymbolContextSymbol ()) {
168199 auto mangledName = symbol->GetMangled ().GetMangledName ().GetStringRef ();
0 commit comments