1 /* src/vm/jit/intrp/disass.c - disassembler wrapper for interpreter
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Andreas Krall
30 Changes: Christian Thalinger
34 $Id: disass.c 5684 2006-10-05 00:06:23Z edwin $
45 #include "vm/jit/intrp/intrp.h"
48 /* function disassinstr ********************************************************
50 outputs a disassembler listing of one machine code instruction on 'stdout'
51 c: instructions machine code
53 *******************************************************************************/
55 u1 *intrp_disassinstr(u1 *code)
62 r = (u1 *) vm_disassemble_inst((Inst *) code, vm_prim);
69 /* function disassemble ********************************************************
71 outputs a disassembler listing of some machine code on 'stdout'
72 code: pointer to first instruction
73 len: code size (number of instructions * 4)
75 *******************************************************************************/
77 void intrp_disassemble(u1 *start, u1 *end)
81 printf(" --- disassembler listing ---\n");
84 vm_disassemble((Inst *) start, (Inst *) end, vm_prim);
89 void printarg_ui (u4 ui )
91 fprintf(vm_out, "%ud", ui);
94 void printarg_v (Cell v )
96 fprintf(vm_out, "%lld", (long long)v);
99 void printarg_Cell (Cell x )
101 fprintf(vm_out, "%lld", (long long)x);
105 void printarg_b (s4 b )
107 fprintf(vm_out, "%d", b);
110 void printarg_s (s4 s )
112 fprintf(vm_out, "%d", s);
115 void printarg_i (s4 i )
117 fprintf(vm_out, "%d", i);
120 void printarg_l (s8 l )
122 fprintf(vm_out, "%lld", (long long)l);
125 void printarg_f (float f )
127 fprintf(vm_out, "%f", (double)f);
130 void printarg_d (double d )
132 fprintf(vm_out, "%f", d);
135 void printarg_aRef (java_objectheader *aRef )
137 fprintf(vm_out, "obj: %p", (void *)aRef);
140 void printarg_aArray (java_arrayheader * aArray )
142 fprintf(vm_out, "array %p", (void *)aArray);
145 void printarg_aaTarget(Inst ** aaTarget)
148 methodinfo *m=((methodinfo **)aaTarget)[3];
151 fprintf(vm_out, "NULL");
154 void printarg_aClass (classinfo * aClass )
157 utf_fprint_printable_ascii_classname(vm_out, aClass->name);
159 fprintf(vm_out, "NULL");
162 void printarg_acr (constant_classref *acr )
164 fprintf(vm_out, "cr: %p", (void *)acr);
167 void printarg_addr (u1 * addr )
169 fprintf(vm_out, "%p", (void *)addr);
172 void printarg_af (functionptr af )
174 fprintf(vm_out, "f: %p", (void *)af);
177 void printarg_afi (fieldinfo * afi )
180 utf_fprint_printable_ascii_classname(vm_out, afi->class->name);
181 fprintf(vm_out, ".");
182 utf_fprint_printable_ascii(vm_out, afi->name);
183 utf_fprint_printable_ascii(vm_out, afi->descriptor);
185 fprintf(vm_out, "fi=NULL");
188 void printarg_am (methodinfo * am )
191 utf_fprint_printable_ascii_classname(vm_out, am->class->name);
192 fprintf(vm_out, ".");
193 utf_fprint_printable_ascii(vm_out, am->name);
194 utf_fprint_printable_ascii(vm_out, am->descriptor);
196 fprintf(vm_out, "m=NULL");
199 void printarg_acell (Cell * acell )
201 fprintf(vm_out, "%p", (void *)acell);
204 void printarg_ainst (Inst * ainst )
206 fprintf(vm_out, "%p", (void *)ainst);
209 void printarg_auf (unresolved_field * auf )
212 utf_fprint_printable_ascii(vm_out, auf->fieldref->name);
213 fprintf(vm_out, " (type ");
214 utf_fprint_printable_ascii(vm_out, auf->fieldref->descriptor);
215 fprintf(vm_out, ")");
217 fprintf(vm_out, "NULL");
220 void printarg_aum (unresolved_method *aum )
223 utf_fprint_printable_ascii_classname(vm_out, METHODREF_CLASSNAME(aum->methodref));
224 fprintf(vm_out, ".");
225 utf_fprint_printable_ascii(vm_out, aum->methodref->name);
226 utf_fprint_printable_ascii(vm_out, aum->methodref->descriptor);
228 fprintf(vm_out, "NULL");
231 void printarg_avftbl (vftbl_t * avftbl )
234 fprintf(vm_out, "vftbl: ");
235 utf_fprint_printable_ascii_classname(vm_out, avftbl->class->name);
237 fprintf(vm_out, "NULL");
242 * These are local overrides for various environment variables in Emacs.
243 * Please do not remove this and leave it at the end of the file, where
244 * Emacs will automagically detect them.
245 * ---------------------------------------------------------------------
248 * indent-tabs-mode: t
252 * vim:noexpandtab:sw=4:ts=4: