changeset 59699:34a4e4291d10

8246926: Clean up newlines and whitespaces in hs_err files Reviewed-by: dholmes, eosterlund, iklam
author stefank
date Wed, 10 Jun 2020 08:58:43 +0200
parents 7589335ecde5
children 3b0c7708ca6a
files src/hotspot/os/aix/os_aix.cpp src/hotspot/os/linux/os_linux.cpp src/hotspot/os/linux/os_linux.hpp src/hotspot/os/posix/os_posix.cpp src/hotspot/os/windows/os_windows.cpp src/hotspot/share/gc/g1/g1CollectedHeap.cpp src/hotspot/share/runtime/os.cpp src/hotspot/share/utilities/vmError.cpp test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java
diffstat 9 files changed, 67 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/os/aix/os_aix.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/os/aix/os_aix.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -1368,7 +1368,7 @@
 }
 
 void os::print_os_info(outputStream* st) {
-  st->print("OS:");
+  st->print_cr("OS:");
 
   os::Posix::print_uname_info(st);
 
--- a/src/hotspot/os/linux/os_linux.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/os/linux/os_linux.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -2069,8 +2069,8 @@
   return true;
 }
 
-static void _print_ascii_file_h(const char* header, const char* filename, outputStream* st) {
-  st->print_cr("%s:", header);
+static void _print_ascii_file_h(const char* header, const char* filename, outputStream* st, bool same_line = true) {
+  st->print("%s:%c", header, same_line ? ' ' : '\n');
   if (!_print_ascii_file(filename, st)) {
     st->print_cr("<Not Available>");
   }
@@ -2085,7 +2085,7 @@
   jio_snprintf(fname, sizeof(fname), "/proc/%d/maps", pid);
 
   if (!_print_ascii_file(fname, st)) {
-    st->print("Can not get library information for pid = %d\n", pid);
+    st->print_cr("Can not get library information for pid = %d", pid);
   }
 }
 
@@ -2137,7 +2137,7 @@
 }
 
 void os::print_os_info(outputStream* st) {
-  st->print("OS:");
+  st->print_cr("OS:");
 
   os::Linux::print_distro_info(st);
 
@@ -2147,8 +2147,7 @@
 
   // Print warning if unsafe chroot environment detected
   if (unsafe_chroot_detected) {
-    st->print("WARNING!! ");
-    st->print_cr("%s", unstable_chroot_error);
+    st->print_cr("WARNING!! %s", unstable_chroot_error);
   }
 
   os::Linux::print_libversion_info(st);
@@ -2156,14 +2155,21 @@
   os::Posix::print_rlimit_info(st);
 
   os::Posix::print_load_average(st);
+  st->cr();
 
   os::Linux::print_full_memory_info(st);
+  st->cr();
 
   os::Linux::print_proc_sys_info(st);
-
-  os::Linux::print_ld_preload_file(st);
-
-  os::Linux::print_container_info(st);
+  st->cr();
+
+  if (os::Linux::print_ld_preload_file(st)) {
+    st->cr();
+  }
+
+  if (os::Linux::print_container_info(st)) {
+    st->cr();
+  }
 
   VM_Version::print_platform_virtualization_info(st);
 
@@ -2224,9 +2230,8 @@
     st->print("Debian ");
     _print_ascii_file("/etc/debian_version", st);
   } else {
-    st->print("Linux");
-  }
-  st->cr();
+    st->print_cr("Linux");
+  }
 }
 
 static void parse_os_info_helper(FILE* fp, char* distro, size_t length, bool get_first_line) {
@@ -2295,14 +2300,13 @@
 
 void os::Linux::print_libversion_info(outputStream* st) {
   // libc, pthread
-  st->print("libc:");
+  st->print("libc: ");
   st->print("%s ", os::Linux::glibc_version());
   st->print("%s ", os::Linux::libpthread_version());
   st->cr();
 }
 
 void os::Linux::print_proc_sys_info(outputStream* st) {
-  st->cr();
   _print_ascii_file_h("/proc/sys/kernel/threads-max (system-wide limit on the number of threads)",
                       "/proc/sys/kernel/threads-max", st);
   _print_ascii_file_h("/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have)",
@@ -2312,7 +2316,7 @@
 }
 
 void os::Linux::print_full_memory_info(outputStream* st) {
-  _print_ascii_file_h("\n/proc/meminfo", "/proc/meminfo", st);
+  _print_ascii_file_h("/proc/meminfo", "/proc/meminfo", st, false);
   st->cr();
 
   // some information regarding THPs; for details see
@@ -2323,9 +2327,8 @@
                       "/sys/kernel/mm/transparent_hugepage/defrag", st);
 }
 
-void os::Linux::print_ld_preload_file(outputStream* st) {
-  _print_ascii_file("/etc/ld.so.preload", st, "\n/etc/ld.so.preload:");
-  st->cr();
+bool os::Linux::print_ld_preload_file(outputStream* st) {
+  return _print_ascii_file("/etc/ld.so.preload", st, "/etc/ld.so.preload:");
 }
 
 void os::Linux::print_uptime_info(outputStream* st) {
@@ -2336,97 +2339,97 @@
   }
 }
 
-
-void os::Linux::print_container_info(outputStream* st) {
+bool os::Linux::print_container_info(outputStream* st) {
   if (!OSContainer::is_containerized()) {
-    return;
-  }
-
-  st->print("container (cgroup) information:\n");
+    return false;
+  }
+
+  st->print_cr("container (cgroup) information:");
 
   const char *p_ct = OSContainer::container_type();
-  st->print("container_type: %s\n", p_ct != NULL ? p_ct : "not supported");
+  st->print_cr("container_type: %s", p_ct != NULL ? p_ct : "not supported");
 
   char *p = OSContainer::cpu_cpuset_cpus();
-  st->print("cpu_cpuset_cpus: %s\n", p != NULL ? p : "not supported");
+  st->print_cr("cpu_cpuset_cpus: %s", p != NULL ? p : "not supported");
   free(p);
 
   p = OSContainer::cpu_cpuset_memory_nodes();
-  st->print("cpu_memory_nodes: %s\n", p != NULL ? p : "not supported");
+  st->print_cr("cpu_memory_nodes: %s", p != NULL ? p : "not supported");
   free(p);
 
   int i = OSContainer::active_processor_count();
   st->print("active_processor_count: ");
   if (i > 0) {
-    st->print("%d\n", i);
+    st->print_cr("%d", i);
   } else {
-    st->print("not supported\n");
+    st->print_cr("not supported");
   }
 
   i = OSContainer::cpu_quota();
   st->print("cpu_quota: ");
   if (i > 0) {
-    st->print("%d\n", i);
+    st->print_cr("%d", i);
   } else {
-    st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no quota");
+    st->print_cr("%s", i == OSCONTAINER_ERROR ? "not supported" : "no quota");
   }
 
   i = OSContainer::cpu_period();
   st->print("cpu_period: ");
   if (i > 0) {
-    st->print("%d\n", i);
+    st->print_cr("%d", i);
   } else {
-    st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no period");
+    st->print_cr("%s", i == OSCONTAINER_ERROR ? "not supported" : "no period");
   }
 
   i = OSContainer::cpu_shares();
   st->print("cpu_shares: ");
   if (i > 0) {
-    st->print("%d\n", i);
+    st->print_cr("%d", i);
   } else {
-    st->print("%s\n", i == OSCONTAINER_ERROR ? "not supported" : "no shares");
+    st->print_cr("%s", i == OSCONTAINER_ERROR ? "not supported" : "no shares");
   }
 
   jlong j = OSContainer::memory_limit_in_bytes();
   st->print("memory_limit_in_bytes: ");
   if (j > 0) {
-    st->print(JLONG_FORMAT "\n", j);
+    st->print_cr(JLONG_FORMAT, j);
   } else {
-    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+    st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
   }
 
   j = OSContainer::memory_and_swap_limit_in_bytes();
   st->print("memory_and_swap_limit_in_bytes: ");
   if (j > 0) {
-    st->print(JLONG_FORMAT "\n", j);
+    st->print_cr(JLONG_FORMAT, j);
   } else {
-    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+    st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
   }
 
   j = OSContainer::memory_soft_limit_in_bytes();
   st->print("memory_soft_limit_in_bytes: ");
   if (j > 0) {
-    st->print(JLONG_FORMAT "\n", j);
+    st->print_cr(JLONG_FORMAT, j);
   } else {
-    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+    st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
   }
 
   j = OSContainer::OSContainer::memory_usage_in_bytes();
   st->print("memory_usage_in_bytes: ");
   if (j > 0) {
-    st->print(JLONG_FORMAT "\n", j);
+    st->print_cr(JLONG_FORMAT, j);
   } else {
-    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+    st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
   }
 
   j = OSContainer::OSContainer::memory_max_usage_in_bytes();
   st->print("memory_max_usage_in_bytes: ");
   if (j > 0) {
-    st->print(JLONG_FORMAT "\n", j);
+    st->print_cr(JLONG_FORMAT, j);
   } else {
-    st->print("%s\n", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
-  }
-  st->cr();
+    st->print_cr("%s", j == OSCONTAINER_ERROR ? "not supported" : "unlimited");
+  }
+
+  return true;
 }
 
 void os::Linux::print_steal_info(outputStream* st) {
@@ -2556,8 +2559,9 @@
 void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) {
   // Only print the model name if the platform provides this as a summary
   if (!print_model_name_and_flags(st, buf, buflen)) {
-    _print_ascii_file_h("\n/proc/cpuinfo", "/proc/cpuinfo", st);
-  }
+    _print_ascii_file_h("/proc/cpuinfo", "/proc/cpuinfo", st, false);
+  }
+  st->cr();
   print_sys_devices_cpu_info(st, buf, buflen);
 }
 
