185 void print_insn_labels(); |
186 void print_insn_labels(); |
186 void print_insn_bytes(address pc0, address pc); |
187 void print_insn_bytes(address pc0, address pc); |
187 void print_address(address value); |
188 void print_address(address value); |
188 |
189 |
189 public: |
190 public: |
190 decode_env(CodeBlob* code, outputStream* output); |
191 decode_env(CodeBlob* code, outputStream* output, CodeComments c = CodeComments()); |
191 |
192 |
192 address decode_instructions(address start, address end); |
193 address decode_instructions(address start, address end); |
193 |
194 |
194 void start_insn(address pc) { |
195 void start_insn(address pc) { |
195 _cur_insn = pc; |
196 _cur_insn = pc; |
227 int total_ticks() { return _total_ticks; } |
228 int total_ticks() { return _total_ticks; } |
228 void set_total_ticks(int n) { _total_ticks = n; } |
229 void set_total_ticks(int n) { _total_ticks = n; } |
229 const char* options() { return _option_buf; } |
230 const char* options() { return _option_buf; } |
230 }; |
231 }; |
231 |
232 |
232 decode_env::decode_env(CodeBlob* code, outputStream* output) { |
233 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeComments c) { |
233 memset(this, 0, sizeof(*this)); |
234 memset(this, 0, sizeof(*this)); |
234 _output = output ? output : tty; |
235 _output = output ? output : tty; |
235 _code = code; |
236 _code = code; |
236 if (code != NULL && code->is_nmethod()) |
237 if (code != NULL && code->is_nmethod()) |
237 _nm = (nmethod*) code; |
238 _nm = (nmethod*) code; |
|
239 _comments.assign(c); |
238 |
240 |
239 // by default, output pc but not bytes: |
241 // by default, output pc but not bytes: |
240 _print_pc = true; |
242 _print_pc = true; |
241 _print_bytes = false; |
243 _print_bytes = false; |
242 _bytes_per_line = Disassembler::pd_instruction_alignment(); |
244 _bytes_per_line = Disassembler::pd_instruction_alignment(); |
354 outputStream* st = output(); |
356 outputStream* st = output(); |
355 CodeBlob* cb = _code; |
357 CodeBlob* cb = _code; |
356 if (cb != NULL) { |
358 if (cb != NULL) { |
357 cb->print_block_comment(st, p); |
359 cb->print_block_comment(st, p); |
358 } |
360 } |
|
361 _comments.print_block_comment(st, (intptr_t)(p - _start)); |
359 if (_print_pc) { |
362 if (_print_pc) { |
360 st->print(" " PTR_FORMAT ": ", p); |
363 st->print(" " PTR_FORMAT ": ", p); |
361 } |
364 } |
362 } |
365 } |
363 |
366 |
465 decode_env env(cb, st); |
468 decode_env env(cb, st); |
466 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); |
469 env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); |
467 env.decode_instructions(cb->code_begin(), cb->code_end()); |
470 env.decode_instructions(cb->code_begin(), cb->code_end()); |
468 } |
471 } |
469 |
472 |
470 |
473 void Disassembler::decode(address start, address end, outputStream* st, CodeComments c) { |
471 void Disassembler::decode(address start, address end, outputStream* st) { |
|
472 if (!load_library()) return; |
474 if (!load_library()) return; |
473 decode_env env(CodeCache::find_blob_unsafe(start), st); |
475 decode_env env(CodeCache::find_blob_unsafe(start), st, c); |
474 env.decode_instructions(start, end); |
476 env.decode_instructions(start, end); |
475 } |
477 } |
476 |
478 |
477 void Disassembler::decode(nmethod* nm, outputStream* st) { |
479 void Disassembler::decode(nmethod* nm, outputStream* st) { |
478 if (!load_library()) return; |
480 if (!load_library()) return; |