CACAO
disass.hpp
Go to the documentation of this file.
1 /* src/vm/jit/disass.hpp - disassembler header
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #ifndef DISASS_HPP_
27 #define DISASS_HPP_ 1
28 
29 #include "config.h"
30 
31 #if defined(WITH_BINUTILS_DISASSEMBLER)
32 # include <dis-asm.h>
33 #endif
34 
35 #include "vm/types.hpp"
36 
37 #include "vm/global.hpp"
38 
39 #if defined(ENABLE_DISASSEMBLER)
40 
41 /* some macros ****************************************************************/
42 
43 #if defined(ENABLE_JIT)
44 # if defined(ENABLE_INTRP)
45 
46 #define DISASSINSTR(code) \
47  do { \
48  if (opt_intrp) \
49  (code) = intrp_disassinstr((u1*) (code)); \
50  else \
51  (code) = disassinstr((u1*) (code)); \
52  } while (0)
53 
54 #define DISASSEMBLE(start,end) \
55  do { \
56  if (opt_intrp) \
57  intrp_disassemble((start), (end)); \
58  else \
59  disassemble((start), (end)); \
60  } while (0)
61 
62 # else /* defined(ENABLE_INTRP) */
63 
64 #define DISASSINSTR(code) \
65  (code) = disassinstr((u1*) (code))
66 
67 #define DISASSEMBLE(start,end) \
68  disassemble((start), (end))
69 
70 # endif /* defined(ENABLE_INTRP) */
71 #else /* defined(ENABLE_JIT) */
72 
73 #define DISASSINSTR(code) \
74  (code) = intrp_disassinstr((u1*) (code))
75 
76 #define DISASSEMBLE(start,end) \
77  intrp_disassemble((start), (end))
78 
79 #endif /* defined(ENABLE_JIT) */
80 
81 
82 /* export global variables ****************************************************/
83 
84 #if defined(WITH_BINUTILS_DISASSEMBLER)
85 extern disassemble_info info;
86 extern bool disass_initialized;
87 #endif
88 
89 #if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__aarch64__)
90 extern char disass_buf[512];
91 extern s4 disass_len;
92 #endif
93 
94 
95 /* function prototypes *******************************************************/
96 
97 extern "C" {
98 
99 #if defined(ENABLE_JIT)
100 void disassemble(u1 *start, u1 *end);
101 #endif
102 
103 #if defined(WITH_BINUTILS_DISASSEMBLER)
104 void disass_printf(PTR p, const char *fmt, ...);
105 
106 int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info);
107 #endif
108 
109 /* machine dependent functions */
110 
111 #if defined(ENABLE_JIT)
112 u1 *disassinstr(u1 *code);
113 #endif
114 
115 #if defined(ENABLE_INTRP)
116 u1 *intrp_disassinstr(u1 *code);
117 void intrp_disassemble(u1 *start, u1 *end);
118 #endif
119 
120 } // extern "C"
121 
122 #endif /* defined(ENABLE_DISASSEMBLER) */
123 
124 #endif // DISASS_HPP_
125 
126 
127 /*
128  * These are local overrides for various environment variables in Emacs.
129  * Please do not remove this and leave it at the end of the file, where
130  * Emacs will automagically detect them.
131  * ---------------------------------------------------------------------
132  * Local variables:
133  * mode: c++
134  * indent-tabs-mode: t
135  * c-basic-offset: 4
136  * tab-width: 4
137  * End:
138  */
int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info)
u1 * disassinstr(u1 *code)
Definition: disass.cpp:48
uint8_t u1
Definition: types.hpp:40
int32_t s4
Definition: types.hpp:45
u1 * intrp_disassinstr(u1 *code)
Definition: disass.cpp:42
void intrp_disassemble(u1 *start, u1 *end)
Definition: disass.cpp:64
void disass_printf(PTR p, const char *fmt,...)
void disassemble(u1 *start, u1 *end)
Definition: disass.cpp:403
const char const void jint length
Definition: jvmti.h:352