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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [opcodes/] [dis-buf.c] - Blame information for rev 866

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

Line No. Rev Author Line
1 24 jeremybenn
/* Disassemble from a buffer, for GNU.
2
   Copyright 1993, 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2005,
3 225 jeremybenn
   2007, 2009  Free Software Foundation, Inc.
4 24 jeremybenn
 
5
   This file is part of the GNU opcodes library.
6
 
7
   This library is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
 
12
   It is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
 
22
#include "sysdep.h"
23
#include "dis-asm.h"
24
#include <errno.h>
25
#include "opintl.h"
26
 
27
/* Get LENGTH bytes from info's buffer, at target address memaddr.
28
   Transfer them to myaddr.  */
29
int
30
buffer_read_memory (bfd_vma memaddr,
31
                    bfd_byte *myaddr,
32
                    unsigned int length,
33
                    struct disassemble_info *info)
34
{
35
  unsigned int opb = info->octets_per_byte;
36
  unsigned int end_addr_offset = length / opb;
37
  unsigned int max_addr_offset = info->buffer_length / opb;
38
  unsigned int octets = (memaddr - info->buffer_vma) * opb;
39
 
40
  if (memaddr < info->buffer_vma
41
      || memaddr - info->buffer_vma + end_addr_offset > max_addr_offset)
42
    /* Out of bounds.  Use EIO because GDB uses it.  */
43
    return EIO;
44
  memcpy (myaddr, info->buffer + octets, length);
45
 
46
  return 0;
47
}
48
 
49
/* Print an error message.  We can assume that this is in response to
50
   an error return from buffer_read_memory.  */
51
 
52
void
53
perror_memory (int status,
54
               bfd_vma memaddr,
55
               struct disassemble_info *info)
56
{
57
  if (status != EIO)
58
    /* Can't happen.  */
59
    info->fprintf_func (info->stream, _("Unknown error %d\n"), status);
60
  else
61
    {
62
      char buf[30];
63
 
64
      /* Actually, address between memaddr and memaddr + len was
65
         out of bounds.  */
66
      sprintf_vma (buf, memaddr);
67
      info->fprintf_func (info->stream,
68
                          _("Address 0x%s is out of bounds.\n"), buf);
69
    }
70
}
71
 
72
/* This could be in a separate file, to save miniscule amounts of space
73
   in statically linked executables.  */
74
 
75
/* Just print the address is hex.  This is included for completeness even
76
   though both GDB and objdump provide their own (to print symbolic
77
   addresses).  */
78
 
79
void
80
generic_print_address (bfd_vma addr, struct disassemble_info *info)
81
{
82
  char buf[30];
83
 
84
  sprintf_vma (buf, addr);
85
  (*info->fprintf_func) (info->stream, "0x%s", buf);
86
}
87
 
88
/* Just return true.  */
89
 
90
int
91
generic_symbol_at_address (bfd_vma addr ATTRIBUTE_UNUSED,
92
                           struct disassemble_info *info ATTRIBUTE_UNUSED)
93
{
94
  return 1;
95
}
96
 
97
/* Just return TRUE.  */
98
 
99
bfd_boolean
100
generic_symbol_is_valid (asymbol * sym ATTRIBUTE_UNUSED,
101
                         struct disassemble_info *info ATTRIBUTE_UNUSED)
102
{
103
  return TRUE;
104
}

powered by: WebSVN 2.1.0

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