826 if (envvar != NULL) { 827 st->print("%s", env_list[i]); 828 st->print("="); 829 st->print_cr("%s", envvar); 830 } 831 } 832 } 833 } 834 835 void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) { 836 // cpu 837 st->print("CPU:"); 838 st->print("total %d", os::processor_count()); 839 // It's not safe to query number of active processors after crash 840 // st->print("(active %d)", os::active_processor_count()); 841 st->print(" %s", VM_Version::cpu_features()); 842 st->cr(); 843 pd_print_cpu_info(st, buf, buflen); 844 } 845 846 void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) { 847 const int secs_per_day = 86400; 848 const int secs_per_hour = 3600; 849 const int secs_per_min = 60; 850 851 time_t tloc; 852 (void)time(&tloc); 853 st->print("time: %s", ctime(&tloc)); // ctime adds newline. 854 855 struct tm tz; 856 if (localtime_pd(&tloc, &tz) != NULL) { 857 ::strftime(buf, buflen, "%Z", &tz); 858 st->print_cr("timezone: %s", buf); 859 } 860 861 double t = os::elapsedTime(); 862 // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in 863 // Linux. Must be a bug in glibc ? Workaround is to round "t" to int 864 // before printf. We lost some precision, but who cares? 865 int eltime = (int)t; // elapsed time in seconds 866 867 // print elapsed time in a human-readable format: 868 int eldays = eltime / secs_per_day; 869 int day_secs = eldays * secs_per_day; 870 int elhours = (eltime - day_secs) / secs_per_hour; 871 int hour_secs = elhours * secs_per_hour; 872 int elmins = (eltime - day_secs - hour_secs) / secs_per_min; 873 int minute_secs = elmins * secs_per_min; 874 int elsecs = (eltime - day_secs - hour_secs - minute_secs); 875 st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs); 876 } 877 878 // moved from debug.cpp (used to be find()) but still called from there 879 // The verbose parameter is only set by the debug code in one case 880 void os::print_location(outputStream* st, intptr_t x, bool verbose) { 881 address addr = (address)x; 882 CodeBlob* b = CodeCache::find_blob_unsafe(addr); 883 if (b != NULL) { 884 if (b->is_buffer_blob()) { 885 // the interpreter is generated into a buffer blob 886 InterpreterCodelet* i = Interpreter::codelet_containing(addr); 887 if (i != NULL) { 888 st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an Interpreter codelet", addr, (int)(addr - i->code_begin())); 889 i->print_on(st); 890 return; 891 } 892 if (Interpreter::contains(addr)) { 893 st->print_cr(INTPTR_FORMAT " is pointing into interpreter code" 894 " (not bytecode specific)", addr); 895 return; | 826 if (envvar != NULL) { 827 st->print("%s", env_list[i]); 828 st->print("="); 829 st->print_cr("%s", envvar); 830 } 831 } 832 } 833 } 834 835 void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) { 836 // cpu 837 st->print("CPU:"); 838 st->print("total %d", os::processor_count()); 839 // It's not safe to query number of active processors after crash 840 // st->print("(active %d)", os::active_processor_count()); 841 st->print(" %s", VM_Version::cpu_features()); 842 st->cr(); 843 pd_print_cpu_info(st, buf, buflen); 844 } 845 846 // Print a one line string summarizing the cpu, number of cores, memory, and operating system version 847 void os::print_summary_info(outputStream* st, char* buf, size_t buflen) { 848 st->print("Host: "); 849 #ifndef PRODUCT 850 if (get_host_name(buf, buflen)) { 851 st->print("%s, ", buf); 852 } 853 #endif // PRODUCT 854 get_summary_cpu_info(buf, buflen); 855 st->print("%s, ", buf); 856 st->print("%d cores, %dG, ", processor_count(), physical_memory()/G); 857 get_summary_os_info(buf, buflen); 858 st->print_raw(buf); 859 st->cr(); 860 } 861 862 void os::print_date_and_time(outputStream *st, char* buf, size_t buflen) { 863 const int secs_per_day = 86400; 864 const int secs_per_hour = 3600; 865 const int secs_per_min = 60; 866 867 time_t tloc; 868 (void)time(&tloc); 869 char* timestring = ctime(&tloc); // ctime adds newline. 870 // edit out the newline 871 char* nl = strchr(timestring, '\n'); 872 if (nl != NULL) { 873 *nl = '\0'; 874 } 875 876 struct tm tz; 877 if (localtime_pd(&tloc, &tz) != NULL) { 878 ::strftime(buf, buflen, "%Z", &tz); 879 st->print("Time: %s %s", timestring, buf); 880 } else { 881 st->print("Time: %s", timestring); 882 } 883 884 double t = os::elapsedTime(); 885 // NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in 886 // Linux. Must be a bug in glibc ? Workaround is to round "t" to int 887 // before printf. We lost some precision, but who cares? 888 int eltime = (int)t; // elapsed time in seconds 889 890 // print elapsed time in a human-readable format: 891 int eldays = eltime / secs_per_day; 892 int day_secs = eldays * secs_per_day; 893 int elhours = (eltime - day_secs) / secs_per_hour; 894 int hour_secs = elhours * secs_per_hour; 895 int elmins = (eltime - day_secs - hour_secs) / secs_per_min; 896 int minute_secs = elmins * secs_per_min; 897 int elsecs = (eltime - day_secs - hour_secs - minute_secs); 898 st->print_cr(" elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs); 899 } 900 901 // moved from debug.cpp (used to be find()) but still called from there 902 // The verbose parameter is only set by the debug code in one case 903 void os::print_location(outputStream* st, intptr_t x, bool verbose) { 904 address addr = (address)x; 905 CodeBlob* b = CodeCache::find_blob_unsafe(addr); 906 if (b != NULL) { 907 if (b->is_buffer_blob()) { 908 // the interpreter is generated into a buffer blob 909 InterpreterCodelet* i = Interpreter::codelet_containing(addr); 910 if (i != NULL) { 911 st->print_cr(INTPTR_FORMAT " is at code_begin+%d in an Interpreter codelet", addr, (int)(addr - i->code_begin())); 912 i->print_on(st); 913 return; 914 } 915 if (Interpreter::contains(addr)) { 916 st->print_cr(INTPTR_FORMAT " is pointing into interpreter code" 917 " (not bytecode specific)", addr); 918 return; |