aoqi@0: /* aoqi@0: * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_COMPILER_DISASSEMBLER_HPP aoqi@0: #define SHARE_VM_COMPILER_DISASSEMBLER_HPP aoqi@0: aoqi@0: #include "asm/codeBuffer.hpp" aoqi@0: #include "runtime/globals.hpp" aoqi@0: #ifdef TARGET_OS_FAMILY_linux aoqi@0: # include "os_linux.inline.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_FAMILY_solaris aoqi@0: # include "os_solaris.inline.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_FAMILY_windows aoqi@0: # include "os_windows.inline.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_FAMILY_aix aoqi@0: # include "os_aix.inline.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_FAMILY_bsd aoqi@0: # include "os_bsd.inline.hpp" aoqi@0: #endif aoqi@0: aoqi@0: class decode_env; aoqi@0: aoqi@0: // The disassembler prints out assembly code annotated aoqi@0: // with Java specific information. aoqi@0: aoqi@0: class Disassembler { aoqi@0: friend class decode_env; aoqi@0: private: aoqi@0: // this is the type of the dll entry point: aoqi@0: typedef void* (*decode_func_virtual)(uintptr_t start_va, uintptr_t end_va, aoqi@0: unsigned char* buffer, uintptr_t length, aoqi@0: void* (*event_callback)(void*, const char*, void*), aoqi@0: void* event_stream, aoqi@0: int (*printf_callback)(void*, const char*, ...), aoqi@0: void* printf_stream, aoqi@0: const char* options, aoqi@0: int newline); aoqi@0: // this is the type of the dll entry point for old version: aoqi@0: typedef void* (*decode_func)(void* start_va, void* end_va, aoqi@0: void* (*event_callback)(void*, const char*, void*), aoqi@0: void* event_stream, aoqi@0: int (*printf_callback)(void*, const char*, ...), aoqi@0: void* printf_stream, aoqi@0: const char* options); aoqi@0: // points to the library. aoqi@0: static void* _library; aoqi@0: // bailout aoqi@0: static bool _tried_to_load_library; aoqi@0: // points to the decode function. aoqi@0: static decode_func_virtual _decode_instructions_virtual; aoqi@0: static decode_func _decode_instructions; aoqi@0: // tries to load library and return whether it succedded. aoqi@0: static bool load_library(); aoqi@0: aoqi@0: // Machine dependent stuff aoqi@0: #ifdef TARGET_ARCH_x86 aoqi@0: # include "disassembler_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_sparc aoqi@0: # include "disassembler_sparc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_zero aoqi@0: # include "disassembler_zero.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_arm aoqi@0: # include "disassembler_arm.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_ppc aoqi@0: # include "disassembler_ppc.hpp" aoqi@0: #endif aoqi@0: aoqi@0: aoqi@0: public: aoqi@0: static bool can_decode() { aoqi@0: return (_decode_instructions_virtual != NULL) || aoqi@0: (_decode_instructions != NULL) || aoqi@0: load_library(); aoqi@0: } aoqi@0: static void decode(CodeBlob *cb, outputStream* st = NULL); aoqi@0: static void decode(nmethod* nm, outputStream* st = NULL); aoqi@0: static void decode(address begin, address end, outputStream* st = NULL, CodeStrings c = CodeStrings()); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_COMPILER_DISASSEMBLER_HPP