Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
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
  • Loading branch information
Gerard Ziemski committed Aug 14, 2020
1 parent 28b409f commit 51cc98fdcedc5ec7e532e9f6c16cb6887217e029
Showing with 21 additions and 5 deletions.
  1. +21 −5 src/hotspot/os/bsd/os_bsd.cpp
@@ -1536,21 +1536,37 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
int mib_kern[] = { CTL_KERN, KERN_OSTYPE };
if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) {
#ifdef __APPLE__
strncpy(os, "Darwin", sizeof(os));
strncpy(os, "Darwin", sizeof(os));
#elif __OpenBSD__
strncpy(os, "OpenBSD", sizeof(os));
strncpy(os, "OpenBSD", sizeof(os));
#else
strncpy(os, "BSD", sizeof(os));
strncpy(os, "BSD", sizeof(os));
#endif
}

char release[100];
size = sizeof(release);
int mib_release[] = { CTL_KERN, KERN_OSRELEASE };
if (sysctl(mib_release, 2, release, &size, NULL, 0) < 0) {
// if error, leave blank
strncpy(release, "", sizeof(release));
// 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);
}

0 comments on commit 51cc98f

Please sign in to comment.