Skip to content

Commit

Permalink
[coredump] Add Support For macOS Path
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousTommy committed Jun 13, 2024
1 parent d551cca commit eff1cab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/hosttools/src/coredump/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit eff1cab

Please sign in to comment.