CACAO
disass.cpp
Go to the documentation of this file.
1 /* src/vm/jit/i386/disass.cpp - wrapper functions for GNU binutils disassembler
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  Contact: cacao@cacaojvm.org
24 
25  Authors: Andreas Krall
26  Reinhard Grafl
27  Christian Thalinger
28  Alexander Jordan
29 
30  Changes:
31 
32 */
33 
34 
35 #include "config.h"
36 
37 #include <cassert>
38 #include <cstdarg>
39 #include <dis-asm.h>
40 
41 #include "vm/types.hpp"
42 
43 #include "vm/global.hpp"
44 #include "vm/jit/disass.hpp"
45 
46 char *regs[] = {
47  "g0",
48  "g1",
49  "g2",
50  "g3",
51  "g4",
52  "g5",
53  "g6",
54  "g7",
55  "o0",
56  "o1",
57  "o2",
58  "o3",
59  "o4",
60  "o5",
61  "o6",
62  "o7",
63  "l0",
64  "l1",
65  "l2",
66  "l3",
67  "l4",
68  "l5",
69  "l6",
70  "l7",
71  "l0",
72  "i1",
73  "i2",
74  "i3",
75  "i4",
76  "i5",
77  "i6",
78  "i7"
79 };
80 
81 /* disassinstr *****************************************************************
82 
83  Outputs a disassembler listing of one machine code instruction on
84  'stdout'.
85 
86  code: instructions machine code
87 
88 *******************************************************************************/
89 
90 u1 *disassinstr(u1 *code)
91 {
92  if (!disass_initialized) {
93  INIT_DISASSEMBLE_INFO(info, NULL, disass_printf);
94 
95  /* setting the struct members must be done after
96  INIT_DISASSEMBLE_INFO */
97 
98  info.mach = bfd_mach_sparc_v9;
99  info.endian = BFD_ENDIAN_BIG;
100  info.read_memory_func = &disass_buffer_read_memory;
101 
102  disass_initialized = 1;
103  }
104 
105  printf("0x%016lx: %08x ", (s8) code, *((u4 *) code));
106 
107  print_insn_sparc((bfd_vma) code, &info);
108 
109  printf("\n");
110 
111  return code + 4;
112 }
113 
114 
115 /*
116  * These are local overrides for various environment variables in Emacs.
117  * Please do not remove this and leave it at the end of the file, where
118  * Emacs will automagically detect them.
119  * ---------------------------------------------------------------------
120  * Local variables:
121  * mode: c++
122  * indent-tabs-mode: t
123  * c-basic-offset: 4
124  * tab-width: 4
125  * End:
126  */
int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info)
char * regs[]
Definition: disass.c:51
u1 * disassinstr(u1 *code)
Definition: disass.cpp:48
uint8_t u1
Definition: types.hpp:40
int64_t s8
Definition: types.hpp:48
uint32_t u4
Definition: types.hpp:46
void disass_printf(PTR p, const char *fmt,...)
#define printf(...)
Definition: ssa2.cpp:40