CACAO
disass.cpp
Go to the documentation of this file.
1 /* src/vm/jit/mips/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 */
24 
25 
26 #include "config.h"
27 
28 #include <dis-asm.h>
29 #include <stdint.h>
30 #include <cstdio>
31 
32 #include "vm/global.hpp"
33 
34 #include "vm/jit/disass.hpp"
35 
36 
37 /* disassinstr *****************************************************************
38 
39  Outputs a disassembler listing of one machine code instruction on
40  `stdout'.
41 
42  code: pointer to machine code
43 
44 *******************************************************************************/
45 
46 u1 *disassinstr(u1 *code)
47 {
48  if (!disass_initialized) {
49  INIT_DISASSEMBLE_INFO(info, NULL, disass_printf);
50 
51  /* setting the struct members must be done after
52  INIT_DISASSEMBLE_INFO */
53 
54  info.read_memory_func = &disass_buffer_read_memory;
55 
56  disass_initialized = true;
57  }
58 
59  printf("0x%08x: %08x ", (s4) code, *((s4 *) code));
60 
61 #if WORDS_BIGENDIAN
62  print_insn_big_mips((bfd_vma) code, &info);
63 #else
64  print_insn_little_mips((bfd_vma) code, &info);
65 #endif
66 
67  printf("\n");
68 
69  return code + 4;
70 }
71 
72 
73 /*
74  * These are local overrides for various environment variables in Emacs.
75  * Please do not remove this and leave it at the end of the file, where
76  * Emacs will automagically detect them.
77  * ---------------------------------------------------------------------
78  * Local variables:
79  * mode: c++
80  * indent-tabs-mode: t
81  * c-basic-offset: 4
82  * tab-width: 4
83  * End:
84  * vim:noexpandtab:sw=4:ts=4:
85  */
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
void disass_printf(PTR p, const char *fmt,...)
#define printf(...)
Definition: ssa2.cpp:40