hsdis.h revision 1879:f95d63e2154a
1/*
2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. 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 it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 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 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25/* decode_instructions -- dump a range of addresses as native instructions
26   This implements the protocol required by the HotSpot PrintAssembly option.
27
28   The starting and ending addresses are within the current process's address space.
29
30   The option string, if not empty, is interpreted by the disassembler implementation.
31
32   The printf callback is 'fprintf' or any other workalike.
33   It is called as (*printf_callback)(printf_stream, "some format...", some, format, args).
34
35   The event callback receives an event tag (a string) and an argument (a void*).
36   It is called as (*event_callback)(event_stream, "tag", arg).
37
38   Events:
39     <insn pc='%p'>             begin an instruction, at a given location
40     </insn pc='%d'>            end an instruction, at a given location
41     <addr value='%p'/>         emit the symbolic value of an address
42
43   A tag format is one of three basic forms: "tag", "/tag", "tag/",
44   where tag is a simple identifier, signifying (as in XML) a element start,
45   element end, and standalone element.  (To render as XML, add angle brackets.)
46*/
47extern
48#ifdef DLL_EXPORT
49  DLL_EXPORT
50#endif
51void* decode_instructions(void* start, void* end,
52                          void* (*event_callback)(void*, const char*, void*),
53                          void* event_stream,
54                          int (*printf_callback)(void*, const char*, ...),
55                          void* printf_stream,
56                          const char* options);
57
58/* convenience typedefs */
59
60typedef void* (*decode_instructions_event_callback_ftype)  (void*, const char*, void*);
61typedef int   (*decode_instructions_printf_callback_ftype) (void*, const char*, ...);
62typedef void* (*decode_instructions_ftype) (void* start, void* end,
63                                            decode_instructions_event_callback_ftype event_callback,
64                                            void* event_stream,
65                                            decode_instructions_printf_callback_ftype printf_callback,
66                                            void* printf_stream,
67                                            const char* options);
68