forked from OSchip/llvm-project
[dsymutil] Warn on timestmap mismatch between object file and debug map
Add a warning when the timestmap doesn't match between the object file and the debug map entry. We were already emitting such warnings for archive members and swift interface files. This patch also unifies the warning across all three. rdar://65614640 Differential revision: https://reviews.llvm.org/D94536
This commit is contained in:
parent
914e2f5a02
commit
e5553b9a6a
|
@ -20,7 +20,7 @@ READOBJ-NEXT: |.|
|
|||
DWARFDUMP: __swift_ast
|
||||
|
||||
RUN: dsymutil -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 -no-output -verbose 2>&1 | FileCheck %s --check-prefix=TIMESTAMP
|
||||
TIMESTAMP: warning: Timestamp mismatch
|
||||
TIMESTAMP: warning: {{.*}}/swift-ast.swiftmodule: timestamp mismatch between swift interface file ({{.*}}) and debug map ({{.*}})
|
||||
|
||||
RUN: dsymutil -s %T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck %s --check-prefix=NAST
|
||||
NAST-NOT: N_AST
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
RUN: touch %p/Inputs/basic.macho.x86_64.o
|
||||
RUN: dsymutil -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic.macho.x86_64 | FileCheck %s
|
||||
RUN: dsymutil -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-lto.macho.x86_64 | FileCheck %s --check-prefix=CHECK-LTO
|
||||
RUN: dsymutil -verbose -dump-debug-map -oso-prepend-path=%p %p/Inputs/basic-archive.macho.x86_64 2>&1 | FileCheck %s --check-prefix=CHECK-ARCHIVE
|
||||
|
@ -46,6 +47,7 @@ opening the archive once if mulitple of its members are used).
|
|||
CHECK-ARCHIVE: trying to open {{.*}}basic-archive.macho.x86_64'
|
||||
CHECK-ARCHIVE-NEXT: loaded object.
|
||||
CHECK-ARCHIVE-NEXT: trying to open {{.*}}/Inputs/basic1.macho.x86_64.o'
|
||||
CHECK-ARCHIVE-NEXT: warning: {{.*}}/Inputs/basic1.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}})
|
||||
CHECK-ARCHIVE-NEXT: loaded object.
|
||||
CHECK-ARCHIVE-NEXT: trying to open {{.*}}/libbasic.a(basic2.macho.x86_64.o)'
|
||||
CHECK-ARCHIVE-NEXT: loaded archive {{.*}}/libbasic.a'
|
||||
|
|
|
@ -87,7 +87,8 @@ Error BinaryHolder::ArchiveEntry::load(IntrusiveRefCntPtr<vfs::FileSystem> VFS,
|
|||
}
|
||||
|
||||
Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr<vfs::FileSystem> VFS,
|
||||
StringRef Filename, bool Verbose) {
|
||||
StringRef Filename, TimestampTy Timestamp,
|
||||
bool Verbose) {
|
||||
// Try to load regular binary and force it to be memory mapped.
|
||||
auto ErrOrBuff = (Filename == "-")
|
||||
? MemoryBuffer::getSTDIN()
|
||||
|
@ -95,6 +96,17 @@ Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr<vfs::FileSystem> VFS,
|
|||
if (auto Err = ErrOrBuff.getError())
|
||||
return errorCodeToError(Err);
|
||||
|
||||
if (Filename != "-" && Timestamp != sys::TimePoint<>()) {
|
||||
llvm::ErrorOr<vfs::Status> Stat = VFS->status(Filename);
|
||||
if (!Stat)
|
||||
return errorCodeToError(Stat.getError());
|
||||
if (Timestamp != Stat->getLastModificationTime())
|
||||
WithColor::warning() << Filename
|
||||
<< ": timestamp mismatch between object file ("
|
||||
<< Stat->getLastModificationTime()
|
||||
<< ") and debug map (" << Timestamp << ")\n";
|
||||
}
|
||||
|
||||
MemBuffer = std::move(*ErrOrBuff);
|
||||
|
||||
if (Verbose)
|
||||
|
@ -182,7 +194,11 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename,
|
|||
if (Timestamp != sys::TimePoint<>() &&
|
||||
Timestamp != ModTimeOrErr.get()) {
|
||||
if (Verbose)
|
||||
WithColor::warning() << "member has timestamp mismatch.\n";
|
||||
WithColor::warning()
|
||||
<< *NameOrErr
|
||||
<< ": timestamp mismatch between archive member ("
|
||||
<< ModTimeOrErr.get() << ") and debug map (" << Timestamp
|
||||
<< ")\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -246,7 +262,7 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) {
|
|||
std::lock_guard<std::mutex> Lock(ObjectCacheMutex);
|
||||
if (!ObjectCache.count(Filename)) {
|
||||
ObjectEntry &OE = ObjectCache[Filename];
|
||||
auto Err = OE.load(VFS, Filename, Verbose);
|
||||
auto Err = OE.load(VFS, Filename, Timestamp, Verbose);
|
||||
if (Err) {
|
||||
ObjectCache.erase(Filename);
|
||||
return std::move(Err);
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
public:
|
||||
/// Load the given object binary in memory.
|
||||
Error load(IntrusiveRefCntPtr<vfs::FileSystem> VFS, StringRef Filename,
|
||||
bool Verbose = false);
|
||||
TimestampTy Timestamp, bool Verbose = false);
|
||||
|
||||
/// Access all owned ObjectFiles.
|
||||
std::vector<const object::ObjectFile *> getObjects() const;
|
||||
|
|
|
@ -412,9 +412,10 @@ bool DwarfLinkerForBinary::link(const DebugMap &Map) {
|
|||
Stat.getLastModificationTime());
|
||||
if (ModificationTime != Obj->getTimestamp()) {
|
||||
// Not using the helper here as we can easily stream TimePoint<>.
|
||||
WithColor::warning() << "Timestamp mismatch for " << File << ": "
|
||||
<< Stat.getLastModificationTime() << " and "
|
||||
<< sys::TimePoint<>(Obj->getTimestamp()) << "\n";
|
||||
WithColor::warning()
|
||||
<< File << ": timestamp mismatch between swift interface file ("
|
||||
<< sys::TimePoint<>(Obj->getTimestamp()) << ") and debug map ("
|
||||
<< sys::TimePoint<>(Obj->getTimestamp()) << ")\n";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue