00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_printlayout.cpp.incl"
00026 # include <ctype.h>
00027
00028 const int indent_col = 3;
00029 const int value_col = 16;
00030
00031 PrintObjectClosure::PrintObjectClosure(outputStream* st = NULL) {
00032 this->st = st ? st : std;
00033 }
00034
00035 void PrintObjectClosure::do_object(memOop obj) {
00036 this->obj = obj;
00037 obj->print_value();
00038 if (WizardMode) {
00039 st->print(" (size = %d)", obj->size());
00040 }
00041 st->cr();
00042 }
00043
00044 void PrintObjectClosure::do_mark(markOop *m) {
00045 st->fill_to(indent_col);
00046 st->print("mark");
00047 st->sp();
00048 st->fill_to(value_col);
00049 (*m)->print_value();
00050 st->cr();
00051 }
00052
00053 void PrintObjectClosure::do_oop(char* title, oop* o) {
00054 symbolOop name = obj->blueprint()->inst_var_name_at(o-(oop*)obj->addr());
00055 st->fill_to(indent_col);
00056 if (name) {
00057 name->print_symbol_on(st);
00058 } else {
00059 st->print("%s", title);
00060 }
00061 st->sp();
00062 st->fill_to(value_col);
00063 (*o)->print_value();
00064 st->cr();
00065 }
00066
00067 void PrintObjectClosure::do_byte(char* title, u_char* b) {
00068 st->fill_to(indent_col);
00069 st->print("%s", title);
00070 st->sp();
00071 st->fill_to(value_col);
00072 char c = (char) *b;
00073 if (isprint(c)) st->print_cr("%c", c);
00074 else st->print_cr("\\%o", c);
00075 }
00076
00077 void PrintObjectClosure::do_long(char* title, void** p) {
00078 st->fill_to(indent_col);
00079 st->print("%s", title);
00080 st->sp();
00081 st->fill_to(value_col);
00082 st->print_cr("%#lx", *p);
00083 }
00084
00085 void PrintObjectClosure::do_double(char* title, double* d) {
00086 st->fill_to(indent_col);
00087 st->print("%s", title);
00088 st->sp();
00089 st->fill_to(value_col);
00090 st->print_cr("%.15f", *d);
00091 }
00092
00093 void PrintObjectClosure::begin_indexables() {
00094 }
00095
00096 void PrintObjectClosure::end_indexables() {
00097 }
00098
00099 void PrintObjectClosure::do_indexable_oop(int index, oop* o) {
00100 if (index > MaxElementPrintSize) return;
00101 st->fill_to(indent_col);
00102 st->print("%d", index);
00103 st->sp();
00104 st->fill_to(value_col);
00105 (*o)->print_value();
00106 st->cr();
00107 }
00108
00109 void PrintObjectClosure::do_indexable_byte(int index, u_char* b) {
00110 if (index > MaxElementPrintSize) return;
00111 st->fill_to(indent_col);
00112 st->print("%d", index);
00113 st->sp();
00114 st->fill_to(value_col);
00115 int c = (int) *b;
00116 if (isprint(c)) st->print_cr("%c", c);
00117 else st->print_cr("\\%o", c);
00118 }
00119
00120 void PrintObjectClosure::do_indexable_doubleByte(int index, doubleByte* b) {
00121 if (index > MaxElementPrintSize) return;
00122 st->fill_to(indent_col);
00123 st->print("%d", index);
00124 st->sp();
00125 st->fill_to(value_col);
00126 int c = (int) *b;
00127 if (isprint(c)) st->print_cr("%c", c);
00128 else st->print_cr("\\%o", c);
00129 }
00130
00131 void PrintObjectClosure::do_indexable_long(int index, long* l) {
00132 if (index > MaxElementPrintSize) return;
00133 st->fill_to(indent_col);
00134 st->print("%d", index);
00135 st->sp();
00136 st->fill_to(value_col);
00137 st->print_cr("0x%lx", *l);
00138 }
00139