disassembler.hpp revision 2073:b92c45f2bc75
142660Smarkm/* 2146515Sru * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 321495Sjmacd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4146515Sru * 521495Sjmacd * This code is free software; you can redistribute it and/or modify it 621495Sjmacd * under the terms of the GNU General Public License version 2 only, as 721495Sjmacd * published by the Free Software Foundation. 821495Sjmacd * 921495Sjmacd * This code is distributed in the hope that it will be useful, but WITHOUT 1021495Sjmacd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1121495Sjmacd * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1221495Sjmacd * version 2 for more details (a copy is included in the LICENSE file that 1321495Sjmacd * accompanied this code). 1421495Sjmacd * 1521495Sjmacd * You should have received a copy of the GNU General Public License version 1621495Sjmacd * 2 along with this work; if not, write to the Free Software Foundation, 1721495Sjmacd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1821495Sjmacd * 1921495Sjmacd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2021495Sjmacd * or visit www.oracle.com if you need additional information or have any 2121495Sjmacd * questions. 2256160Sru * 2342660Smarkm */ 2421495Sjmacd 2542660Smarkm#ifndef SHARE_VM_COMPILER_DISASSEMBLER_HPP 2621495Sjmacd#define SHARE_VM_COMPILER_DISASSEMBLER_HPP 2756160Sru 2821495Sjmacd#include "runtime/globals.hpp" 2921495Sjmacd#ifdef TARGET_OS_FAMILY_linux 3021495Sjmacd# include "os_linux.inline.hpp" 3121495Sjmacd#endif 3221495Sjmacd#ifdef TARGET_OS_FAMILY_solaris 3321495Sjmacd# include "os_solaris.inline.hpp" 3421495Sjmacd#endif 3521495Sjmacd#ifdef TARGET_OS_FAMILY_windows 3621495Sjmacd# include "os_windows.inline.hpp" 3721495Sjmacd#endif 3842660Smarkm 3942660Smarkmclass decode_env; 4042660Smarkm 4142660Smarkm// The disassembler prints out assembly code annotated 4242660Smarkm// with Java specific information. 4356160Sru 4442660Smarkmclass Disassembler { 4521495Sjmacd friend class decode_env; 4621495Sjmacd private: 4721495Sjmacd // this is the type of the dll entry point: 4842660Smarkm typedef void* (*decode_func)(void* start, void* end, 4942660Smarkm void* (*event_callback)(void*, const char*, void*), 5042660Smarkm void* event_stream, 5142660Smarkm int (*printf_callback)(void*, const char*, ...), 5242660Smarkm void* printf_stream, 5342660Smarkm const char* options); 5456160Sru // points to the library. 5556160Sru static void* _library; 5621495Sjmacd // bailout 5756160Sru static bool _tried_to_load_library; 5821495Sjmacd // points to the decode function. 5956160Sru static decode_func _decode_instructions; 6042660Smarkm // tries to load library and return whether it succedded. 6156160Sru static bool load_library(); 6242660Smarkm 6342660Smarkm // Machine dependent stuff 6442660Smarkm#ifdef TARGET_ARCH_x86 6542660Smarkm# include "disassembler_x86.hpp" 6642660Smarkm#endif 6742660Smarkm#ifdef TARGET_ARCH_sparc 6842660Smarkm# include "disassembler_sparc.hpp" 6942660Smarkm#endif 7042660Smarkm#ifdef TARGET_ARCH_zero 7142660Smarkm# include "disassembler_zero.hpp" 7242660Smarkm#endif 7342660Smarkm#ifdef TARGET_ARCH_arm 7421495Sjmacd# include "disassembler_arm.hpp" 7556160Sru#endif 7621495Sjmacd#ifdef TARGET_ARCH_ppc 7721495Sjmacd# include "disassembler_ppc.hpp" 7821495Sjmacd#endif 7921495Sjmacd 8021495Sjmacd 8121495Sjmacd public: 8221495Sjmacd static bool can_decode() { 8321495Sjmacd return (_decode_instructions != NULL) || load_library(); 8421495Sjmacd } 8521495Sjmacd static void decode(CodeBlob *cb, outputStream* st = NULL); 8621495Sjmacd static void decode(nmethod* nm, outputStream* st = NULL); 8721495Sjmacd static void decode(address begin, address end, outputStream* st = NULL); 8842660Smarkm}; 8942660Smarkm 9042660Smarkm#endif // SHARE_VM_COMPILER_DISASSEMBLER_HPP 9142660Smarkm