8219098: Make output of region strings more regular in error messages
authortschatzl
Wed, 20 Feb 2019 10:48:36 +0100
changeset 53839 31dde2f0ddf1
parent 53838 c8c9bd65c198
child 53840 9a0fd1f82406
8219098: Make output of region strings more regular in error messages Summary: Error messages should use the HR_PARAMS/HR_FORMAT_PARAMS macros to print information about HeapRegions. Reviewed-by: kbarrett, lkorinth
src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp
src/hotspot/share/gc/g1/heapRegion.cpp
--- a/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp	Wed Feb 20 09:53:28 2019 +0100
+++ b/src/hotspot/share/gc/g1/g1FullGCOopClosures.cpp	Wed Feb 20 10:48:36 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -71,26 +71,19 @@
       }
       if (!_g1h->is_in_closed_subset(obj)) {
         HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
-        yy.print_cr("Field " PTR_FORMAT
-            " of live obj " PTR_FORMAT " in region "
-            "[" PTR_FORMAT ", " PTR_FORMAT ")",
-            p2i(p), p2i(_containing_obj),
-            p2i(from->bottom()), p2i(from->end()));
+        yy.print_cr("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
         print_object(&yy, _containing_obj);
         yy.print_cr("points to obj " PTR_FORMAT " not in the heap",
-            p2i(obj));
+                    p2i(obj));
       } else {
         HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
         HeapRegion* to   = _g1h->heap_region_containing((HeapWord*)obj);
-        yy.print_cr("Field " PTR_FORMAT
-            " of live obj " PTR_FORMAT " in region "
-            "[" PTR_FORMAT ", " PTR_FORMAT ")",
-            p2i(p), p2i(_containing_obj),
-            p2i(from->bottom()), p2i(from->end()));
+        yy.print_cr("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
         print_object(&yy, _containing_obj);
-        yy.print_cr("points to dead obj " PTR_FORMAT " in region "
-            "[" PTR_FORMAT ", " PTR_FORMAT ")",
-            p2i(obj), p2i(to->bottom()), p2i(to->end()));
+        yy.print_cr("points to dead obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(obj), HR_FORMAT_PARAMS(to));
         print_object(&yy, obj);
       }
       yy.print_cr("----------");
--- a/src/hotspot/share/gc/g1/heapRegion.cpp	Wed Feb 20 09:53:28 2019 +0100
+++ b/src/hotspot/share/gc/g1/heapRegion.cpp	Wed Feb 20 10:48:36 2019 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -336,8 +336,8 @@
         // Object is in the region. Check that its less than top
         if (_hr->top() <= (HeapWord*)obj) {
           // Object is above top
-          log_error(gc, verify)("Object " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ") is above top " PTR_FORMAT,
-                               p2i(obj), p2i(_hr->bottom()), p2i(_hr->end()), p2i(_hr->top()));
+          log_error(gc, verify)("Object " PTR_FORMAT " in region " HR_FORMAT " is above top ",
+                                p2i(obj), HR_FORMAT_PARAMS(_hr));
           _failures = true;
           return;
         }
@@ -415,8 +415,8 @@
   // on its strong code root list
   if (is_empty()) {
     if (strong_code_roots_length > 0) {
-      log_error(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] is empty but has " SIZE_FORMAT " code root entries",
-                            p2i(bottom()), p2i(end()), strong_code_roots_length);
+      log_error(gc, verify)("region " HR_FORMAT " is empty but has " SIZE_FORMAT " code root entries",
+                            HR_FORMAT_PARAMS(this), strong_code_roots_length);
       *failures = true;
     }
     return;
@@ -524,21 +524,22 @@
         ResourceMark rm;
         if (!_g1h->is_in_closed_subset(obj)) {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
-          log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
-            p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
+          log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
           LogStream ls(log.error());
           print_object(&ls, _containing_obj);
           HeapRegion* const to = _g1h->heap_region_containing(obj);
-          log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s", p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
+          log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s",
+                    p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
         } else {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
           HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj);
-          log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
-            p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
+          log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
           LogStream ls(log.error());
           print_object(&ls, _containing_obj);
-          log.error("points to dead obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
-            p2i(obj), p2i(to->bottom()), p2i(to->end()));
+          log.error("points to dead obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(obj), HR_FORMAT_PARAMS(to));
           print_object(&ls, obj);
         }
         log.error("----------");
@@ -593,12 +594,13 @@
             log.error("----------");
           }
           log.error("Missing rem set entry:");
-          log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
-            p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
+          log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT " in region " HR_FORMAT,
+                    p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
           ResourceMark rm;
           LogStream ls(log.error());
           _containing_obj->print_on(&ls);
-          log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s", p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
+          log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s",
+                    p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
           if (oopDesc::is_oop(obj)) {
             obj->print_on(&ls);
           }