8237591: Mac: include OS X version in hs_err_pid crash log file

Added macOS and build version to crash lof report

Reviewed-by: dholmes, dcubed
This commit is contained in:
Gerard Ziemski 2020-08-14 13:24:24 -05:00
parent 65b99c7b1a
commit 087cbbfd69

View File

@ -1551,6 +1551,22 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
// if error, leave blank
strncpy(release, "", sizeof(release));
}
#ifdef __APPLE__
char osproductversion[100];
size_t sz = sizeof(osproductversion);
int ret = sysctlbyname("kern.osproductversion", osproductversion, &sz, NULL, 0);
if (ret == 0) {
char build[100];
size = sizeof(build);
int mib_build[] = { CTL_KERN, KERN_OSVERSION };
if (sysctl(mib_build, 2, build, &size, NULL, 0) < 0) {
snprintf(buf, buflen, "%s %s, macOS %s", os, release, osproductversion);
} else {
snprintf(buf, buflen, "%s %s, macOS %s (%s)", os, release, osproductversion, build);
}
} else
#endif
snprintf(buf, buflen, "%s %s", os, release);
}