OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [gdb-5.0/] [opcodes/] [dis-buf.c] - Blame information for rev 1778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/* Disassemble from a buffer, for GNU.
2
   Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
3
 
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.
8
 
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.
13
 
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.  */
17
 
18
#include "sysdep.h"
19
#include "dis-asm.h"
20
#include <errno.h>
21
#include "opintl.h"
22
 
23
/* Get LENGTH bytes from info's buffer, at target address memaddr.
24
   Transfer them to myaddr.  */
25
int
26
buffer_read_memory (memaddr, myaddr, length, info)
27
     bfd_vma memaddr;
28
     bfd_byte *myaddr;
29
     unsigned int length;
30
     struct disassemble_info *info;
31
{
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;
36
 
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.  */
40
    return EIO;
41
  memcpy (myaddr, info->buffer + octets, length);
42
 
43
  return 0;
44
}
45
 
46
/* Print an error message.  We can assume that this is in response to
47
   an error return from buffer_read_memory.  */
48
void
49
perror_memory (status, memaddr, info)
50
     int status;
51
     bfd_vma memaddr;
52
     struct disassemble_info *info;
53
{
54
  if (status != EIO)
55
    /* Can't happen.  */
56
    info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
57
  else
58
    /* Actually, address between memaddr and memaddr + len was
59
       out of bounds.  */
60
    info->fprintf_func (info->stream,
61
                        _("Address 0x%x is out of bounds.\n"), memaddr);
62
}
63
 
64
/* This could be in a separate file, to save miniscule amounts of space
65
   in statically linked executables.  */
66
 
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
69
   addresses).  */
70
 
71
void
72
generic_print_address (addr, info)
73
     bfd_vma addr;
74
     struct disassemble_info *info;
75
{
76
  char buf[30];
77
 
78
  sprintf_vma (buf, addr);
79
  (*info->fprintf_func) (info->stream, "0x%s", buf);
80
}
81
 
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).  */
85
 
86
void
87
generic_strcat_address (addr, buf, len)
88
     bfd_vma addr;
89
     char *buf;
90
     int len;
91
{
92
  if (buf != (char *)NULL && len > 0)
93
    {
94
      char tmpBuf[30];
95
 
96
      sprintf_vma (tmpBuf, addr);
97
      if ((strlen (buf) + strlen (tmpBuf)) <= (unsigned int) len)
98
        strcat (buf, tmpBuf);
99
      else
100
        strncat (buf, tmpBuf, (len - strlen(buf)));
101
    }
102
  return;
103
}
104
 
105
/* Just return the given address.  */
106
 
107
int
108
generic_symbol_at_address (addr, info)
109
     bfd_vma addr ATTRIBUTE_UNUSED;
110
     struct disassemble_info *info ATTRIBUTE_UNUSED;
111
{
112
  return 1;
113
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.