annotate src/share/tools/hsdis/hsdis.h @ 6782:5a98bf7d847b

6879063: SA should use hsdis for disassembly Summary: We should in SA to use hsdis for it like the JVM does to replace the current java based disassembler. Reviewed-by: twisti, jrose, sla Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 24 Sep 2012 12:44:00 -0700
parents f95d63e2154a
children 3d701c802d01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
1 /*
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
2 * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
100
c7c777385a15 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.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
4 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
7 * published by the Free Software Foundation.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
8 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
13 * accompanied this code).
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
14 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 100
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 100
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 100
diff changeset
21 * questions.
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
22 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
23 */
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
24
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
25 /* decode_instructions -- dump a range of addresses as native instructions
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
26 This implements the protocol required by the HotSpot PrintAssembly option.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
27
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
28 The start_va, end_va is the virtual address the region of memory to
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
29 disasemble and buffer contains the instructions to decode,
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
30 Disassembling instructions in the current address space is done by
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
31 having start_va == buffer.
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
32
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
33 The option string, if not empty, is interpreted by the disassembler implementation.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
34
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
35 The printf callback is 'fprintf' or any other workalike.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
36 It is called as (*printf_callback)(printf_stream, "some format...", some, format, args).
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
37
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
38 The event callback receives an event tag (a string) and an argument (a void*).
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
39 It is called as (*event_callback)(event_stream, "tag", arg).
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
40
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
41 Events:
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
42 <insn pc='%p'> begin an instruction, at a given location
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
43 </insn pc='%d'> end an instruction, at a given location
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
44 <addr value='%p'/> emit the symbolic value of an address
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
45
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
46 A tag format is one of three basic forms: "tag", "/tag", "tag/",
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
47 where tag is a simple identifier, signifying (as in XML) a element start,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
48 element end, and standalone element. (To render as XML, add angle brackets.)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
49 */
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
50 extern
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
51 #ifdef DLL_EXPORT
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
52 DLL_EXPORT
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
53 #endif
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
54 void* decode_instructions_virtual(uintptr_t start_va, uintptr_t end_va,
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
55 unsigned char* buffer, uintptr_t length,
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
56 void* (*event_callback)(void*, const char*, void*),
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
57 void* event_stream,
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
58 int (*printf_callback)(void*, const char*, ...),
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
59 void* printf_stream,
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
60 const char* options);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
61
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
62 /* convenience typedefs */
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
63
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
64 typedef void* (*decode_instructions_event_callback_ftype) (void*, const char*, void*);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
65 typedef int (*decode_instructions_printf_callback_ftype) (void*, const char*, ...);
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
66 typedef void* (*decode_instructions_ftype) (uintptr_t start_va, uintptr_t end_va,
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1972
diff changeset
67 unsigned char* buffer, uintptr_t length,
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
68 decode_instructions_event_callback_ftype event_callback,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
69 void* event_stream,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
70 decode_instructions_printf_callback_ftype printf_callback,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
71 void* printf_stream,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
72 const char* options);