This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / opcodes / dis-buf.c
CommitLineData
aff22f45 1/* Disassemble from a buffer, for GNU.
5c9b5f58 2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
aff22f45
JK
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18#include "dis-asm.h"
5c9b5f58 19#include <string.h>
aff22f45
JK
20#include <errno.h>
21
22/* Get LENGTH bytes from info's buffer, at target address memaddr.
23 Transfer them to myaddr. */
24int
25buffer_read_memory (memaddr, myaddr, length, info)
26 bfd_vma memaddr;
27 bfd_byte *myaddr;
28 int length;
29 struct disassemble_info *info;
30{
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. */
34 return EIO;
35 memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length);
36 return 0;
37}
38
39/* Print an error message. We can assume that this is in response to
40 an error return from buffer_read_memory. */
41void
42perror_memory (status, memaddr, info)
43 int status;
44 bfd_vma memaddr;
45 struct disassemble_info *info;
46{
47 if (status != EIO)
48 /* Can't happen. */
49 (*info->fprintf_func) (info->stream, "Unknown error %d\n", status);
50 else
51 /* Actually, address between memaddr and memaddr + len was
52 out of bounds. */
53 (*info->fprintf_func) (info->stream,
54 "Address 0x%x is out of bounds.\n", memaddr);
55}
5c9b5f58
PS
56
57/* This could be in a separate file, to save miniscule amounts of space
58 in statically linked executables. */
59
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
62 addresses). */
63
64void
65generic_print_address (addr, info)
66 bfd_vma addr;
67 struct disassemble_info *info;
68{
69 (*info->fprintf_func) (info->stream, "0x%x", addr);
70}
This page took 0.180552 seconds and 4 git commands to generate.