src/utils/hsdis/hsdis.h
author tonyp
Fri, 19 Jul 2019 12:39:31 -0400
changeset 55751 014decdb5086
parent 51271 b6e0bfe4a6ec
permissions -rw-r--r--
8227179: Test for new gc+metaspace=info output format Reviewed-by: tschatzl, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
     1
/*
13873
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
     2
 * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
     4
 *
51202
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
     5
 * The Universal Permissive License (UPL), Version 1.0
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
     6
 *
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
     7
 * Subject to the condition set forth below, permission is hereby granted to
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
     8
 * any person obtaining a copy of this software, associated documentation
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
     9
 * and/or data (collectively the "Software"), free of charge and under any
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    10
 * and all copyright rights in the Software, and any and all patent rights
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    11
 * owned or freely licensable by each licensor hereunder covering either (i)
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    12
 * the unmodified Software as contributed to or provided by such licensor,
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    13
 * or (ii) the Larger Works (as defined below), to deal in both
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    14
 *
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    15
 * (a) the Software, and
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    16
 *
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    17
 * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file
51271
b6e0bfe4a6ec 8208541: non-ASCII characters in hsdis UPL text
dbuck
parents: 51202
diff changeset
    18
 * if one is included with the Software (each a "Larger Work" to which the
51202
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    19
 * Software is contributed by such licensors),
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    20
 *
51202
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    21
 * without restriction, including without limitation the rights to copy,
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    22
 * create derivative works of, display, perform, and distribute the Software
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    23
 * and make, use, sell, offer for sale, import, export, have made, and have
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    24
 * sold the Software and the Larger Work(s), and to sublicense the foregoing
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    25
 * rights on either these or other terms.
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    26
 *
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    27
 * This license is subject to the following condition:
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    28
 *
51202
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    29
 * The above copyright notice and either this complete permission notice or
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    30
 * at a minimum a reference to the UPL must be included in all copies or
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    31
 * substantial portions of the Software.
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    32
 *
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    33
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    34
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    35
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    36
 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    37
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    38
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
59b0d8afc831 8208183: update HSDIS plugin license to UPL
dbuck
parents: 47216
diff changeset
    39
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    40
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 347
diff changeset
    41
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 347
diff changeset
    42
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 347
diff changeset
    43
 * questions.
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    44
 *
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    45
 */
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    46
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    47
/* decode_instructions -- dump a range of addresses as native instructions
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    48
   This implements the protocol required by the HotSpot PrintAssembly option.
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    49
13873
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    50
   The start_va, end_va is the virtual address the region of memory to
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    51
   disasemble and buffer contains the instructions to decode,
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    52
   Disassembling instructions in the current address space is done by
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    53
   having start_va == buffer.
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    54
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    55
   The option string, if not empty, is interpreted by the disassembler implementation.
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    56
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    57
   The printf callback is 'fprintf' or any other workalike.
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    58
   It is called as (*printf_callback)(printf_stream, "some format...", some, format, args).
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    59
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    60
   The event callback receives an event tag (a string) and an argument (a void*).
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    61
   It is called as (*event_callback)(event_stream, "tag", arg).
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    62
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    63
   Events:
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    64
     <insn pc='%p'>             begin an instruction, at a given location
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    65
     </insn pc='%d'>            end an instruction, at a given location
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    66
     <addr value='%p'/>         emit the symbolic value of an address
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    67
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    68
   A tag format is one of three basic forms: "tag", "/tag", "tag/",
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    69
   where tag is a simple identifier, signifying (as in XML) a element start,
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    70
   element end, and standalone element.  (To render as XML, add angle brackets.)
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    71
*/
14384
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    72
#ifndef SHARED_TOOLS_HSDIS_H
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    73
#define SHARED_TOOLS_HSDIS_H
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    74
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    75
extern
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    76
#ifdef DLL_EXPORT
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    77
  DLL_EXPORT
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    78
#endif
13873
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    79
void* decode_instructions_virtual(uintptr_t start_va, uintptr_t end_va,
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    80
                                  unsigned char* buffer, uintptr_t length,
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    81
                                  void* (*event_callback)(void*, const char*, void*),
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    82
                                  void* event_stream,
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    83
                                  int (*printf_callback)(void*, const char*, ...),
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 7397
diff changeset
    84
                                  void* printf_stream,
14384
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    85
                                  const char* options,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    86
                                  int newline /* bool value for nice new line */);
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    87
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    88
/* This is the compatability interface for older versions of hotspot */
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    89
extern
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    90
#ifdef DLL_ENTRY
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    91
  DLL_ENTRY
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    92
#endif
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    93
void* decode_instructions(void* start_pv, void* end_pv,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    94
                    void* (*event_callback)(void*, const char*, void*),
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    95
                    void* event_stream,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    96
                    int   (*printf_callback)(void*, const char*, ...),
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    97
                    void* printf_stream,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
    98
                    const char* options);
347
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
    99
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
   100
/* convenience typedefs */
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
   101
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
   102
typedef void* (*decode_instructions_event_callback_ftype)  (void*, const char*, void*);
df859fcca515 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
   103
typedef int   (*decode_instructions_printf_callback_ftype) (void*, const char*, ...);
14384
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   104
typedef void* (*decode_func_vtype) (uintptr_t start_va, uintptr_t end_va,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   105
                                    unsigned char* buffer, uintptr_t length,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   106
                                    decode_instructions_event_callback_ftype event_callback,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   107
                                    void* event_stream,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   108
                                    decode_instructions_printf_callback_ftype printf_callback,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   109
                                    void* printf_stream,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   110
                                    const char* options,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   111
                                    int newline);
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   112
typedef void* (*decode_func_stype) (void* start_pv, void* end_pv,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   113
                                    decode_instructions_event_callback_ftype event_callback,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   114
                                    void* event_stream,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   115
                                    decode_instructions_printf_callback_ftype printf_callback,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   116
                                    void* printf_stream,
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   117
                                    const char* options);
801df8025142 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 13873
diff changeset
   118
#endif /* SHARED_TOOLS_HSDIS_H */