9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "precompiled.hpp"
25
26 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
27 #include "gc_implementation/shenandoah/shenandoahForwarding.hpp"
28 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
29 #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp"
30 #include "gc_implementation/shenandoah/shenandoahUtils.hpp"
31 #include "memory/resourceArea.hpp"
32
33 void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
34 // Be extra safe. Only access data that is guaranteed to be safe:
35 // should be in heap, in known committed region, within that region.
36
37 ShenandoahHeap* heap = ShenandoahHeap::heap();
38 if (!heap->is_in(loc)) return;
39
40 ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
41 if (r != NULL && r->is_committed()) {
42 address start = MAX2((address) r->bottom(), (address) loc - 32);
43 address end = MIN2((address) r->end(), (address) loc + 128);
44 if (start >= end) return;
45
46 stringStream ss;
47 os::print_hex_dump(&ss, start, end, 4);
48 msg.append("\n");
49 msg.append("Raw heap memory:\n%s", ss.as_string());
50 }
51 }
52
53 void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) {
54 ShenandoahHeap* heap = ShenandoahHeap::heap();
55 ShenandoahHeapRegion *r = heap->heap_region_containing(obj);
56
57 ResourceMark rm;
58 stringStream ss;
59 r->print_on(&ss);
60
61 stringStream mw_ss;
62 obj->mark()->print_on(&mw_ss);
63
64 ShenandoahMarkingContext* const ctx = heap->marking_context();
65
66 msg.append(" " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name());
67 msg.append(" %3s allocated after mark start\n", ctx->allocated_after_mark_start((HeapWord *) obj) ? "" : "not");
68 msg.append(" %3s marked \n", ctx->is_marked(obj) ? "" : "not");
69 msg.append(" %3s in collection set\n", heap->in_collection_set(obj) ? "" : "not");
70 msg.append(" mark:%s\n", mw_ss.as_string());
71 msg.append(" region: %s", ss.as_string());
72 }
73
74 void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) {
75 ShenandoahHeap* heap = ShenandoahHeap::heap();
76 if (heap->is_in(loc)) {
77 msg.append(" inside Java heap\n");
78 ShenandoahHeapRegion *r = heap->heap_region_containing(loc);
79 stringStream ss;
80 r->print_on(&ss);
81
82 msg.append(" %3s in collection set\n", heap->in_collection_set(loc) ? "" : "not");
83 msg.append(" region: %s", ss.as_string());
84 } else {
85 msg.append(" outside of Java heap\n");
86 stringStream ss;
87 os::print_location(&ss, (intptr_t) loc, false);
|
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "precompiled.hpp"
25
26 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp"
27 #include "gc_implementation/shenandoah/shenandoahForwarding.hpp"
28 #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"
29 #include "gc_implementation/shenandoah/shenandoahHeapRegionSet.inline.hpp"
30 #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp"
31 #include "gc_implementation/shenandoah/shenandoahTraversalGC.hpp"
32 #include "gc_implementation/shenandoah/shenandoahUtils.hpp"
33 #include "memory/resourceArea.hpp"
34
35 void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) {
36 // Be extra safe. Only access data that is guaranteed to be safe:
37 // should be in heap, in known committed region, within that region.
38
39 ShenandoahHeap* heap = ShenandoahHeap::heap();
40 if (!heap->is_in(loc)) return;
41
42 ShenandoahHeapRegion* r = heap->heap_region_containing(loc);
43 if (r != NULL && r->is_committed()) {
44 address start = MAX2((address) r->bottom(), (address) loc - 32);
45 address end = MIN2((address) r->end(), (address) loc + 128);
46 if (start >= end) return;
47
48 stringStream ss;
49 os::print_hex_dump(&ss, start, end, 4);
50 msg.append("\n");
51 msg.append("Raw heap memory:\n%s", ss.as_string());
52 }
53 }
54
55 void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) {
56 ShenandoahHeap* heap = ShenandoahHeap::heap();
57 ShenandoahHeapRegion *r = heap->heap_region_containing(obj);
58
59 ResourceMark rm;
60 stringStream ss;
61 r->print_on(&ss);
62
63 stringStream mw_ss;
64 obj->mark()->print_on(&mw_ss);
65
66 ShenandoahMarkingContext* const ctx = heap->marking_context();
67
68 msg.append(" " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name());
69 msg.append(" %3s allocated after mark start\n", ctx->allocated_after_mark_start((HeapWord *) obj) ? "" : "not");
70 if (heap->traversal_gc() != NULL) {
71 msg.append(" %3s in traversal set\n", heap->traversal_gc()->traversal_set()->is_in((HeapWord*) obj) ? "" : "not");
72 }
73 msg.append(" %3s marked \n", ctx->is_marked(obj) ? "" : "not");
74 msg.append(" %3s in collection set\n", heap->in_collection_set(obj) ? "" : "not");
75 msg.append(" mark:%s\n", mw_ss.as_string());
76 msg.append(" region: %s", ss.as_string());
77 }
78
79 void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) {
80 ShenandoahHeap* heap = ShenandoahHeap::heap();
81 if (heap->is_in(loc)) {
82 msg.append(" inside Java heap\n");
83 ShenandoahHeapRegion *r = heap->heap_region_containing(loc);
84 stringStream ss;
85 r->print_on(&ss);
86
87 msg.append(" %3s in collection set\n", heap->in_collection_set(loc) ? "" : "not");
88 msg.append(" region: %s", ss.as_string());
89 } else {
90 msg.append(" outside of Java heap\n");
91 stringStream ss;
92 os::print_location(&ss, (intptr_t) loc, false);
|