OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [xcoffsolib.c] - Blame information for rev 227

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* Shared library support for RS/6000 (xcoff) object files, for GDB.
2
   Copyright (C) 1991, 1992, 1995, 1996, 1999, 2000, 2001, 2007, 2008, 2009,
3
   2010 Free Software Foundation, Inc.
4
   Contributed by IBM Corporation.
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 "bfd.h"
23
#include "xcoffsolib.h"
24
#include "inferior.h"
25
#include "gdbcmd.h"
26
#include "symfile.h"
27
#include "frame.h"
28
#include "gdb_regex.h"
29
 
30
 
31
/* If ADDR lies in a shared library, return its name.
32
   Note that returned name points to static data whose content is overwritten
33
   by each call.  */
34
 
35
char *
36
xcoff_solib_address (CORE_ADDR addr)
37
{
38
  static char *buffer = NULL;
39
  struct vmap *vp = vmap;
40
 
41
  /* The first vmap entry is for the exec file.  */
42
 
43
  if (vp == NULL)
44
    return NULL;
45
  for (vp = vp->nxt; vp; vp = vp->nxt)
46
    if (vp->tstart <= addr && addr < vp->tend)
47
      {
48
        xfree (buffer);
49
        buffer = xstrprintf ("%s%s%s%s",
50
                             vp->name,
51
                             *vp->member ? "(" : "",
52
                             vp->member,
53
                             *vp->member ? ")" : "");
54
        return buffer;
55
      }
56
  return NULL;
57
}
58
 
59
static void solib_info (char *, int);
60
static void sharedlibrary_command (char *pattern, int from_tty);
61
 
62
static void
63
solib_info (char *args, int from_tty)
64
{
65
  int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
66
  struct vmap *vp = vmap;
67
 
68
  /* Check for new shared libraries loaded with load ().  */
69
  if (! ptid_equal (inferior_ptid, null_ptid))
70
    xcoff_relocate_symtab (PIDGET (inferior_ptid));
71
 
72
  if (vp == NULL || vp->nxt == NULL)
73
    {
74
      printf_unfiltered ("No shared libraries loaded at this time.\n");
75
      return;
76
    }
77
 
78
  /* Skip over the first vmap, it is the main program, always loaded.  */
79
  vp = vp->nxt;
80
 
81
  printf_unfiltered ("\
82
Text Range              Data Range              Syms    Shared Object Library\n");
83
 
84
  for (; vp != NULL; vp = vp->nxt)
85
    {
86
      printf_unfiltered ("0x%s-0x%s     0x%s-0x%s       %s      %s%s%s%s\n",
87
                         phex (vp->tstart, addr_size),
88
                         phex (vp->tend, addr_size),
89
                         phex (vp->dstart, addr_size),
90
                         phex (vp->dend, addr_size),
91
                         vp->loaded ? "Yes" : "No ",
92
                         vp->name,
93
                         *vp->member ? "(" : "",
94
                         vp->member,
95
                         *vp->member ? ")" : "");
96
    }
97
}
98
 
99
static void
100
sharedlibrary_command (char *pattern, int from_tty)
101
{
102
  dont_repeat ();
103
 
104
  /* Check for new shared libraries loaded with load ().  */
105
  if (! ptid_equal (inferior_ptid, null_ptid))
106
    xcoff_relocate_symtab (PIDGET (inferior_ptid));
107
 
108
  if (pattern)
109
    {
110
      char *re_err = re_comp (pattern);
111
 
112
      if (re_err)
113
        error (_("Invalid regexp: %s"), re_err);
114
    }
115
 
116
  /* Walk the list of currently loaded shared libraries, and read
117
     symbols for any that match the pattern --- or any whose symbols
118
     aren't already loaded, if no pattern was given.  */
119
  {
120
    int any_matches = 0;
121
    int loaded_any_symbols = 0;
122
    struct vmap *vp = vmap;
123
 
124
    if (!vp)
125
      return;
126
 
127
    /* skip over the first vmap, it is the main program, always loaded. */
128
    for (vp = vp->nxt; vp; vp = vp->nxt)
129
      if (! pattern
130
            || re_exec (vp->name)
131
            || (*vp->member && re_exec (vp->member)))
132
        {
133
          any_matches = 1;
134
 
135
          if (vp->loaded)
136
            {
137
              if (from_tty)
138
                printf_unfiltered ("Symbols already loaded for %s\n",
139
                                   vp->name);
140
            }
141
          else
142
            {
143
              if (vmap_add_symbols (vp))
144
                loaded_any_symbols = 1;
145
            }
146
        }
147
 
148
    if (from_tty && pattern && ! any_matches)
149
      printf_unfiltered
150
        ("No loaded shared libraries match the pattern `%s'.\n", pattern);
151
 
152
    if (loaded_any_symbols)
153
      {
154
        /* Getting new symbols may change our opinion about what is
155
           frameless.  */
156
        reinit_frame_cache ();
157
      }
158
  }
159
}
160
 
161
void
162
_initialize_xcoffsolib (void)
163
{
164
  add_com ("sharedlibrary", class_files, sharedlibrary_command,
165
           _("Load shared object library symbols for files matching REGEXP."));
166
  add_info ("sharedlibrary", solib_info,
167
            _("Status of loaded shared object libraries"));
168
 
169
  add_setshow_boolean_cmd ("auto-solib-add", class_support,
170
                           &auto_solib_add, _("\
171
Set autoloading of shared library symbols."), _("\
172
Show autoloading of shared library symbols."), _("\
173
If \"on\", symbols from all shared object libraries will be loaded\n\
174
automatically when the inferior begins execution, when the dynamic linker\n\
175
informs gdb that a new library has been loaded, or when attaching to the\n\
176
inferior.  Otherwise, symbols must be loaded manually, using `sharedlibrary'."),
177
                           NULL,
178
                           NULL, /* FIXME: i18n: */
179
                           &setlist, &showlist);
180
}

powered by: WebSVN 2.1.0

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