1 /* src/vm/jit/disass-common.c - common functions for GNU binutils disassembler
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: Christian Thalinger
31 $Id: disass-common.c 4844 2006-04-25 18:02:15Z edwin $
38 #if defined(WITH_BINUTILS_DISASSEMBLER)
47 #include "mm/memory.h"
48 #include "vm/jit/disass.h"
51 /* global variables ***********************************************************/
53 #if defined(WITH_BINUTILS_DISASSEMBLER)
54 disassemble_info info;
55 bool disass_initialized = false;
59 /* We need this on i386 and x86_64 since we don't know the byte length
60 of currently printed instructions. 512 bytes should be enough. */
62 #if defined(__I386__) || defined(__X86_64__)
68 /* disassemble *****************************************************************
70 Outputs a disassembler listing of some machine code on `stdout'.
72 start: pointer to first machine instruction
73 end: pointer after last machine instruction
75 *******************************************************************************/
77 #if defined(ENABLE_JIT)
78 void disassemble(u1 *start, u1 *end)
80 printf(" --- disassembler listing ---\n");
83 start = disassinstr(start);
88 /* disass_printf ***************************************************************
90 Required by binutils disassembler. This just prints the
91 disassembled instructions to stdout.
93 *******************************************************************************/
95 #if defined(WITH_BINUTILS_DISASSEMBLER)
96 void disass_printf(PTR p, const char *fmt, ...)
102 #if defined(__I386__) || defined(__X86_64__)
103 disass_len += vsprintf(disass_buf + disass_len, fmt, ap);
113 /* buffer_read_memory **********************************************************
115 We need to replace the buffer_read_memory from binutils.
117 *******************************************************************************/
119 int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info)
121 MCOPY(myaddr, (void *) (ptrint) memaddr, u1, length);
125 #endif /* defined(WITH_BINUTILS_DISASSEMBLER) */
129 * These are local overrides for various environment variables in Emacs.
130 * Please do not remove this and leave it at the end of the file, where
131 * Emacs will automagically detect them.
132 * ---------------------------------------------------------------------
135 * indent-tabs-mode: t