1 /* |
1 /* |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
624 tty->print_cr("// [Section #%d]", i); |
624 tty->print_cr("// [Section #%d]", i); |
625 printDOFSection(dof, sec); |
625 printDOFSection(dof, sec); |
626 } |
626 } |
627 } |
627 } |
628 |
628 |
629 /** |
|
630 * This prints out hex data in a 'windbg' or 'xxd' form, where each line is: |
|
631 * <hex-address>: 8 * <hex-halfword> <ascii translation> |
|
632 * example: |
|
633 * 0000000: 7f44 4f46 0102 0102 0000 0000 0000 0000 .DOF............ |
|
634 * 0000010: 0000 0000 0000 0040 0000 0020 0000 0005 .......@... .... |
|
635 * 0000020: 0000 0000 0000 0040 0000 0000 0000 015d .......@.......] |
|
636 * ... |
|
637 */ |
|
638 static void printDOFRawData(void* dof) { |
|
639 size_t size = ((dof_hdr_t*)dof)->dofh_loadsz; |
|
640 size_t limit = (size + 16) / 16 * 16; |
|
641 for (size_t i = 0; i < limit; ++i) { |
|
642 if (i % 16 == 0) { |
|
643 tty->print("%07x:", i); |
|
644 } |
|
645 if (i % 2 == 0) { |
|
646 tty->print(" "); |
|
647 } |
|
648 if (i < size) { |
|
649 tty->print("%02x", ((unsigned char*)dof)[i]); |
|
650 } else { |
|
651 tty->print(" "); |
|
652 } |
|
653 if ((i + 1) % 16 == 0) { |
|
654 tty->print(" "); |
|
655 for (size_t j = 0; j < 16; ++j) { |
|
656 size_t idx = i + j - 15; |
|
657 char c = ((char*)dof)[idx]; |
|
658 if (idx < size) { |
|
659 tty->print("%c", c >= 32 && c <= 126 ? c : '.'); |
|
660 } |
|
661 } |
|
662 tty->print_cr(""); |
|
663 } |
|
664 } |
|
665 tty->print_cr(""); |
|
666 } |
|
667 |
|
668 static void printDOFHelper(dof_helper_t* helper) { |
629 static void printDOFHelper(dof_helper_t* helper) { |
669 tty->print_cr("// dof_helper_t {"); |
630 tty->print_cr("// dof_helper_t {"); |
670 tty->print_cr("// dofhp_mod = \"%s\"", helper->dofhp_mod); |
631 tty->print_cr("// dofhp_mod = \"%s\"", helper->dofhp_mod); |
671 tty->print_cr("// dofhp_addr = 0x%016llx", helper->dofhp_addr); |
632 tty->print_cr("// dofhp_addr = 0x%016llx", helper->dofhp_addr); |
672 tty->print_cr("// dofhp_dof = 0x%016llx", helper->dofhp_dof); |
633 tty->print_cr("// dofhp_dof = 0x%016llx", helper->dofhp_dof); |
673 printDOF((void*)helper->dofhp_dof); |
634 printDOF((void*)helper->dofhp_dof); |
674 tty->print_cr("// }"); |
635 tty->print_cr("// }"); |
675 printDOFRawData((void*)helper->dofhp_dof); |
636 size_t len = ((dof_hdr_t*)helper)->dofh_loadsz; |
|
637 tty->print_data((void*)helper->dofhp_dof, len, true); |
676 } |
638 } |
677 |
639 |
678 #else // ndef HAVE_DTRACE_H |
640 #else // ndef HAVE_DTRACE_H |
679 |
641 |
680 // Get here if we're not building on at least Solaris 10 |
642 // Get here if we're not building on at least Solaris 10 |