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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [bfd-target.c] - Blame information for rev 280

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

Line No. Rev Author Line
1 227 jeremybenn
/* Very simple "bfd" target, for GDB, the GNU debugger.
2
 
3
   Copyright (C) 2003, 2005, 2007, 2008, 2009, 2010
4
   Free Software Foundation, Inc.
5
 
6
   This file is part of GDB.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
 
21
#include "defs.h"
22
#include "target.h"
23
#include "bfd-target.h"
24
#include "exec.h"
25
 
26
/* The object that is stored in the target_ops->to_data field has this
27
   type.  */
28
struct target_bfd_data
29
{
30
  /* The BFD we're wrapping.  */
31
  struct bfd *bfd;
32
 
33
  /* The section table build from the ALLOC sections in BFD.  Note
34
     that we can't rely on extracting the BFD from a random section in
35
     the table, since the table can be legitimately empty.  */
36
  struct target_section_table table;
37
};
38
 
39
static LONGEST
40
target_bfd_xfer_partial (struct target_ops *ops,
41
                         enum target_object object,
42
                         const char *annex, gdb_byte *readbuf,
43
                         const gdb_byte *writebuf,
44
                         ULONGEST offset, LONGEST len)
45
{
46
  switch (object)
47
    {
48
    case TARGET_OBJECT_MEMORY:
49
      {
50
        struct target_bfd_data *data = ops->to_data;
51
        return section_table_xfer_memory_partial (readbuf, writebuf,
52
                                                  offset, len,
53
                                                  data->table.sections,
54
                                                  data->table.sections_end,
55
                                                  NULL);
56
      }
57
    default:
58
      return -1;
59
    }
60
}
61
 
62
static struct target_section_table *
63
target_bfd_get_section_table (struct target_ops *ops)
64
{
65
  struct target_bfd_data *data = ops->to_data;
66
  return &data->table;
67
}
68
 
69
static void
70
target_bfd_xclose (struct target_ops *t, int quitting)
71
{
72
  struct target_bfd_data *data = t->to_data;
73
 
74
  bfd_close (data->bfd);
75
  xfree (data->table.sections);
76
  xfree (data);
77
  xfree (t);
78
}
79
 
80
struct target_ops *
81
target_bfd_reopen (struct bfd *bfd)
82
{
83
  struct target_ops *t;
84
  struct target_bfd_data *data;
85
 
86
  data = XZALLOC (struct target_bfd_data);
87
  data->bfd = bfd;
88
  build_section_table (bfd, &data->table.sections, &data->table.sections_end);
89
 
90
  t = XZALLOC (struct target_ops);
91
  t->to_shortname = "bfd";
92
  t->to_longname = _("BFD backed target");
93
  t->to_doc = _("You should never see this");
94
  t->to_get_section_table = target_bfd_get_section_table;
95
  t->to_xfer_partial = target_bfd_xfer_partial;
96
  t->to_xclose = target_bfd_xclose;
97
  t->to_data = data;
98
 
99
  return t;
100
}

powered by: WebSVN 2.1.0

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