1 /* Disassemble from a buffer, for GNU.
2 Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 /* Get LENGTH bytes from info's buffer, at target address memaddr.
24 Transfer them to myaddr. */
26 buffer_read_memory (memaddr, myaddr, length, info)
30 struct disassemble_info *info;
32 unsigned int opb = info->octets_per_byte;
33 unsigned int end_addr_offset = length / opb;
34 unsigned int max_addr_offset = info->buffer_length / opb;
35 unsigned int octets = (memaddr - info->buffer_vma) * opb;
37 if (memaddr < info->buffer_vma
38 || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
39 /* Out of bounds. Use EIO because GDB uses it. */
41 memcpy (myaddr, info->buffer + octets, length);
46 /* Print an error message. We can assume that this is in response to
47 an error return from buffer_read_memory. */
49 perror_memory (status, memaddr, info)
52 struct disassemble_info *info;
56 info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
58 /* Actually, address between memaddr and memaddr + len was
60 info->fprintf_func (info->stream,
61 _("Address 0x%x is out of bounds.\n"), memaddr);
64 /* This could be in a separate file, to save miniscule amounts of space
65 in statically linked executables. */
67 /* Just print the address is hex. This is included for completeness even
68 though both GDB and objdump provide their own (to print symbolic
72 generic_print_address (addr, info)
74 struct disassemble_info *info;
78 sprintf_vma (buf, addr);
79 (*info->fprintf_func) (info->stream, "0x%s", buf);
82 /* Just concatenate the address as hex. This is included for
83 completeness even though both GDB and objdump provide their own (to
84 print symbolic addresses). */
87 generic_strcat_address (addr, buf, len)
92 if (buf != (char *)NULL && len > 0)
96 sprintf_vma (tmpBuf, addr);
97 if ((strlen (buf) + strlen (tmpBuf)) <= (unsigned int) len)
100 strncat (buf, tmpBuf, (len - strlen(buf)));
105 /* Just return the given address. */
108 generic_symbol_at_address (addr, info)
109 bfd_vma addr ATTRIBUTE_UNUSED;
110 struct disassemble_info *info ATTRIBUTE_UNUSED;