Added and changed some SUPPORT defines.
[cacao.git] / src / vm / jit / x86_64 / dis-buf.c
1 /* Disassemble from a buffer, for GNU.
2    Copyright 1993, 1994, 1996, 1997, 1998, 1999, 2000
3    Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18
19 /* #include "sysdep.h" */
20 #include "dis-asm.h"
21 #include <errno.h>
22 /* #include "opintl.h" */
23
24 /* Get LENGTH bytes from info's buffer, at target address memaddr.
25    Transfer them to myaddr.  */
26 #if 0
27 int
28 buffer_read_memory (memaddr, myaddr, length, info)
29      bfd_vma memaddr;
30      bfd_byte *myaddr;
31      unsigned int length;
32      struct disassemble_info *info;
33 {
34   unsigned int opb = info->octets_per_byte;
35   unsigned int end_addr_offset = length / opb;
36   unsigned int max_addr_offset = info->buffer_length / opb; 
37   unsigned int octets = (memaddr - info->buffer_vma) * opb;
38
39   if (memaddr < info->buffer_vma
40       || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
41     /* Out of bounds.  Use EIO because GDB uses it.  */
42     return EIO;
43   memcpy (myaddr, info->buffer + octets, length);
44
45   return 0;
46 }
47 #endif
48
49 /* Print an error message.  We can assume that this is in response to
50    an error return from buffer_read_memory.  */
51 void
52 perror_memory (status, memaddr, info)
53      int status;
54      bfd_vma memaddr;
55      struct disassemble_info *info;
56 {
57   if (status != EIO)
58     /* Can't happen.  */
59     info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
60   else
61     /* Actually, address between memaddr and memaddr + len was
62        out of bounds.  */
63     info->fprintf_func (info->stream,
64                         _("Address 0x%x is out of bounds.\n"), memaddr);
65 }
66
67 /* This could be in a separate file, to save miniscule amounts of space
68    in statically linked executables.  */
69
70 /* Just print the address is hex.  This is included for completeness even
71    though both GDB and objdump provide their own (to print symbolic
72    addresses).  */
73
74 void
75 generic_print_address (addr, info)
76      bfd_vma addr;
77      struct disassemble_info *info;
78 {
79   char buf[30];
80
81   sprintf_vma (buf, addr);
82   (*info->fprintf_func) (info->stream, "0x%s", buf);
83 }
84
85 #if 0
86 /* Just concatenate the address as hex.  This is included for
87    completeness even though both GDB and objdump provide their own (to
88    print symbolic addresses).  */
89
90 void generic_strcat_address PARAMS ((bfd_vma, char *, int));
91
92 void
93 generic_strcat_address (addr, buf, len)
94      bfd_vma addr;
95      char *buf;
96      int len;
97 {
98   if (buf != (char *)NULL && len > 0)
99     {
100       char tmpBuf[30];
101
102       sprintf_vma (tmpBuf, addr);
103       if ((strlen (buf) + strlen (tmpBuf)) <= (unsigned int) len)
104         strcat (buf, tmpBuf);
105       else
106         strncat (buf, tmpBuf, (len - strlen(buf)));
107     }
108   return;
109 }
110 #endif
111
112 /* Just return true.  */
113
114 int
115 generic_symbol_at_address (addr, info)
116      bfd_vma addr ATTRIBUTE_UNUSED;
117      struct disassemble_info *info ATTRIBUTE_UNUSED;
118 {
119   return 1;
120 }
121
122 /* Just return TRUE.  */
123
124 #if 0
125 bfd_boolean
126 generic_symbol_is_valid (asymbol * sym ATTRIBUTE_UNUSED,
127                          struct disassemble_info *info ATTRIBUTE_UNUSED)
128 {
129   return TRUE;
130 }
131 #endif