From eff1cab1b844eddc4367fb4a02dbc665ebbe2901 Mon Sep 17 00:00:00 2001 From: "Thomas A." Date: Wed, 12 Jun 2024 11:42:24 -0700 Subject: [PATCH] [coredump] Add Support For macOS Path --- src/hosttools/src/coredump/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hosttools/src/coredump/main.cpp b/src/hosttools/src/coredump/main.cpp index de228e69c..ecd9fe6ec 100644 --- a/src/hosttools/src/coredump/main.cpp +++ b/src/hosttools/src/coredump/main.cpp @@ -252,6 +252,21 @@ static int open_file(struct coredump_params* cprm, const char* filename, size_t if (fd < 0 && filename_length >= cprm->prefix_length && strncmp(filename, cprm->prefix, cprm->prefix_length) == 0) { std::filesystem::path temp_filename = std::filesystem::path() / LIBEXEC_PATH / &filename[cprm->prefix_length]; fd = open(temp_filename.c_str(), O_RDONLY); + + // Sometimes the absolute path may actually be the macOS path + } else if (fd < 0 && filename[0] == '/') { + const char* relative_macos_path = &filename[1]; // Convert the absolute path into a relative path + std::filesystem::path temp_filename; + + // Let's see if the file exists in the upper layer + temp_filename = std::filesystem::path(cprm->prefix) / relative_macos_path; + fd = open(temp_filename.c_str(), O_RDONLY); + + // Otherwise, check the lower layer + if (fd < 0) { + temp_filename = std::filesystem::path(LIBEXEC_PATH) / relative_macos_path; + fd = open(temp_filename.c_str(), O_RDONLY); + } } return fd;