2026 // Most Linux distributions have a /etc/XXX-release file, which contains 2027 // the OS version string. Newer Linux distributions have a /etc/lsb-release 2028 // file that also contains the OS version string. Some have more than one 2029 // /etc/XXX-release file (e.g. Mandrake has both /etc/mandrake-release and 2030 // /etc/redhat-release.), so the order is important. 2031 // Any Linux that is based on Redhat (i.e. Oracle, Mandrake, Sun JDS...) have 2032 // their own specific XXX-release file as well as a redhat-release file. 2033 // Because of this the XXX-release file needs to be searched for before the 2034 // redhat-release file. 2035 // Since Red Hat has a lsb-release file that is not very descriptive the 2036 // search for redhat-release needs to be before lsb-release. 2037 // Since the lsb-release file is the new standard it needs to be searched 2038 // before the older style release files. 2039 // Searching system-release (Red Hat) and os-release (other Linuxes) are a 2040 // next to last resort. The os-release file is a new standard that contains 2041 // distribution information and the system-release file seems to be an old 2042 // standard that has been replaced by the lsb-release and os-release files. 2043 // Searching for the debian_version file is the last resort. It contains 2044 // an informative string like "6.0.6" or "wheezy/sid". Because of this 2045 // "Debian " is printed before the contents of the debian_version file. 2046 void os::Linux::print_distro_info(outputStream* st) { 2047 if (!_print_ascii_file("/etc/oracle-release", st) && 2048 !_print_ascii_file("/etc/mandriva-release", st) && 2049 !_print_ascii_file("/etc/mandrake-release", st) && 2050 !_print_ascii_file("/etc/sun-release", st) && 2051 !_print_ascii_file("/etc/redhat-release", st) && 2052 !_print_ascii_file("/etc/lsb-release", st) && 2053 !_print_ascii_file("/etc/SuSE-release", st) && 2054 !_print_ascii_file("/etc/turbolinux-release", st) && 2055 !_print_ascii_file("/etc/gentoo-release", st) && 2056 !_print_ascii_file("/etc/ltib-release", st) && 2057 !_print_ascii_file("/etc/angstrom-version", st) && 2058 !_print_ascii_file("/etc/system-release", st) && 2059 !_print_ascii_file("/etc/os-release", st)) { 2060 2061 if (file_exists("/etc/debian_version")) { 2062 st->print("Debian "); 2063 _print_ascii_file("/etc/debian_version", st); 2064 } else { 2065 st->print("Linux"); 2066 } 2067 } 2068 st->cr(); 2069 } 2070 2071 void os::Linux::print_libversion_info(outputStream* st) { 2072 // libc, pthread 2073 st->print("libc:"); 2074 st->print("%s ", os::Linux::glibc_version()); 2075 st->print("%s ", os::Linux::libpthread_version()); 2076 st->cr(); 2077 } 2078 2079 void os::Linux::print_full_memory_info(outputStream* st) { 2080 st->print("\n/proc/meminfo:\n"); 2081 _print_ascii_file("/proc/meminfo", st); 2082 st->cr(); 2083 } 2084 2085 void os::print_memory_info(outputStream* st) { 2086 2087 st->print("Memory:"); 2088 st->print(" %dk page", os::vm_page_size()>>10); 2089 2090 // values in struct sysinfo are "unsigned long" 2131 st->print_raw(buf); 2132 fclose(fp); 2133 return true; 2134 } 2135 } 2136 } 2137 fclose(fp); 2138 } 2139 #endif // x86 platforms 2140 return false; 2141 } 2142 2143 void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { 2144 // Only print the model name if the platform provides this as a summary 2145 if (!print_model_name_and_flags(st, buf, buflen)) { 2146 st->print("\n/proc/cpuinfo:\n"); 2147 if (!_print_ascii_file("/proc/cpuinfo", st)) { 2148 st->print_cr(" <Not Available>"); 2149 } 2150 } 2151 } 2152 2153 void os::print_siginfo(outputStream* st, void* siginfo) { 2154 const siginfo_t* si = (const siginfo_t*)siginfo; 2155 2156 os::Posix::print_siginfo_brief(st, si); 2157 #if INCLUDE_CDS 2158 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) && 2159 UseSharedSpaces) { 2160 FileMapInfo* mapinfo = FileMapInfo::current_info(); 2161 if (mapinfo->is_in_shared_space(si->si_addr)) { 2162 st->print("\n\nError accessing class data sharing archive." \ 2163 " Mapped file inaccessible during execution, " \ 2164 " possible disk/network problem."); 2165 } 2166 } 2167 #endif 2168 st->cr(); 2169 } 2170 | 2026 // Most Linux distributions have a /etc/XXX-release file, which contains 2027 // the OS version string. Newer Linux distributions have a /etc/lsb-release 2028 // file that also contains the OS version string. Some have more than one 2029 // /etc/XXX-release file (e.g. Mandrake has both /etc/mandrake-release and 2030 // /etc/redhat-release.), so the order is important. 2031 // Any Linux that is based on Redhat (i.e. Oracle, Mandrake, Sun JDS...) have 2032 // their own specific XXX-release file as well as a redhat-release file. 2033 // Because of this the XXX-release file needs to be searched for before the 2034 // redhat-release file. 2035 // Since Red Hat has a lsb-release file that is not very descriptive the 2036 // search for redhat-release needs to be before lsb-release. 2037 // Since the lsb-release file is the new standard it needs to be searched 2038 // before the older style release files. 2039 // Searching system-release (Red Hat) and os-release (other Linuxes) are a 2040 // next to last resort. The os-release file is a new standard that contains 2041 // distribution information and the system-release file seems to be an old 2042 // standard that has been replaced by the lsb-release and os-release files. 2043 // Searching for the debian_version file is the last resort. It contains 2044 // an informative string like "6.0.6" or "wheezy/sid". Because of this 2045 // "Debian " is printed before the contents of the debian_version file. 2046 2047 const char* distro_files[] = { 2048 "/etc/oracle-release", 2049 "/etc/mandriva-release", 2050 "/etc/mandrake-release", 2051 "/etc/sun-release", 2052 "/etc/redhat-release", 2053 "/etc/lsb-release", 2054 "/etc/SuSE-release", 2055 "/etc/turbolinux-release", 2056 "/etc/gentoo-release", 2057 "/etc/ltib-release", 2058 "/etc/angstrom-version", 2059 "/etc/system-release", 2060 "/etc/os-release", 2061 NULL }; 2062 2063 void os::Linux::print_distro_info(outputStream* st) { 2064 for (int i = 0;; i++) { 2065 const char* file = distro_files[i]; 2066 if (file == NULL) break; 2067 // If file prints, we found it. 2068 if (_print_ascii_file(file, st)) return; 2069 } 2070 if (file_exists("/etc/debian_version")) { 2071 st->print("Debian "); 2072 _print_ascii_file("/etc/debian_version", st); 2073 } else { 2074 st->print("Linux"); 2075 } 2076 st->cr(); 2077 } 2078 2079 static void parse_os_info(char* distro, size_t length, const char* file) { 2080 FILE* fp = fopen(file, "r"); 2081 if (fp != NULL) { 2082 char buf[257]; 2083 // get last line of the file. 2084 while (!feof(fp)) { 2085 fgets(buf, sizeof(buf), fp); 2086 } 2087 // Edit out ubuntu things 2088 if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL) { 2089 char* ptr = strstr(buf, "\""); 2090 if (ptr != NULL) { 2091 ptr++; // go beyond first " 2092 char* nl = strchr(ptr, '\"'); 2093 if (nl != NULL) *nl = '\0'; 2094 strncpy(distro, ptr, length); 2095 fclose(fp); 2096 return; 2097 } 2098 } else { 2099 // if not Ubuntu, print out whole line minus \n 2100 char* nl = strchr(buf, '\n'); 2101 if (nl != NULL) *nl = '\0'; 2102 strncpy(distro, buf, length); 2103 fclose(fp); 2104 return; 2105 } 2106 } 2107 } 2108 2109 void os::get_summary_os_info(char* buf, size_t buflen) { 2110 for (int i = 0;; i++) { 2111 const char* file = distro_files[i]; 2112 if (file == NULL) break; 2113 if (file_exists(file)) { 2114 parse_os_info(buf, buflen, file); 2115 return; 2116 } 2117 } 2118 // special case for debian 2119 if (file_exists("/etc/debian_version")) { 2120 strncpy(buf, "Debian ", buflen); 2121 parse_os_info(&buf[7], buflen-7, "/etc/debian_version"); 2122 } else { 2123 strncpy(buf, "Linux", buflen); 2124 } 2125 } 2126 2127 void os::Linux::print_libversion_info(outputStream* st) { 2128 // libc, pthread 2129 st->print("libc:"); 2130 st->print("%s ", os::Linux::glibc_version()); 2131 st->print("%s ", os::Linux::libpthread_version()); 2132 st->cr(); 2133 } 2134 2135 void os::Linux::print_full_memory_info(outputStream* st) { 2136 st->print("\n/proc/meminfo:\n"); 2137 _print_ascii_file("/proc/meminfo", st); 2138 st->cr(); 2139 } 2140 2141 void os::print_memory_info(outputStream* st) { 2142 2143 st->print("Memory:"); 2144 st->print(" %dk page", os::vm_page_size()>>10); 2145 2146 // values in struct sysinfo are "unsigned long" 2187 st->print_raw(buf); 2188 fclose(fp); 2189 return true; 2190 } 2191 } 2192 } 2193 fclose(fp); 2194 } 2195 #endif // x86 platforms 2196 return false; 2197 } 2198 2199 void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { 2200 // Only print the model name if the platform provides this as a summary 2201 if (!print_model_name_and_flags(st, buf, buflen)) { 2202 st->print("\n/proc/cpuinfo:\n"); 2203 if (!_print_ascii_file("/proc/cpuinfo", st)) { 2204 st->print_cr(" <Not Available>"); 2205 } 2206 } 2207 } 2208 2209 const char* search_string = IA32_ONLY("model name") AMD64_ONLY("model name") 2210 IA64_ONLY("") SPARC_ONLY("cpu") 2211 ARM32_ONLY("Processor") PPC_ONLY("Processor") AARCH64_ONLY("Processor"); 2212 2213 // Parses the cpuinfo file for string representing the model name. 2214 void os::get_summary_cpu_info(char* cpuinfo, size_t length) { 2215 FILE* fp = fopen("/proc/cpuinfo", "r"); 2216 if (fp != NULL) { 2217 while (!feof(fp)) { 2218 char buf[257]; 2219 if (fgets(buf, sizeof(buf), fp)) { 2220 char* start = strstr(buf, search_string); 2221 if (start != NULL) { 2222 char *ptr = start + strlen(search_string); 2223 char *end = buf + strlen(buf); 2224 while (ptr != end) { 2225 // skip whitespace and colon for the rest of the name. 2226 if (*ptr != ' ' && *ptr != '\t' && *ptr != ':') { 2227 break; 2228 } 2229 ptr++; 2230 } 2231 if (ptr != end) { 2232 // reasonable string, get rid of newline and keep the rest 2233 char* nl = strchr(buf, '\n'); 2234 if (nl != NULL) *nl = '\0'; 2235 strncpy(cpuinfo, ptr, length); 2236 fclose(fp); 2237 return; 2238 } 2239 } 2240 } 2241 } 2242 } 2243 // cpuinfo not found or parsing failed, just print generic string. The entire 2244 // /proc/cpuinfo file will be printed later in the file (or enough of it for x86) 2245 strncpy(cpuinfo, IA32_ONLY("x86 IA32") AMD64_ONLY("x86 IA64") 2246 IA64_ONLY("IA64") SPARC_ONLY("sparcv9") 2247 ARM32_ONLY("arm32") PPC_ONLY("PPC64") AARCH64_ONLY("AARCH64"), length); 2248 } 2249 2250 void os::print_siginfo(outputStream* st, void* siginfo) { 2251 const siginfo_t* si = (const siginfo_t*)siginfo; 2252 2253 os::Posix::print_siginfo_brief(st, si); 2254 #if INCLUDE_CDS 2255 if (si && (si->si_signo == SIGBUS || si->si_signo == SIGSEGV) && 2256 UseSharedSpaces) { 2257 FileMapInfo* mapinfo = FileMapInfo::current_info(); 2258 if (mapinfo->is_in_shared_space(si->si_addr)) { 2259 st->print("\n\nError accessing class data sharing archive." \ 2260 " Mapped file inaccessible during execution, " \ 2261 " possible disk/network problem."); 2262 } 2263 } 2264 #endif 2265 st->cr(); 2266 } 2267 |