1 /* Disassemble from a buffer, for GNU.
2 Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* Get LENGTH bytes from info's buffer, at target address memaddr.
23 Transfer them to myaddr. */
25 buffer_read_memory (memaddr, myaddr, length, info)
29 struct disassemble_info *info;
31 if (memaddr < info->buffer_vma
32 || memaddr + length > info->buffer_vma + info->buffer_length)
33 /* Out of bounds. Use EIO because GDB uses it. */
35 memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
39 /* Print an error message. We can assume that this is in response to
40 an error return from buffer_read_memory. */
42 perror_memory (status, memaddr, info)
45 struct disassemble_info *info;
49 (*info->fprintf_func) (info->stream, "Unknown error %d\n", status);
51 /* Actually, address between memaddr and memaddr + len was
53 (*info->fprintf_func) (info->stream,
54 "Address 0x%x is out of bounds.\n", memaddr);
57 /* This could be in a separate file, to save miniscule amounts of space
58 in statically linked executables. */
60 /* Just print the address is hex. This is included for completeness even
61 though both GDB and objdump provide their own (to print symbolic
65 generic_print_address (addr, info)
67 struct disassemble_info *info;
69 (*info->fprintf_func) (info->stream, "0x%x", addr);