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 if (memaddr
< info
->buffer_vma
33 || memaddr
- info
->buffer_vma
+ length
> info
->buffer_length
)
34 /* Out of bounds. Use EIO because GDB uses it. */
36 memcpy (myaddr
, info
->buffer
+ (memaddr
- info
->buffer_vma
), length
);
40 /* Print an error message. We can assume that this is in response to
41 an error return from buffer_read_memory. */
43 perror_memory (status
, memaddr
, info
)
46 struct disassemble_info
*info
;
50 info
->fprintf_func (info
->stream
, _("Unknown error %d\n"), status
);
52 /* Actually, address between memaddr and memaddr + len was
54 info
->fprintf_func (info
->stream
,
55 _("Address 0x%x is out of bounds.\n"), memaddr
);
58 /* This could be in a separate file, to save miniscule amounts of space
59 in statically linked executables. */
61 /* Just print the address is hex. This is included for completeness even
62 though both GDB and objdump provide their own (to print symbolic
66 generic_print_address (addr
, info
)
68 struct disassemble_info
*info
;
72 sprintf_vma (buf
, addr
);
73 (*info
->fprintf_func
) (info
->stream
, "0x%s", buf
);
76 /* Just concatenate the address as hex. This is included for
77 completeness even though both GDB and objdump provide their own (to
78 print symbolic addresses). */
81 generic_strcat_address (addr
, buf
, len
)
86 if (buf
!= (char *)NULL
&& len
> 0)
90 sprintf_vma (tmpBuf
, addr
);
91 if ((strlen (buf
) + strlen (tmpBuf
)) <= (unsigned int) len
)
94 strncat (buf
, tmpBuf
, (len
- strlen(buf
)));
99 /* Just return the given address. */
102 generic_symbol_at_address (addr
, info
)
103 bfd_vma addr ATTRIBUTE_UNUSED
;
104 struct disassemble_info
*info ATTRIBUTE_UNUSED
;