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/_debugPrintable.cpp.incl"
00026
00027
00028
00029 #ifndef DEBUG
00030 # ifdef ASSERT
00031
00032
00033 DEBUG should be defined when ASSERT is defined. It's intended to be used for debugging
00034 functions that don't slow down the system too much and thus can be left in optimized code.
00035 On the other hand, the code shouldn't be included in a production version.
00036 # endif
00037 #endif
00038
00039
00040
00041
00042
00043 class Command {
00044 private:
00045 ResourceMark rm;
00046 public:
00047 Command(char* str) {
00048 std->cr();
00049 std->print_cr("\"Executing %s\"", str);
00050 }
00051
00052 ~Command() {
00053 flush_logFile();
00054 }
00055 };
00056
00057
00058 void pp(void* p) {
00059 Command c("pp");
00060 FlagSetting fl(PrintVMMessages, true);
00061 if (p == NULL) {
00062 lprintf("0x0");
00063 return;
00064 }
00065
00066 if (Universe::is_heap((oop*) p)) {
00067 memOop obj = as_memOop(Universe::object_start((oop*) p));
00068 obj->print();
00069 if (obj->is_method()) {
00070 int bci = methodOop(obj)->bci_from((u_char*) p);
00071 prettyPrinter::print(methodOop(obj), NULL, bci);
00072 }
00073 return;
00074 }
00075
00076 if (oop(p)->is_smi() || oop(p)->is_mark()) {
00077 oop(p)->print();
00078 return;
00079 }
00080 }
00081
00082
00083 void pv(int p) { ((PrintableResourceObj*) p)->print(); }
00084
00085 void pp_short(void* p) {
00086 Command c("pp_short");
00087 FlagSetting fl(PrintVMMessages, true);
00088 if (p == NULL) {
00089 lprintf("0x0");
00090 } else if (oop(p)->is_mem()) {
00091
00092 oop(p)->print();
00093 } else {
00094
00095
00096 }
00097 }
00098
00099
00100 void pk(Klass* p) {
00101 Command c("pk");
00102 FlagSetting fl(PrintVMMessages, true);
00103 p->print_klass();
00104 }
00105
00106 void pr(void* m) {
00107 Command c("pr");
00108 Universe::remembered_set->print_set_for_object(memOop(m));
00109 }
00110
00111 void ps() {
00112
00113 int* fp;
00114 __asm { mov fp, ebp }
00115 {
00116 Command c("ps");
00117
00118 DeltaProcess* p = DeltaProcess::active();
00119 std->print(" for process: ");
00120 p->print();
00121 std->cr();
00122
00123 if (p->last_Delta_fp() != NULL) {
00124
00125
00126 p->trace_stack();
00127 } else {
00128
00129 frame f(NULL, fp, NULL);
00130 f = f.sender();
00131 p->trace_stack_from(vframe::new_vframe(&f));
00132 }
00133 }
00134 }
00135
00136 void pss() {
00137 Command c("pss");
00138 Processes::print();
00139 }
00140
00141
00142 void pd() {
00143
00144 int* fp;
00145 __asm { mov fp, ebp }
00146 {
00147 Command c("pd");
00148
00149 DeltaProcess* p = DeltaProcess::active();
00150 std->print(" for process: ");
00151 p->print();
00152 std->cr();
00153
00154 if (p->last_Delta_fp() != NULL) {
00155
00156
00157 p->trace_stack_for_deoptimization();
00158 } else {
00159
00160 frame f(NULL, fp, NULL);
00161 f = f.sender();
00162 p->trace_stack_for_deoptimization(&f);
00163 }
00164 }
00165 }
00166
00167 void oat(int index) {
00168 Command c("oat");
00169 if (objectIDTable::is_index_ok(index)) {
00170 oop obj = objectIDTable::at(index);
00171 obj->print();
00172 } else {
00173 std->print_cr("index %d out of bounds", index);
00174 }
00175 }
00176
00177
00178 void urs_ps() {
00179 FlagSetting f1(WizardMode, true);
00180 FlagSetting f2(PrintOopAddress, true);
00181 FlagSetting f3(ActivationShowCode, true);
00182 FlagSetting f4(MaterializeEliminatedBlocks, false);
00183 FlagSetting f5(BreakAtWarning, false);
00184 ps();
00185 }
00186
00187 void pc() {
00188 Command c("pc");
00189 theCompiler->print_code(false);
00190 }
00191
00192 void pscopes() {
00193 Command c("pscopes");
00194 theCompiler->topScope->printTree();
00195 }
00196
00197 void debug() {
00198 Command c("debug");
00199 WizardMode = true;
00200 PrintVMMessages = true;
00201 PrintCompilation = PrintInlining = PrintSplitting = PrintCode = PrintAssemblyCode = PrintEliminateUnnededNodes = true;
00202 PrintEliminateContexts = PrintCopyPropagation = PrintRScopes = PrintExposed = PrintLoopOpts = true;
00203 AlwaysFlushVMMessages = true;
00204 flush_logFile();
00205 }
00206
00207 void ndebug() {
00208 Command c("ndebug");
00209 PrintCompilation = PrintInlining = PrintSplitting = PrintCode = PrintAssemblyCode = PrintEliminateUnnededNodes = false;
00210 PrintEliminateContexts = PrintCopyPropagation = PrintRScopes = PrintExposed = PrintLoopOpts = false;
00211 AlwaysFlushVMMessages = false;
00212 flush_logFile();
00213 }
00214
00215 void flush() {
00216 Command c("flush");
00217 flush_logFile();
00218 }
00219
00220 void events() {
00221 Command c("events");
00222 eventLog->printPartial(50);
00223 }
00224
00225 nmethod* find(int addr) {
00226 Command c("find");
00227 return findNMethod((void*)addr);
00228 }
00229
00230 methodOop findm(int hp) {
00231 Command c("findm");
00232 return methodOopDesc::methodOop_from_hcode((u_char*)hp);
00233 }
00234
00235
00236
00237 void pp(int p) {
00238 pp((void*)p);
00239 }
00240
00241 void pp_short(int p) {
00242 pp_short((void*)p);
00243 }
00244
00245 void pk(int p) {
00246 pk((Klass*)p);
00247 }
00248
00249 void ph(int hp) {
00250 Command c("ph");
00251 findm(hp)->pretty_print();
00252 }
00253
00254 void pm(int m) {
00255 Command c("pm");
00256 methodOop(m)->pretty_print();
00257 }
00258
00259 void print_codes(char* class_name, char* selector) {
00260 Command c("print_codes");
00261 std->print_cr("Finding %s in %s.", selector, class_name);
00262 oop result = Universe::find_global(class_name);
00263 if (!result) {
00264 std->print_cr("Could not find global %s.", class_name);
00265 } else if (!result->is_klass()) {
00266 std->print_cr("Global %s is not a class.", class_name);
00267 } else {
00268 symbolOop sel = oopFactory::new_symbol(selector);
00269 methodOop method = klassOop(result)->klass_part()->lookup(sel);
00270 if (!method) method = result->blueprint()->lookup(sel);
00271 if (!method) {
00272 std->print_cr("Method %s is not in %s.", selector, class_name);
00273 } else {
00274 method->pretty_print();
00275 method->print_codes();
00276 }
00277 }
00278 }
00279
00280 void help() {
00281 Command c("help");
00282
00283
00284 std->print_cr("basic");
00285 std->print_cr(" pp(void* p) - try to make sense of p");
00286 std->print_cr(" pv(int p) - ((PrintableResourceObj*) p)->print()");
00287 std->print_cr(" ps() - print current process stack");
00288 std->print_cr(" pss() - print all process stacks");
00289 std->print_cr(" oat(int i) - print object with id = i");
00290
00291 std->print_cr("methodOop");
00292 std->print_cr(" pm(int m) - pretty print methodOop(m)");
00293 std->print_cr(" ph(int hp) - pretty print method containing hp");
00294 std->print_cr(" findm(int hp) - returns methodOop containing hp");
00295
00296 std->print_cr("misc.");
00297 std->print_cr(" flush() - flushes the log file");
00298 std->print_cr(" events() - dump last 50 event");
00299
00300
00301 std->print_cr("compiler debugging");
00302 std->print_cr(" debug() - to set things up for compiler debugging");
00303 std->print_cr(" ndebug() - undo debug");
00304 std->print_cr(" pc() - theCompiler->print_code(false)");
00305 std->print_cr(" pscopes() - theCompiler->topScope->printTree()");
00306 std->print_cr(" urs_ps() - print current process stack with many flags turned on");
00307 }