--- a/src/hotspot/os/linux/os_linux.hpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/os/linux/os_linux.hpp	Wed Jun 10 08:58:43 2020 +0200
@@ -102,12 +102,12 @@
   static bool release_memory_special_huge_tlbfs(char* base, size_t bytes);
 
   static void print_full_memory_info(outputStream* st);
-  static void print_container_info(outputStream* st);
+  static bool print_container_info(outputStream* st);
   static void print_steal_info(outputStream* st);
   static void print_distro_info(outputStream* st);
   static void print_libversion_info(outputStream* st);
   static void print_proc_sys_info(outputStream* st);
-  static void print_ld_preload_file(outputStream* st);
+  static bool print_ld_preload_file(outputStream* st);
   static void print_uptime_info(outputStream* st);
 
  public:
--- a/src/hotspot/os/posix/os_posix.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/os/posix/os_posix.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -396,7 +396,7 @@
 }
 
 void os::Posix::print_load_average(outputStream* st) {
-  st->print("load average:");
+  st->print("load average: ");
   double loadavg[3];
   int res = os::loadavg(loadavg, 3);
   if (res != -1) {
@@ -490,7 +490,7 @@
 
 void os::Posix::print_uname_info(outputStream* st) {
   // kernel
-  st->print("uname:");
+  st->print("uname: ");
   struct utsname name;
   uname(&name);
   st->print("%s ", name.sysname);
--- a/src/hotspot/os/windows/os_windows.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/os/windows/os_windows.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -1607,7 +1607,7 @@
     st->print("N/A ");
   }
 #endif
-  st->print("OS:");
+  st->print_cr("OS:");
   os::win32::print_windows_version(st);
 
   os::win32::print_uptime_info(st);
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -2555,7 +2555,10 @@
   print_on(st);
 
   // Print the per-region information.
-  print_regions_on(st);
+  if (_hrm != NULL) {
+    st->cr();
+    print_regions_on(st);
+  }
 }
 
 void G1CollectedHeap::print_on_error(outputStream* st) const {
--- a/src/hotspot/share/runtime/os.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/share/runtime/os.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -959,7 +959,7 @@
 void os::print_cpu_info(outputStream* st, char* buf, size_t buflen) {
   // cpu
   st->print("CPU:");
-  st->print("total %d", os::processor_count());
+  st->print(" total %d", os::processor_count());
   // It's not safe to query number of active processors after crash
   // st->print("(active %d)", os::active_processor_count()); but we can
   // print the initial number of active processors.
--- a/src/hotspot/share/utilities/vmError.cpp	Wed Jun 10 08:57:50 2020 +0200
+++ b/src/hotspot/share/utilities/vmError.cpp	Wed Jun 10 08:58:43 2020 +0200
@@ -878,7 +878,7 @@
 
      if (_verbose) {
        // Safepoint state
-       st->print("VM state:");
+       st->print("VM state: ");
 
        if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing");
        else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint");
--- a/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java	Wed Jun 10 08:57:50 2020 +0200
+++ b/test/hotspot/jtreg/runtime/logging/OsCpuLoggingTest.java	Wed Jun 10 08:58:43 2020 +0200
@@ -45,7 +45,7 @@
     }
 
     static void analyzeOutputForOsCpuLog(OutputAnalyzer output) throws Exception {
-        output.shouldContain("CPU:total");
+        output.shouldContain("CPU: total");
         output.shouldHaveExitValue(0);
     }