提交 a5958a27 编写于 作者: N nloodin

7165755: OS Information much longer on linux than other platforms

Reviewed-by: sla, dholmes
上级 b2b86d53
...@@ -2340,93 +2340,21 @@ void os::print_dll_info(outputStream *st) { ...@@ -2340,93 +2340,21 @@ void os::print_dll_info(outputStream *st) {
#endif #endif
} }
void os::print_os_info_brief(outputStream* st) {
st->print("Bsd");
os::Posix::print_uname_info(st);
}
void os::print_os_info(outputStream* st) { void os::print_os_info(outputStream* st) {
st->print("OS:"); st->print("OS:");
st->print("Bsd");
// Try to identify popular distros. os::Posix::print_uname_info(st);
// Most Bsd distributions have /etc/XXX-release file, which contains
// the OS version string. Some have more than one /etc/XXX-release file
// (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
// so the order is important.
if (!_print_ascii_file("/etc/mandrake-release", st) &&
!_print_ascii_file("/etc/sun-release", st) &&
!_print_ascii_file("/etc/redhat-release", st) &&
!_print_ascii_file("/etc/SuSE-release", st) &&
!_print_ascii_file("/etc/turbobsd-release", st) &&
!_print_ascii_file("/etc/gentoo-release", st) &&
!_print_ascii_file("/etc/debian_version", st) &&
!_print_ascii_file("/etc/ltib-release", st) &&
!_print_ascii_file("/etc/angstrom-version", st)) {
st->print("Bsd");
}
st->cr();
// kernel
st->print("uname:");
struct utsname name;
uname(&name);
st->print(name.sysname); st->print(" ");
st->print(name.release); st->print(" ");
st->print(name.version); st->print(" ");
st->print(name.machine);
st->cr();
#ifndef _ALLBSD_SOURCE
// Print warning if unsafe chroot environment detected
if (unsafe_chroot_detected) {
st->print("WARNING!! ");
st->print_cr(unstable_chroot_error);
}
// libc, pthread
st->print("libc:");
st->print(os::Bsd::glibc_version()); st->print(" ");
st->print(os::Bsd::libpthread_version()); st->print(" ");
if (os::Bsd::is_BsdThreads()) {
st->print("(%s stack)", os::Bsd::is_floating_stack() ? "floating" : "fixed");
}
st->cr();
#endif
// rlimit
st->print("rlimit:");
struct rlimit rlim;
st->print(" STACK ");
getrlimit(RLIMIT_STACK, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", CORE ");
getrlimit(RLIMIT_CORE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", NPROC "); os::Posix::print_rlimit_info(st);
getrlimit(RLIMIT_NPROC, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
st->print(", NOFILE "); os::Posix::print_load_average(st);
getrlimit(RLIMIT_NOFILE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
#ifndef _ALLBSD_SOURCE
st->print(", AS ");
getrlimit(RLIMIT_AS, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->cr();
// load average
st->print("load average:");
double loadavg[3];
os::loadavg(loadavg, 3);
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
st->cr();
#endif
} }
void os::pd_print_cpu_info(outputStream* st) { void os::pd_print_cpu_info(outputStream* st) {
......
...@@ -2020,15 +2020,43 @@ void os::print_dll_info(outputStream *st) { ...@@ -2020,15 +2020,43 @@ void os::print_dll_info(outputStream *st) {
} }
} }
void os::print_os_info_brief(outputStream* st) {
os::Linux::print_distro_info(st);
os::Posix::print_uname_info(st);
os::Linux::print_libversion_info(st);
}
void os::print_os_info(outputStream* st) { void os::print_os_info(outputStream* st) {
st->print("OS:"); st->print("OS:");
// Try to identify popular distros. os::Linux::print_distro_info(st);
// Most Linux distributions have /etc/XXX-release file, which contains
// the OS version string. Some have more than one /etc/XXX-release file os::Posix::print_uname_info(st);
// (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
// so the order is important. // Print warning if unsafe chroot environment detected
if (unsafe_chroot_detected) {
st->print("WARNING!! ");
st->print_cr(unstable_chroot_error);
}
os::Linux::print_libversion_info(st);
os::Posix::print_rlimit_info(st);
os::Posix::print_load_average(st);
os::Linux::print_full_memory_info(st);
}
// Try to identify popular distros.
// Most Linux distributions have /etc/XXX-release file, which contains
// the OS version string. Some have more than one /etc/XXX-release file
// (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
// so the order is important.
void os::Linux::print_distro_info(outputStream* st) {
if (!_print_ascii_file("/etc/mandrake-release", st) && if (!_print_ascii_file("/etc/mandrake-release", st) &&
!_print_ascii_file("/etc/sun-release", st) && !_print_ascii_file("/etc/sun-release", st) &&
!_print_ascii_file("/etc/redhat-release", st) && !_print_ascii_file("/etc/redhat-release", st) &&
...@@ -2041,23 +2069,9 @@ void os::print_os_info(outputStream* st) { ...@@ -2041,23 +2069,9 @@ void os::print_os_info(outputStream* st) {
st->print("Linux"); st->print("Linux");
} }
st->cr(); st->cr();
}
// kernel void os::Linux::print_libversion_info(outputStream* st) {
st->print("uname:");
struct utsname name;
uname(&name);
st->print(name.sysname); st->print(" ");
st->print(name.release); st->print(" ");
st->print(name.version); st->print(" ");
st->print(name.machine);
st->cr();
// Print warning if unsafe chroot environment detected
if (unsafe_chroot_detected) {
st->print("WARNING!! ");
st->print_cr(unstable_chroot_error);
}
// libc, pthread // libc, pthread
st->print("libc:"); st->print("libc:");
st->print(os::Linux::glibc_version()); st->print(" "); st->print(os::Linux::glibc_version()); st->print(" ");
...@@ -2066,56 +2080,12 @@ void os::print_os_info(outputStream* st) { ...@@ -2066,56 +2080,12 @@ void os::print_os_info(outputStream* st) {
st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed"); st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
} }
st->cr(); st->cr();
// rlimit
st->print("rlimit:");
struct rlimit rlim;
st->print(" STACK ");
getrlimit(RLIMIT_STACK, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", CORE ");
getrlimit(RLIMIT_CORE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", NPROC ");
getrlimit(RLIMIT_NPROC, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
st->print(", NOFILE ");
getrlimit(RLIMIT_NOFILE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
st->print(", AS ");
getrlimit(RLIMIT_AS, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->cr();
// load average
st->print("load average:");
double loadavg[3];
os::loadavg(loadavg, 3);
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
st->cr();
// meminfo
st->print("\n/proc/meminfo:\n");
_print_ascii_file("/proc/meminfo", st);
st->cr();
} }
void os::pd_print_cpu_info(outputStream* st) { void os::Linux::print_full_memory_info(outputStream* st) {
st->print("\n/proc/cpuinfo:\n"); st->print("\n/proc/meminfo:\n");
if (!_print_ascii_file("/proc/cpuinfo", st)) { _print_ascii_file("/proc/meminfo", st);
st->print(" <Not Available>"); st->cr();
}
st->cr();
} }
void os::print_memory_info(outputStream* st) { void os::print_memory_info(outputStream* st) {
...@@ -2138,6 +2108,14 @@ void os::print_memory_info(outputStream* st) { ...@@ -2138,6 +2108,14 @@ void os::print_memory_info(outputStream* st) {
st->cr(); st->cr();
} }
void os::pd_print_cpu_info(outputStream* st) {
st->print("\n/proc/cpuinfo:\n");
if (!_print_ascii_file("/proc/cpuinfo", st)) {
st->print(" <Not Available>");
}
st->cr();
}
// Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific
// but they're the same for all the linux arch that we support // but they're the same for all the linux arch that we support
// and they're the same for solaris but there's no common place to put this. // and they're the same for solaris but there's no common place to put this.
......
...@@ -89,6 +89,10 @@ class Linux { ...@@ -89,6 +89,10 @@ class Linux {
static bool hugetlbfs_sanity_check(bool warn, size_t page_size); static bool hugetlbfs_sanity_check(bool warn, size_t page_size);
static void print_full_memory_info(outputStream* st);
static void print_distro_info(outputStream* st);
static void print_libversion_info(outputStream* st);
public: public:
static void init_thread_fpu_state(); static void init_thread_fpu_state();
static int get_fpu_control_word(); static int get_fpu_control_word();
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <unistd.h> #include <unistd.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/utsname.h>
// Check core dump limit and report possible place where core can be found // Check core dump limit and report possible place where core can be found
void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) { void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* buffer, size_t bufferSize) {
...@@ -72,3 +74,59 @@ void os::wait_for_keypress_at_exit(void) { ...@@ -72,3 +74,59 @@ void os::wait_for_keypress_at_exit(void) {
// don't do anything on posix platforms // don't do anything on posix platforms
return; return;
} }
void os::Posix::print_load_average(outputStream* st) {
st->print("load average:");
double loadavg[3];
os::loadavg(loadavg, 3);
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
st->cr();
}
void os::Posix::print_rlimit_info(outputStream* st) {
st->print("rlimit:");
struct rlimit rlim;
st->print(" STACK ");
getrlimit(RLIMIT_STACK, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", CORE ");
getrlimit(RLIMIT_CORE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
//Isn't there on solaris
#ifndef TARGET_OS_FAMILY_solaris
st->print(", NPROC ");
getrlimit(RLIMIT_NPROC, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
#endif
st->print(", NOFILE ");
getrlimit(RLIMIT_NOFILE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
st->print(", AS ");
getrlimit(RLIMIT_AS, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->cr();
}
void os::Posix::print_uname_info(outputStream* st) {
// kernel
st->print("uname:");
struct utsname name;
uname(&name);
st->print(name.sysname); st->print(" ");
st->print(name.release); st->print(" ");
st->print(name.version); st->print(" ");
st->print(name.machine);
st->cr();
}
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef OS_POSIX_VM_OS_POSIX_HPP
#define OS_POSIX_VM_OS_POSIX_HPP
class Posix {
friend class os;
protected:
static void print_distro_info(outputStream* st);
static void print_rlimit_info(outputStream* st);
static void print_uname_info(outputStream* st);
static void print_libversion_info(outputStream* st);
static void print_load_average(outputStream* st);
};
#endif
...@@ -2242,61 +2242,44 @@ static bool _print_ascii_file(const char* filename, outputStream* st) { ...@@ -2242,61 +2242,44 @@ static bool _print_ascii_file(const char* filename, outputStream* st) {
return true; return true;
} }
void os::print_os_info_brief(outputStream* st) {
os::Solaris::print_distro_info(st);
os::Posix::print_uname_info(st);
os::Solaris::print_libversion_info(st);
}
void os::print_os_info(outputStream* st) { void os::print_os_info(outputStream* st) {
st->print("OS:"); st->print("OS:");
if (!_print_ascii_file("/etc/release", st)) { os::Solaris::print_distro_info(st);
st->print("Solaris");
}
st->cr();
// kernel os::Posix::print_uname_info(st);
st->print("uname:");
struct utsname name;
uname(&name);
st->print(name.sysname); st->print(" ");
st->print(name.release); st->print(" ");
st->print(name.version); st->print(" ");
st->print(name.machine);
// libthread
if (os::Solaris::T2_libthread()) st->print(" (T2 libthread)");
else st->print(" (T1 libthread)");
st->cr();
// rlimit os::Solaris::print_libversion_info(st);
st->print("rlimit:");
struct rlimit rlim;
st->print(" STACK ");
getrlimit(RLIMIT_STACK, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", CORE ");
getrlimit(RLIMIT_CORE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->print(", NOFILE ");
getrlimit(RLIMIT_NOFILE, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%d", rlim.rlim_cur);
st->print(", AS ");
getrlimit(RLIMIT_AS, &rlim);
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
else st->print("%uk", rlim.rlim_cur >> 10);
st->cr();
// load average os::Posix::print_rlimit_info(st);
st->print("load average:");
double loadavg[3]; os::Posix::print_load_average(st);
os::loadavg(loadavg, 3);
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
st->cr();
} }
void os::Solaris::print_distro_info(outputStream* st) {
if (!_print_ascii_file("/etc/release", st)) {
st->print("Solaris");
}
st->cr();
}
void os::Solaris::print_libversion_info(outputStream* st) {
if (os::Solaris::T2_libthread()) {
st->print(" (T2 libthread)");
}
else {
st->print(" (T1 libthread)");
}
st->cr();
}
static bool check_addr0(outputStream* st) { static bool check_addr0(outputStream* st) {
jboolean status = false; jboolean status = false;
......
...@@ -180,6 +180,9 @@ class Solaris { ...@@ -180,6 +180,9 @@ class Solaris {
// proc_t structure (note that this is a system struct). // proc_t structure (note that this is a system struct).
static address _main_stack_base; static address _main_stack_base;
static void print_distro_info(outputStream* st);
static void print_libversion_info(outputStream* st);
public: public:
static void libthread_init(); static void libthread_init();
static void synchronization_init(); static void synchronization_init();
......
...@@ -1562,9 +1562,17 @@ void os::print_dll_info(outputStream *st) { ...@@ -1562,9 +1562,17 @@ void os::print_dll_info(outputStream *st) {
enumerate_modules(pid, _print_module, (void *)st); enumerate_modules(pid, _print_module, (void *)st);
} }
void os::print_os_info_brief(outputStream* st) {
os::print_os_info(st);
}
void os::print_os_info(outputStream* st) { void os::print_os_info(outputStream* st) {
st->print("OS:"); st->print("OS:");
os::win32::print_windows_version(st);
}
void os::win32::print_windows_version(outputStream* st) {
OSVERSIONINFOEX osvi; OSVERSIONINFOEX osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
// Win32_OS defines the interface to windows operating systems // Win32_OS defines the interface to windows operating systems
class win32 { class win32 {
friend class os;
protected: protected:
static int _vm_page_size; static int _vm_page_size;
...@@ -39,6 +40,8 @@ class win32 { ...@@ -39,6 +40,8 @@ class win32 {
static bool _is_windows_2003; static bool _is_windows_2003;
static bool _is_windows_server; static bool _is_windows_server;
static void print_windows_version(outputStream* st);
public: public:
// Windows-specific interface: // Windows-specific interface:
static void initialize_system_info(); static void initialize_system_info();
......
...@@ -492,6 +492,7 @@ class os: AllStatic { ...@@ -492,6 +492,7 @@ class os: AllStatic {
// Print out system information; they are called by fatal error handler. // Print out system information; they are called by fatal error handler.
// Output format may be different on different platforms. // Output format may be different on different platforms.
static void print_os_info(outputStream* st); static void print_os_info(outputStream* st);
static void print_os_info_brief(outputStream* st);
static void print_cpu_info(outputStream* st); static void print_cpu_info(outputStream* st);
static void pd_print_cpu_info(outputStream* st); static void pd_print_cpu_info(outputStream* st);
static void print_memory_info(outputStream* st); static void print_memory_info(outputStream* st);
...@@ -685,14 +686,17 @@ class os: AllStatic { ...@@ -685,14 +686,17 @@ class os: AllStatic {
// Platform dependent stuff // Platform dependent stuff
#ifdef TARGET_OS_FAMILY_linux #ifdef TARGET_OS_FAMILY_linux
# include "os_linux.hpp" # include "os_linux.hpp"
# include "os_posix.hpp"
#endif #endif
#ifdef TARGET_OS_FAMILY_solaris #ifdef TARGET_OS_FAMILY_solaris
# include "os_solaris.hpp" # include "os_solaris.hpp"
# include "os_posix.hpp"
#endif #endif
#ifdef TARGET_OS_FAMILY_windows #ifdef TARGET_OS_FAMILY_windows
# include "os_windows.hpp" # include "os_windows.hpp"
#endif #endif
#ifdef TARGET_OS_FAMILY_bsd #ifdef TARGET_OS_FAMILY_bsd
# include "os_posix.hpp"
# include "os_bsd.hpp" # include "os_bsd.hpp"
#endif #endif
#ifdef TARGET_OS_ARCH_linux_x86 #ifdef TARGET_OS_ARCH_linux_x86
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册