hotspot/src/os/linux/vm/os_linux.cpp
changeset 12735 3e2e491f4f69
parent 12116 d81396ae8bf6
child 13195 be27e1b6a4b9
equal deleted inserted replaced
12734:98682ebd7a8b 12735:3e2e491f4f69
  2018    if (!_print_ascii_file(fname, st)) {
  2018    if (!_print_ascii_file(fname, st)) {
  2019      st->print("Can not get library information for pid = %d\n", pid);
  2019      st->print("Can not get library information for pid = %d\n", pid);
  2020    }
  2020    }
  2021 }
  2021 }
  2022 
  2022 
       
  2023 void os::print_os_info_brief(outputStream* st) {
       
  2024   os::Linux::print_distro_info(st);
       
  2025 
       
  2026   os::Posix::print_uname_info(st);
       
  2027 
       
  2028   os::Linux::print_libversion_info(st);
       
  2029 
       
  2030 }
  2023 
  2031 
  2024 void os::print_os_info(outputStream* st) {
  2032 void os::print_os_info(outputStream* st) {
  2025   st->print("OS:");
  2033   st->print("OS:");
  2026 
  2034 
  2027   // Try to identify popular distros.
  2035   os::Linux::print_distro_info(st);
  2028   // Most Linux distributions have /etc/XXX-release file, which contains
  2036 
  2029   // the OS version string. Some have more than one /etc/XXX-release file
  2037   os::Posix::print_uname_info(st);
  2030   // (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
  2038 
  2031   // so the order is important.
  2039   // Print warning if unsafe chroot environment detected
       
  2040   if (unsafe_chroot_detected) {
       
  2041     st->print("WARNING!! ");
       
  2042     st->print_cr(unstable_chroot_error);
       
  2043   }
       
  2044 
       
  2045   os::Linux::print_libversion_info(st);
       
  2046 
       
  2047   os::Posix::print_rlimit_info(st);
       
  2048 
       
  2049   os::Posix::print_load_average(st);
       
  2050 
       
  2051   os::Linux::print_full_memory_info(st);
       
  2052 }
       
  2053 
       
  2054 // Try to identify popular distros.
       
  2055 // Most Linux distributions have /etc/XXX-release file, which contains
       
  2056 // the OS version string. Some have more than one /etc/XXX-release file
       
  2057 // (e.g. Mandrake has both /etc/mandrake-release and /etc/redhat-release.),
       
  2058 // so the order is important.
       
  2059 void os::Linux::print_distro_info(outputStream* st) {
  2032   if (!_print_ascii_file("/etc/mandrake-release", st) &&
  2060   if (!_print_ascii_file("/etc/mandrake-release", st) &&
  2033       !_print_ascii_file("/etc/sun-release", st) &&
  2061       !_print_ascii_file("/etc/sun-release", st) &&
  2034       !_print_ascii_file("/etc/redhat-release", st) &&
  2062       !_print_ascii_file("/etc/redhat-release", st) &&
  2035       !_print_ascii_file("/etc/SuSE-release", st) &&
  2063       !_print_ascii_file("/etc/SuSE-release", st) &&
  2036       !_print_ascii_file("/etc/turbolinux-release", st) &&
  2064       !_print_ascii_file("/etc/turbolinux-release", st) &&
  2039       !_print_ascii_file("/etc/ltib-release", st) &&
  2067       !_print_ascii_file("/etc/ltib-release", st) &&
  2040       !_print_ascii_file("/etc/angstrom-version", st)) {
  2068       !_print_ascii_file("/etc/angstrom-version", st)) {
  2041       st->print("Linux");
  2069       st->print("Linux");
  2042   }
  2070   }
  2043   st->cr();
  2071   st->cr();
  2044 
  2072 }
  2045   // kernel
  2073 
  2046   st->print("uname:");
  2074 void os::Linux::print_libversion_info(outputStream* st) {
  2047   struct utsname name;
       
  2048   uname(&name);
       
  2049   st->print(name.sysname); st->print(" ");
       
  2050   st->print(name.release); st->print(" ");
       
  2051   st->print(name.version); st->print(" ");
       
  2052   st->print(name.machine);
       
  2053   st->cr();
       
  2054 
       
  2055   // Print warning if unsafe chroot environment detected
       
  2056   if (unsafe_chroot_detected) {
       
  2057     st->print("WARNING!! ");
       
  2058     st->print_cr(unstable_chroot_error);
       
  2059   }
       
  2060 
       
  2061   // libc, pthread
  2075   // libc, pthread
  2062   st->print("libc:");
  2076   st->print("libc:");
  2063   st->print(os::Linux::glibc_version()); st->print(" ");
  2077   st->print(os::Linux::glibc_version()); st->print(" ");
  2064   st->print(os::Linux::libpthread_version()); st->print(" ");
  2078   st->print(os::Linux::libpthread_version()); st->print(" ");
  2065   if (os::Linux::is_LinuxThreads()) {
  2079   if (os::Linux::is_LinuxThreads()) {
  2066      st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
  2080      st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed");
  2067   }
  2081   }
  2068   st->cr();
  2082   st->cr();
  2069 
  2083 }
  2070   // rlimit
  2084 
  2071   st->print("rlimit:");
  2085 void os::Linux::print_full_memory_info(outputStream* st) {
  2072   struct rlimit rlim;
  2086    st->print("\n/proc/meminfo:\n");
  2073 
  2087    _print_ascii_file("/proc/meminfo", st);
  2074   st->print(" STACK ");
  2088    st->cr();
  2075   getrlimit(RLIMIT_STACK, &rlim);
       
  2076   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
       
  2077   else st->print("%uk", rlim.rlim_cur >> 10);
       
  2078 
       
  2079   st->print(", CORE ");
       
  2080   getrlimit(RLIMIT_CORE, &rlim);
       
  2081   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
       
  2082   else st->print("%uk", rlim.rlim_cur >> 10);
       
  2083 
       
  2084   st->print(", NPROC ");
       
  2085   getrlimit(RLIMIT_NPROC, &rlim);
       
  2086   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
       
  2087   else st->print("%d", rlim.rlim_cur);
       
  2088 
       
  2089   st->print(", NOFILE ");
       
  2090   getrlimit(RLIMIT_NOFILE, &rlim);
       
  2091   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
       
  2092   else st->print("%d", rlim.rlim_cur);
       
  2093 
       
  2094   st->print(", AS ");
       
  2095   getrlimit(RLIMIT_AS, &rlim);
       
  2096   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
       
  2097   else st->print("%uk", rlim.rlim_cur >> 10);
       
  2098   st->cr();
       
  2099 
       
  2100   // load average
       
  2101   st->print("load average:");
       
  2102   double loadavg[3];
       
  2103   os::loadavg(loadavg, 3);
       
  2104   st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
       
  2105   st->cr();
       
  2106 
       
  2107   // meminfo
       
  2108   st->print("\n/proc/meminfo:\n");
       
  2109   _print_ascii_file("/proc/meminfo", st);
       
  2110   st->cr();
       
  2111 }
       
  2112 
       
  2113 void os::pd_print_cpu_info(outputStream* st) {
       
  2114   st->print("\n/proc/cpuinfo:\n");
       
  2115   if (!_print_ascii_file("/proc/cpuinfo", st)) {
       
  2116     st->print("  <Not Available>");
       
  2117   }
       
  2118   st->cr();
       
  2119 }
  2089 }
  2120 
  2090 
  2121 void os::print_memory_info(outputStream* st) {
  2091 void os::print_memory_info(outputStream* st) {
  2122 
  2092 
  2123   st->print("Memory:");
  2093   st->print("Memory:");
  2133             os::available_memory() >> 10);
  2103             os::available_memory() >> 10);
  2134   st->print(", swap " UINT64_FORMAT "k",
  2104   st->print(", swap " UINT64_FORMAT "k",
  2135             ((jlong)si.totalswap * si.mem_unit) >> 10);
  2105             ((jlong)si.totalswap * si.mem_unit) >> 10);
  2136   st->print("(" UINT64_FORMAT "k free)",
  2106   st->print("(" UINT64_FORMAT "k free)",
  2137             ((jlong)si.freeswap * si.mem_unit) >> 10);
  2107             ((jlong)si.freeswap * si.mem_unit) >> 10);
       
  2108   st->cr();
       
  2109 }
       
  2110 
       
  2111 void os::pd_print_cpu_info(outputStream* st) {
       
  2112   st->print("\n/proc/cpuinfo:\n");
       
  2113   if (!_print_ascii_file("/proc/cpuinfo", st)) {
       
  2114     st->print("  <Not Available>");
       
  2115   }
  2138   st->cr();
  2116   st->cr();
  2139 }
  2117 }
  2140 
  2118 
  2141 // Taken from /usr/include/bits/siginfo.h  Supposed to be architecture specific
  2119 // Taken from /usr/include/bits/siginfo.h  Supposed to be architecture specific
  2142 // but they're the same for all the linux arch that we support
  2120 // but they're the same for all the linux arch that we support