1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/compiler/disassembler.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,109 @@ 1.4 +/* 1.5 + * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_COMPILER_DISASSEMBLER_HPP 1.29 +#define SHARE_VM_COMPILER_DISASSEMBLER_HPP 1.30 + 1.31 +#include "asm/codeBuffer.hpp" 1.32 +#include "runtime/globals.hpp" 1.33 +#ifdef TARGET_OS_FAMILY_linux 1.34 +# include "os_linux.inline.hpp" 1.35 +#endif 1.36 +#ifdef TARGET_OS_FAMILY_solaris 1.37 +# include "os_solaris.inline.hpp" 1.38 +#endif 1.39 +#ifdef TARGET_OS_FAMILY_windows 1.40 +# include "os_windows.inline.hpp" 1.41 +#endif 1.42 +#ifdef TARGET_OS_FAMILY_aix 1.43 +# include "os_aix.inline.hpp" 1.44 +#endif 1.45 +#ifdef TARGET_OS_FAMILY_bsd 1.46 +# include "os_bsd.inline.hpp" 1.47 +#endif 1.48 + 1.49 +class decode_env; 1.50 + 1.51 +// The disassembler prints out assembly code annotated 1.52 +// with Java specific information. 1.53 + 1.54 +class Disassembler { 1.55 + friend class decode_env; 1.56 + private: 1.57 + // this is the type of the dll entry point: 1.58 + typedef void* (*decode_func_virtual)(uintptr_t start_va, uintptr_t end_va, 1.59 + unsigned char* buffer, uintptr_t length, 1.60 + void* (*event_callback)(void*, const char*, void*), 1.61 + void* event_stream, 1.62 + int (*printf_callback)(void*, const char*, ...), 1.63 + void* printf_stream, 1.64 + const char* options, 1.65 + int newline); 1.66 + // this is the type of the dll entry point for old version: 1.67 + typedef void* (*decode_func)(void* start_va, void* end_va, 1.68 + void* (*event_callback)(void*, const char*, void*), 1.69 + void* event_stream, 1.70 + int (*printf_callback)(void*, const char*, ...), 1.71 + void* printf_stream, 1.72 + const char* options); 1.73 + // points to the library. 1.74 + static void* _library; 1.75 + // bailout 1.76 + static bool _tried_to_load_library; 1.77 + // points to the decode function. 1.78 + static decode_func_virtual _decode_instructions_virtual; 1.79 + static decode_func _decode_instructions; 1.80 + // tries to load library and return whether it succedded. 1.81 + static bool load_library(); 1.82 + 1.83 + // Machine dependent stuff 1.84 +#ifdef TARGET_ARCH_x86 1.85 +# include "disassembler_x86.hpp" 1.86 +#endif 1.87 +#ifdef TARGET_ARCH_sparc 1.88 +# include "disassembler_sparc.hpp" 1.89 +#endif 1.90 +#ifdef TARGET_ARCH_zero 1.91 +# include "disassembler_zero.hpp" 1.92 +#endif 1.93 +#ifdef TARGET_ARCH_arm 1.94 +# include "disassembler_arm.hpp" 1.95 +#endif 1.96 +#ifdef TARGET_ARCH_ppc 1.97 +# include "disassembler_ppc.hpp" 1.98 +#endif 1.99 + 1.100 + 1.101 + public: 1.102 + static bool can_decode() { 1.103 + return (_decode_instructions_virtual != NULL) || 1.104 + (_decode_instructions != NULL) || 1.105 + load_library(); 1.106 + } 1.107 + static void decode(CodeBlob *cb, outputStream* st = NULL); 1.108 + static void decode(nmethod* nm, outputStream* st = NULL); 1.109 + static void decode(address begin, address end, outputStream* st = NULL, CodeStrings c = CodeStrings()); 1.110 +}; 1.111 + 1.112 +#endif // SHARE_VM_COMPILER_DISASSEMBLER_HPP