@@ -146,6 +146,27 @@ LLDBMemoryReader::getSymbolAddress(const std::string &name) {
146146 return swift::remote::RemoteAddress (load_addr);
147147}
148148
149+ static std::unique_ptr<swift::SwiftObjectFileFormat>
150+ GetSwiftObjectFileFormat (llvm::Triple::ObjectFormatType obj_format_type) {
151+ std::unique_ptr<swift::SwiftObjectFileFormat> obj_file_format;
152+ switch (obj_format_type) {
153+ case llvm::Triple::MachO:
154+ obj_file_format = std::make_unique<swift::SwiftObjectFileFormatMachO>();
155+ break ;
156+ case llvm::Triple::ELF:
157+ obj_file_format = std::make_unique<swift::SwiftObjectFileFormatELF>();
158+ break ;
159+ case llvm::Triple::COFF:
160+ obj_file_format = std::make_unique<swift::SwiftObjectFileFormatCOFF>();
161+ break ;
162+ default :
163+ LLDB_LOG (GetLog (LLDBLog::Types), " Could not determine swift reflection "
164+ " section names for object format type" );
165+ break ;
166+ }
167+ return obj_file_format;
168+ }
169+
149170llvm::Optional<swift::remote::RemoteAbsolutePointer>
150171LLDBMemoryReader::resolvePointerAsSymbol (swift::remote::RemoteAddress address) {
151172 // If an address has a symbol, that symbol provides additional useful data to
@@ -173,8 +194,18 @@ LLDBMemoryReader::resolvePointerAsSymbol(swift::remote::RemoteAddress address) {
173194 return {};
174195 }
175196
176- if (!addr.GetSection ()->CanContainSwiftReflectionData ())
177- return {};
197+ if (auto section_sp = addr.GetSection ()) {
198+ if (auto *obj_file = section_sp->GetObjectFile ()) {
199+ auto obj_file_format_type =
200+ obj_file->GetArchitecture ().GetTriple ().getObjectFormat ();
201+ if (auto swift_obj_file_format =
202+ GetSwiftObjectFileFormat (obj_file_format_type)) {
203+ if (!swift_obj_file_format->sectionContainsReflectionData (
204+ section_sp->GetName ().GetStringRef ()))
205+ return {};
206+ }
207+ }
208+ }
178209
179210 if (auto *symbol = addr.CalculateSymbolContextSymbol ()) {
180211 auto mangledName = symbol->GetMangled ().GetMangledName ().GetStringRef ();
0 commit comments