1 /* src/vm/jit/disass-common.c - common functions for GNU binutils disassembler
3 Copyright (C) 1996-2005, 2006, 2007 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 $Id: disass-common.c 7596 2007-03-28 21:05:53Z twisti $
38 #include "mm/memory.h"
40 #include "vm/jit/disass.h"
43 /* global variables ***********************************************************/
45 #if defined(WITH_BINUTILS_DISASSEMBLER)
46 disassemble_info info;
47 bool disass_initialized = false;
51 /* We need this on i386 and x86_64 since we don't know the byte length
52 of currently printed instructions. 512 bytes should be enough. */
54 #if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
60 /* disassemble *****************************************************************
62 Outputs a disassembler listing of some machine code on `stdout'.
64 start: pointer to first machine instruction
65 end: pointer after last machine instruction
67 *******************************************************************************/
69 #if defined(ENABLE_JIT)
70 void disassemble(u1 *start, u1 *end)
72 printf(" --- disassembler listing ---\n");
75 start = disassinstr(start);
80 /* disass_printf ***************************************************************
82 Required by binutils disassembler. This just prints the
83 disassembled instructions to stdout.
85 *******************************************************************************/
87 void disass_printf(PTR p, const char *fmt, ...)
93 #if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
94 disass_len += vsprintf(disass_buf + disass_len, fmt, ap);
104 /* buffer_read_memory **********************************************************
106 We need to replace the buffer_read_memory from binutils.
108 *******************************************************************************/
110 int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info)
112 MCOPY(myaddr, (void *) (ptrint) memaddr, u1, length);
119 * These are local overrides for various environment variables in Emacs.
120 * Please do not remove this and leave it at the end of the file, where
121 * Emacs will automagically detect them.
122 * ---------------------------------------------------------------------
125 * indent-tabs-mode: t