printlayout.cpp

Go to the documentation of this file.
00001 /* Copyright 1994, 1995 LongView Technologies L.L.C. $Revision: 1.16 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
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 

Generated on Mon Oct 9 13:37:24 2006 for Strongtalk VM by  doxygen 1.4.7