Index: lldb/lit/SymbolFile/DWARF/Inputs/deterministic-build.lldbinit =================================================================== --- /dev/null +++ lldb/lit/SymbolFile/DWARF/Inputs/deterministic-build.lldbinit @@ -0,0 +1,7 @@ +# We intentionally don't want to pick up too many lines of context, since the +# test file is also the source file, and that will pick up comments from the +# test file. +settings set stop-line-count-before 0 +settings set stop-line-count-after 1 +breakpoint set -name main +run Index: lldb/lit/SymbolFile/DWARF/deterministic-build.cpp =================================================================== --- /dev/null +++ lldb/lit/SymbolFile/DWARF/deterministic-build.cpp @@ -0,0 +1,11 @@ +// Test that binaries linked deterministically (N_OSO has timestamp 0) can still +// have their object files loaded by lldb. Note that the env var ZERO_AR_DATE +// requires the ld64 linker, which clang invokes by default. +// REQUIRES: system-darwin +// RUN: %clang %s -g -c -o %t.o +// RUN: ZERO_AR_DATE=1 %clang %t.o -g -o %t +// RUN: %lldb %t -s %S/Inputs/deterministic-build.lldbinit -o exit | FileCheck %s +// CHECK: int main() { return 0; } + + +int main() { return 0; } Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -420,7 +420,11 @@ // than the one from the CU. auto oso_mod_time = std::chrono::time_point_cast( FileSystem::Instance().GetModificationTime(oso_file)); - if (oso_mod_time != comp_unit_info->oso_mod_time) { + // A timestamp of 0 means that the linker was in deterministic mode. In + // that case, we should skip the check against the filesystem last + // modification timestamp, since it will never match. + if (comp_unit_info->oso_mod_time != llvm::sys::TimePoint<>() && + oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is " "%s, debug map time is %s"