Path: blob/master/src/hotspot/share/compiler/abstractDisassembler.hpp
40930 views
/*1* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2019 SAP SE. All rights reserved.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#ifndef SHARE_COMPILER_ABSTRACTDISASSEMBLER_HPP26#define SHARE_COMPILER_ABSTRACTDISASSEMBLER_HPP2728// AbstractDisassembler is the base class for29// platform-specific Disassembler classes.3031#include "utilities/globalDefinitions.hpp"3233class AbstractDisassembler {3435private:36// These are some general settings which control37// abstract disassembly output.38enum {39// that many bytes are dumped in one line.40abstract_instruction_bytes_per_line = 32,41// instruction bytes are grouped in blocks of that many bytes.42abstract_instruction_bytes_per_block = 2,43// instructions have this default len.44abstract_instruction_size_in_bytes = 1,45// instructions have this maximum len.46abstract_instruction_maxsize_in_bytes = 147};4849static bool _align_instr; // vertical alignment of instructions in abstract disassembly50static bool _show_pc; // print the instruction address51static bool _show_offset; // print the instruction offset (from start of blob)52static bool _show_bytes; // print instruction bytes53static bool _show_data_hex; // print instruction bytes54static bool _show_data_int; // print instruction bytes55static bool _show_data_float; // print instruction bytes56static bool _show_structs; // print compiler data structures (relocations, oop maps, scopes, metadata, ...)57static bool _show_comment; // print instruction comments58static bool _show_block_comment; // print block comments5960public:61// Platform-independent location and instruction formatting.62// All functions return #characters printed.63static int print_location(address here, address begin, address end, outputStream* st, bool align, bool print_header);64static int print_instruction(address here, int len, int max_len, outputStream* st, bool align, bool print_header);65static int print_hexdata(address here, int len, outputStream* st, bool print_header = false);66static int print_delimiter(outputStream* st);67static bool start_newline(int byte_count) { return byte_count >= abstract_instruction_bytes_per_line; }6869static void toggle_align_instr() { _align_instr = !_align_instr; }70static void toggle_show_pc() { _show_pc = !_show_pc; }71static void toggle_show_offset() { _show_offset = !_show_offset; }72static void toggle_show_bytes() { _show_bytes = !_show_bytes; }73static void toggle_show_data_hex() { _show_data_hex = !_show_data_hex; }74static void toggle_show_data_int() { _show_data_int = !_show_data_int; }75static void toggle_show_data_float() { _show_data_float = !_show_data_float; }76static void toggle_show_structs() { _show_structs = !_show_structs; }77static void toggle_show_comment() { _show_comment = !_show_comment; }78static void toggle_show_block_comment() { _show_block_comment = !_show_block_comment; }7980static bool align_instr() { return _align_instr; }81static bool show_pc() { return _show_pc; }82static bool show_offset() { return _show_offset; }83static bool show_bytes() { return _show_bytes; }84static bool show_data_hex() { return _show_data_hex; }85static bool show_data_int() { return _show_data_int; }86static bool show_data_float() { return _show_data_float; }87static bool show_structs() { return _show_structs; }88static bool show_comment() { return _show_comment; }89static bool show_block_comment() { return _show_block_comment; }9091// Decodes the one instruction at address start in a platform-independent92// format. Returns the start of the next instruction (which is93// 'start' plus 'instruction_size_in_bytes'). The parameter max_instr_size_in_bytes94// is used for output alignment purposes only.95static address decode_instruction_abstract(address start,96outputStream* st,97const int instruction_size_in_bytes,98const int max_instr_size_in_bytes = abstract_instruction_maxsize_in_bytes);99100// Decodes all instructions in the given range [start..end)101// calling decode_instruction_abstract for each instruction.102// The format is platform dependent only to the extend that103// it respects the actual instruction length where possible.104// Does not print any markers or decorators.105static void decode_range_abstract(address range_start, address range_end,106address start, address end,107outputStream* st,108const int max_instr_size_in_bytes = abstract_instruction_maxsize_in_bytes);109110// Decodes all instructions in the given range in a platform-independent111// format, calling decode_instruction_abstract for each instruction.112static void decode_abstract(address start, address end,113outputStream* st,114const int max_instr_size_in_bytes = abstract_instruction_maxsize_in_bytes);115};116117#endif // SHARE_COMPILER_ABSTRACTDISASSEMBLER_HPP118119120