18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/javaClasses.hpp"
27 #include "code/codeCache.hpp"
28 #include "compiler/disassembler.hpp"
29 #include "gc/shared/cardTableModRefBS.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/handles.inline.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/stubCodeGenerator.hpp"
36 #include "runtime/stubRoutines.hpp"
37 #include CPU_HEADER(depChecker)
38 #ifdef SHARK
39 #include "shark/sharkEntry.hpp"
40 #endif
41
42 void* Disassembler::_library = NULL;
43 bool Disassembler::_tried_to_load_library = false;
44
45 // This routine is in the shared library:
46 Disassembler::decode_func_virtual Disassembler::_decode_instructions_virtual = NULL;
47 Disassembler::decode_func Disassembler::_decode_instructions = NULL;
48
49 static const char hsdis_library_name[] = "hsdis-" HOTSPOT_LIB_ARCH;
50 static const char decode_instructions_virtual_name[] = "decode_instructions_virtual";
51 static const char decode_instructions_name[] = "decode_instructions";
52 static bool use_new_version = true;
53 #define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/
54 #define BYTES_COMMENT ";..." /* funky byte display comment */
55
56 bool Disassembler::load_library() {
57 if (_decode_instructions_virtual != NULL || _decode_instructions != NULL) {
58 // Already succeeded.
59 return true;
60 }
504 } else {
505 env.output()->print_cr("%s", cb->name());
506 }
507 env.output()->print_cr(" at [" PTR_FORMAT ", " PTR_FORMAT "] " JLONG_FORMAT " bytes", p2i(cb->code_begin()), p2i(cb->code_end()), ((jlong)(cb->code_end() - cb->code_begin())) * sizeof(unsigned char*));
508 env.decode_instructions(cb->code_begin(), cb->code_end());
509 }
510
511 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
512 ttyLocker ttyl;
513 if (!load_library()) return;
514 decode_env env(CodeCache::find_blob_unsafe(start), st, c);
515 env.decode_instructions(start, end);
516 }
517
518 void Disassembler::decode(nmethod* nm, outputStream* st) {
519 ttyLocker ttyl;
520 if (!load_library()) return;
521 decode_env env(nm, st);
522 env.output()->print_cr("----------------------------------------------------------------------");
523
524 #ifdef SHARK
525 SharkEntry* entry = (SharkEntry *) nm->code_begin();
526 unsigned char* p = entry->code_start();
527 unsigned char* end = entry->code_limit();
528 #else
529 unsigned char* p = nm->code_begin();
530 unsigned char* end = nm->code_end();
531 #endif // SHARK
532
533 nm->method()->method_holder()->name()->print_symbol_on(env.output());
534 env.output()->print(".");
535 nm->method()->name()->print_symbol_on(env.output());
536 nm->method()->signature()->print_symbol_on(env.output());
537 #if INCLUDE_JVMCI
538 {
539 char buffer[O_BUFLEN];
540 char* jvmciName = nm->jvmci_installed_code_name(buffer, O_BUFLEN);
541 if (jvmciName != NULL) {
542 env.output()->print(" (%s)", jvmciName);
543 }
544 }
545 #endif
546 env.output()->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT "] " JLONG_FORMAT " bytes", p2i(p), p2i(end), ((jlong)(end - p)));
547
548 // Print constant table.
549 if (nm->consts_size() > 0) {
550 nm->print_nmethod_labels(env.output(), nm->consts_begin());
551 int offset = 0;
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/javaClasses.hpp"
27 #include "code/codeCache.hpp"
28 #include "compiler/disassembler.hpp"
29 #include "gc/shared/cardTableModRefBS.hpp"
30 #include "gc/shared/collectedHeap.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/handles.inline.hpp"
34 #include "runtime/os.hpp"
35 #include "runtime/stubCodeGenerator.hpp"
36 #include "runtime/stubRoutines.hpp"
37 #include CPU_HEADER(depChecker)
38
39 void* Disassembler::_library = NULL;
40 bool Disassembler::_tried_to_load_library = false;
41
42 // This routine is in the shared library:
43 Disassembler::decode_func_virtual Disassembler::_decode_instructions_virtual = NULL;
44 Disassembler::decode_func Disassembler::_decode_instructions = NULL;
45
46 static const char hsdis_library_name[] = "hsdis-" HOTSPOT_LIB_ARCH;
47 static const char decode_instructions_virtual_name[] = "decode_instructions_virtual";
48 static const char decode_instructions_name[] = "decode_instructions";
49 static bool use_new_version = true;
50 #define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/
51 #define BYTES_COMMENT ";..." /* funky byte display comment */
52
53 bool Disassembler::load_library() {
54 if (_decode_instructions_virtual != NULL || _decode_instructions != NULL) {
55 // Already succeeded.
56 return true;
57 }
501 } else {
502 env.output()->print_cr("%s", cb->name());
503 }
504 env.output()->print_cr(" at [" PTR_FORMAT ", " PTR_FORMAT "] " JLONG_FORMAT " bytes", p2i(cb->code_begin()), p2i(cb->code_end()), ((jlong)(cb->code_end() - cb->code_begin())) * sizeof(unsigned char*));
505 env.decode_instructions(cb->code_begin(), cb->code_end());
506 }
507
508 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
509 ttyLocker ttyl;
510 if (!load_library()) return;
511 decode_env env(CodeCache::find_blob_unsafe(start), st, c);
512 env.decode_instructions(start, end);
513 }
514
515 void Disassembler::decode(nmethod* nm, outputStream* st) {
516 ttyLocker ttyl;
517 if (!load_library()) return;
518 decode_env env(nm, st);
519 env.output()->print_cr("----------------------------------------------------------------------");
520
521 unsigned char* p = nm->code_begin();
522 unsigned char* end = nm->code_end();
523
524 nm->method()->method_holder()->name()->print_symbol_on(env.output());
525 env.output()->print(".");
526 nm->method()->name()->print_symbol_on(env.output());
527 nm->method()->signature()->print_symbol_on(env.output());
528 #if INCLUDE_JVMCI
529 {
530 char buffer[O_BUFLEN];
531 char* jvmciName = nm->jvmci_installed_code_name(buffer, O_BUFLEN);
532 if (jvmciName != NULL) {
533 env.output()->print(" (%s)", jvmciName);
534 }
535 }
536 #endif
537 env.output()->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT "] " JLONG_FORMAT " bytes", p2i(p), p2i(end), ((jlong)(end - p)));
538
539 // Print constant table.
540 if (nm->consts_size() > 0) {
541 nm->print_nmethod_labels(env.output(), nm->consts_begin());
542 int offset = 0;
|