src/os/bsd/vm/os_bsd.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File
*** old/src/os/bsd/vm/os_bsd.cpp	Thu Jul 16 15:07:35 2015
--- new/src/os/bsd/vm/os_bsd.cpp	Thu Jul 16 15:07:34 2015

*** 1598,1625 **** --- 1598,1607 ---- // XXX: Do we need a lock around this as per Linux? void* os::dll_lookup(void* handle, const char* name) { return dlsym(handle, name); } static bool _print_ascii_file(const char* filename, outputStream* st) { int fd = ::open(filename, O_RDONLY); if (fd == -1) { return false; } char buf[32]; int bytes; while ((bytes = ::read(fd, buf, sizeof(buf))) > 0) { st->print_raw(buf, bytes); } ::close(fd); return true; } int _print_dll_info_cb(const char * name, address base_address, address top_address, void * param) { outputStream * out = (outputStream *) param; out->print_cr(PTR_FORMAT " \t%s", base_address, name); return 0; }
*** 1676,1694 **** --- 1658,1699 ---- #else return 1; #endif } ! void os::print_os_info_brief(outputStream* st) { st->print("Bsd"); ! void os::get_summary_os_info(char* buf, size_t buflen) { + // These buffers are small because we want this to be brief + // and not use a lot of stack while generating the hs_err file. + char os[100]; + size_t size = sizeof(os); + int mib_kern[] = { CTL_KERN, KERN_OSTYPE }; + if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) { + #ifdef __APPLE__ + strncpy(os, "Darwin", sizeof(os)); + #elif __OpenBSD__ + strncpy(os, "OpenBSD", sizeof(os)); + #else + 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)); + } + snprintf(buf, buflen, "%s %s", os, release); + } + void os::print_os_info_brief(outputStream* st) { os::Posix::print_uname_info(st); } void os::print_os_info(outputStream* st) { st->print("OS:"); st->print("Bsd"); os::Posix::print_uname_info(st); os::Posix::print_rlimit_info(st);
*** 1697,1721 **** --- 1702,1748 ---- void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { // Nothing to do for now. } + void os::get_summary_cpu_info(char* buf, size_t buflen) { + unsigned int mhz; + size_t size = sizeof(mhz); + int mib[] = { CTL_HW, HW_CPU_FREQ }; + size = sizeof(mhz); + if (sysctl(mib, 2, &mhz, &size, NULL, 0) < 0) { + mhz = 0; + } + mhz /= 1000000; // reported in millions + + char model[100]; + size = sizeof(model); + int mib_model[] = { CTL_HW, HW_MODEL }; + if (sysctl(mib_model, 2, model, &size, NULL, 0) < 0) { + strncpy(model, cpu_arch, sizeof(model)); + } + + char machine[100]; + size = sizeof(machine); + int mib_machine[] = { CTL_HW, HW_MACHINE }; + if (sysctl(mib_machine, 2, machine, &size, NULL, 0) < 0) { + strncpy(machine, "", sizeof(machine)); + } + + snprintf(buf, buflen, "%s %s %d MHz", model, machine, mhz); + } + void os::print_memory_info(outputStream* st) { st->print("Memory:"); st->print(" %dk page", os::vm_page_size()>>10); st->print(", physical " UINT64_FORMAT "k", os::physical_memory() >> 10); st->print("(" UINT64_FORMAT "k free)", os::available_memory() >> 10); st->cr(); // meminfo st->print("\n/proc/meminfo:\n"); _print_ascii_file("/proc/meminfo", st); st->cr(); } void os::print_siginfo(outputStream* st, void* siginfo) { const siginfo_t* si = (const siginfo_t*)siginfo;

src/os/bsd/vm/os_bsd.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File