Skip to content

[Reflection] Changes to support LLDBMemoryReader #41209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/swift/ABI/ObjectFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class SwiftObjectFileFormat {
public:
virtual ~SwiftObjectFileFormat() {}
virtual llvm::StringRef getSectionName(ReflectionSectionKind section) = 0;
/// Predicate to identify if the named section can contain reflection data.
virtual bool sectionContainsReflectionData(llvm::StringRef sectionName) = 0;
};

/// Responsible for providing the Mach-O reflection section identifiers.
Expand All @@ -50,6 +52,10 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
}
llvm_unreachable("Section type not found.");
}

bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
return sectionName.startswith("__swift5_") || sectionName == "__const";
}
};

/// Responsible for providing the ELF reflection section identifiers.
Expand All @@ -72,6 +78,10 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
}
llvm_unreachable("Section type not found.");
}

bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
return sectionName.startswith("swift5_");
}
};

/// Responsible for providing the COFF reflection section identifiers
Expand All @@ -94,6 +104,10 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
}
llvm_unreachable("Section not found.");
}

bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
return sectionName.startswith(".sw5");
}
};
} // namespace swift
#endif // SWIFT_ABI_OBJECTFILE_H
6 changes: 5 additions & 1 deletion include/swift/Remote/MetadataReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ class MetadataReader {
return nullptr;
}
} else {
resolved = RemoteAbsolutePointer("", remoteAddress);
resolved = Reader->resolvePointer(RemoteAddress(remoteAddress), 0);
if (resolved.getSymbol().empty()) {
// No symbol found, use the already calculated address.
resolved = RemoteAbsolutePointer("", remoteAddress);
}
}

switch (kind) {
Expand Down