Mac: Expect timestamp for main executable in macOS 12+ in process reader

dyld4 *does* record a timestamp for the main executable (confirmed with
a test app).

Bug: chromium:1268776
Change-Id: I13380181903be7b4886dfdf37f1aa42018a0ef55
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3833512
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
This commit is contained in:
Leonard Grey 2022-08-17 14:25:10 -04:00 committed by Crashpad LUCI CQ
parent 0c369760bd
commit 05e3bd85eb

View File

@ -826,9 +826,9 @@ TEST(ProcessReaderMac, SelfModules) {
FromPointerCast<mach_vm_address_t>(_dyld_get_image_header(index)));
bool expect_timestamp;
if (index == 0) {
// dyld didnt load the main executable, so it couldnt record its
// timestamp, and it is reported as 0.
if (index == 0 && MacOSVersionNumber() < 12'00'00) {
// Pre-dyld4, dyld didnt set the main executable's timestamp, and it was
// reported as 0.
EXPECT_EQ(modules[index].timestamp, 0);
} else if (IsMalformedCLKernelsModule(modules[index].reader->FileType(),
modules[index].name,
@ -918,13 +918,15 @@ class ProcessReaderModulesChild final : public MachMultiprocess {
EXPECT_EQ(modules[index].reader->Address(), expect_address);
bool expect_timestamp;
if (index == 0 || index == modules.size() - 1) {
// dyld didnt load the main executable or itself, so it couldnt record
// these timestamps, and they are reported as 0.
EXPECT_EQ(modules[index].timestamp, 0);
} else if (IsMalformedCLKernelsModule(modules[index].reader->FileType(),
modules[index].name,
&expect_timestamp)) {
if ((index == 0 && MacOSVersionNumber() < 12'00'00) || index == modules.size() - 1) {
// Pre-dyld4, dyld didnt set the main executable's timestamp, and it
// was reported as 0.
// The last module is dyld.
EXPECT_EQ(modules[index].timestamp, 0);
}
else if (IsMalformedCLKernelsModule(modules[index].reader->FileType(),
modules[index].name,
&expect_timestamp)) {
// cl_kernels doesnt exist as a file, but may still have a timestamp.
if (!expect_timestamp) {
EXPECT_EQ(modules[index].timestamp, 0);