mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 15:21:13 +08:00
mac-arm64: Omit the cl_kernels workaround on this platform
cl_kernels modules have appeared since OS X 10.10 as MH_BUNDLE modules with a __TEXT segment, one section of which claims to belong to the __LD segment. They are produced when OpenCL is asked to compile an OpenCL kernel for the CPU, but this currently appears impossible on arm64. The workaround is omitted as it appears to be unnecessary, but the test still attempts to create an OpenCL kernel for the CPU. If this ever becomes possible, and the modules are malformed, the test will fail as an indication that the workaround must be reinstated for arm64. Bug: crashpad:345 Test: crashpad_snapshot_test ProcessReaderMac.{Self,Child}Modules Change-Id: Ia3d7163cc9995bb4a33457a77c2a5f0e66f4c1a0 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2386466 Commit-Queue: Mark Mentovai <mark@chromium.org> Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
parent
ca83774eea
commit
f8563cb862
@ -22,6 +22,7 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "build/build_config.h"
|
||||
#include "snapshot/mac/process_reader_mac.h"
|
||||
#include "util/mac/checked_mach_address_range.h"
|
||||
#include "util/mac/mac_util.h"
|
||||
@ -40,6 +41,7 @@ std::string SizeLimitedCString(const char* c_string, size_t max_length) {
|
||||
bool IsMalformedCLKernelsModule(uint32_t mach_o_file_type,
|
||||
const std::string& module_name,
|
||||
bool* has_timestamp) {
|
||||
#if defined(ARCH_CPU_X86_FAMILY)
|
||||
if (mach_o_file_type != MH_BUNDLE) {
|
||||
return false;
|
||||
}
|
||||
@ -66,6 +68,7 @@ bool IsMalformedCLKernelsModule(uint32_t mach_o_file_type,
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -46,6 +46,9 @@ namespace crashpad {
|
||||
//! information stored in `MH_OBJECT` images, although `cl_kernels` images claim
|
||||
//! to be `MH_BUNDLE`.
|
||||
//!
|
||||
//! These `cl_kernels` modules have only been observed on x86, not on arm64.
|
||||
//! This function always returns `false` on arm64.
|
||||
//!
|
||||
//! This function is exposed for testing purposes only.
|
||||
//!
|
||||
//! \param[in] mach_o_file_type The Mach-O type of the module being examined.
|
||||
|
@ -617,7 +617,10 @@ void VerifyImageExistenceAndTimestamp(const char* path, time_t timestamp) {
|
||||
class ScopedOpenCLNoOpKernel {
|
||||
public:
|
||||
ScopedOpenCLNoOpKernel()
|
||||
: context_(nullptr), program_(nullptr), kernel_(nullptr) {}
|
||||
: context_(nullptr),
|
||||
program_(nullptr),
|
||||
kernel_(nullptr),
|
||||
success_(false) {}
|
||||
|
||||
~ScopedOpenCLNoOpKernel() {
|
||||
if (kernel_) {
|
||||
@ -661,6 +664,14 @@ class ScopedOpenCLNoOpKernel {
|
||||
#endif // DISABLED_WUNGUARDED_AVAILABILITY
|
||||
rv =
|
||||
clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_CPU, 1, &device_id, nullptr);
|
||||
#if defined(ARCH_CPU_ARM64)
|
||||
// CL_DEVICE_TYPE_CPU doesn’t seem to work at all on arm64, meaning that
|
||||
// these weird OpenCL modules probably don’t show up there at all. Keep this
|
||||
// test even on arm64 in case this ever does start working.
|
||||
if (rv == CL_INVALID_VALUE) {
|
||||
return;
|
||||
}
|
||||
#endif // ARCH_CPU_ARM64
|
||||
ASSERT_EQ(rv, CL_SUCCESS) << "clGetDeviceIDs";
|
||||
|
||||
context_ = clCreateContext(nullptr, 1, &device_id, nullptr, nullptr, &rv);
|
||||
@ -698,12 +709,17 @@ class ScopedOpenCLNoOpKernel {
|
||||
|
||||
kernel_ = clCreateKernel(program_, "NoOp", &rv);
|
||||
ASSERT_EQ(rv, CL_SUCCESS) << "clCreateKernel";
|
||||
|
||||
success_ = true;
|
||||
}
|
||||
|
||||
bool success() const { return success_; }
|
||||
|
||||
private:
|
||||
cl_context context_;
|
||||
cl_program program_;
|
||||
cl_kernel kernel_;
|
||||
bool success_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedOpenCLNoOpKernel);
|
||||
};
|
||||
@ -769,7 +785,7 @@ TEST(ProcessReaderMac, SelfModules) {
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(found_cl_kernels, ExpectCLKernels());
|
||||
EXPECT_EQ(found_cl_kernels, ExpectCLKernels() && ensure_cl_kernels.success());
|
||||
|
||||
size_t index = modules.size() - 1;
|
||||
EXPECT_EQ(modules[index].name, kDyldPath);
|
||||
@ -789,7 +805,9 @@ TEST(ProcessReaderMac, SelfModules) {
|
||||
|
||||
class ProcessReaderModulesChild final : public MachMultiprocess {
|
||||
public:
|
||||
ProcessReaderModulesChild() : MachMultiprocess() {}
|
||||
explicit ProcessReaderModulesChild(bool ensure_cl_kernels_success)
|
||||
: MachMultiprocess(),
|
||||
ensure_cl_kernels_success_(ensure_cl_kernels_success) {}
|
||||
|
||||
~ProcessReaderModulesChild() {}
|
||||
|
||||
@ -855,7 +873,8 @@ class ProcessReaderModulesChild final : public MachMultiprocess {
|
||||
}
|
||||
}
|
||||
|
||||
EXPECT_EQ(found_cl_kernels, ExpectCLKernels());
|
||||
EXPECT_EQ(found_cl_kernels,
|
||||
ExpectCLKernels() && ensure_cl_kernels_success_);
|
||||
}
|
||||
|
||||
void MachMultiprocessChild() override {
|
||||
@ -905,6 +924,8 @@ class ProcessReaderModulesChild final : public MachMultiprocess {
|
||||
CheckedReadFileAtEOF(ReadPipeHandle());
|
||||
}
|
||||
|
||||
bool ensure_cl_kernels_success_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ProcessReaderModulesChild);
|
||||
};
|
||||
|
||||
@ -912,7 +933,8 @@ TEST(ProcessReaderMac, ChildModules) {
|
||||
ScopedOpenCLNoOpKernel ensure_cl_kernels;
|
||||
ASSERT_NO_FATAL_FAILURE(ensure_cl_kernels.SetUp());
|
||||
|
||||
ProcessReaderModulesChild process_reader_modules_child;
|
||||
ProcessReaderModulesChild process_reader_modules_child(
|
||||
ensure_cl_kernels.success());
|
||||
process_reader_modules_child.Run();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user