* valops.c (find_overload_match): Remove unused argument 'lax'.
[deliverable/binutils-gdb.git] / gdb / xcoffsolib.c
CommitLineData
c906108c 1/* Shared library support for RS/6000 (xcoff) object files, for GDB.
8acc9f48 2 Copyright (C) 1991-2013 Free Software Foundation, Inc.
c906108c
SS
3 Contributed by IBM Corporation.
4
c5aa993b 5 This file is part of GDB.
c906108c 6
c5aa993b
JM
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
c5aa993b 10 (at your option) any later version.
c906108c 11
c5aa993b
JM
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
c906108c 16
c5aa993b 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 19
c906108c
SS
20#include "defs.h"
21#include "bfd.h"
22#include "xcoffsolib.h"
23#include "inferior.h"
63f58cc5
PS
24#include "gdbcmd.h"
25#include "symfile.h"
26#include "frame.h"
27#include "gdb_regex.h"
c5aa993b 28
c906108c 29
a8079a9b
PS
30/* If ADDR lies in a shared library, return its name.
31 Note that returned name points to static data whose content is overwritten
32 by each call. */
c906108c
SS
33
34char *
a8079a9b 35xcoff_solib_address (CORE_ADDR addr)
c906108c 36{
a8079a9b 37 static char *buffer = NULL;
c5aa993b
JM
38 struct vmap *vp = vmap;
39
a8079a9b
PS
40 /* The first vmap entry is for the exec file. */
41
42 if (vp == NULL)
43 return NULL;
44 for (vp = vp->nxt; vp; vp = vp->nxt)
c5aa993b
JM
45 if (vp->tstart <= addr && addr < vp->tend)
46 {
a8079a9b 47 xfree (buffer);
b435e160
AC
48 buffer = xstrprintf ("%s%s%s%s",
49 vp->name,
50 *vp->member ? "(" : "",
51 vp->member,
52 *vp->member ? ")" : "");
c906108c 53 return buffer;
c5aa993b 54 }
a8079a9b 55 return NULL;
c906108c
SS
56}
57
a14ed312 58static void solib_info (char *, int);
63f58cc5 59static void sharedlibrary_command (char *pattern, int from_tty);
c906108c
SS
60
61static void
fba45db2 62solib_info (char *args, int from_tty)
c906108c 63{
f5656ead 64 int addr_size = gdbarch_addr_bit (target_gdbarch ()) / 8;
c906108c
SS
65 struct vmap *vp = vmap;
66
67 /* Check for new shared libraries loaded with load (). */
39f77062
KB
68 if (! ptid_equal (inferior_ptid, null_ptid))
69 xcoff_relocate_symtab (PIDGET (inferior_ptid));
c906108c
SS
70
71 if (vp == NULL || vp->nxt == NULL)
72 {
c5aa993b 73 printf_unfiltered ("No shared libraries loaded at this time.\n");
c906108c
SS
74 return;
75 }
76
77 /* Skip over the first vmap, it is the main program, always loaded. */
78 vp = vp->nxt;
79
3e43a32a
MS
80 printf_unfiltered ("Text Range Data Range "
81 "Syms Shared Object Library\n");
c906108c
SS
82
83 for (; vp != NULL; vp = vp->nxt)
84 {
d4f3574e 85 printf_unfiltered ("0x%s-0x%s 0x%s-0x%s %s %s%s%s%s\n",
5af949e3
UW
86 phex (vp->tstart, addr_size),
87 phex (vp->tend, addr_size),
88 phex (vp->dstart, addr_size),
89 phex (vp->dend, addr_size),
c906108c 90 vp->loaded ? "Yes" : "No ",
a8079a9b 91 vp->name,
c906108c
SS
92 *vp->member ? "(" : "",
93 vp->member,
a8079a9b 94 *vp->member ? ")" : "");
c906108c
SS
95 }
96}
97
63f58cc5
PS
98static void
99sharedlibrary_command (char *pattern, int from_tty)
c906108c
SS
100{
101 dont_repeat ();
102
103 /* Check for new shared libraries loaded with load (). */
39f77062
KB
104 if (! ptid_equal (inferior_ptid, null_ptid))
105 xcoff_relocate_symtab (PIDGET (inferior_ptid));
63f58cc5
PS
106
107 if (pattern)
108 {
109 char *re_err = re_comp (pattern);
c906108c 110
63f58cc5 111 if (re_err)
8a3fe4f8 112 error (_("Invalid regexp: %s"), re_err);
63f58cc5
PS
113 }
114
115 /* Walk the list of currently loaded shared libraries, and read
116 symbols for any that match the pattern --- or any whose symbols
117 aren't already loaded, if no pattern was given. */
118 {
119 int any_matches = 0;
120 int loaded_any_symbols = 0;
121 struct vmap *vp = vmap;
122
123 if (!vp)
124 return;
125
581e13c1 126 /* skip over the first vmap, it is the main program, always loaded. */
63f58cc5
PS
127 for (vp = vp->nxt; vp; vp = vp->nxt)
128 if (! pattern
129 || re_exec (vp->name)
130 || (*vp->member && re_exec (vp->member)))
131 {
132 any_matches = 1;
133
134 if (vp->loaded)
135 {
136 if (from_tty)
137 printf_unfiltered ("Symbols already loaded for %s\n",
138 vp->name);
139 }
140 else
141 {
142 if (vmap_add_symbols (vp))
143 loaded_any_symbols = 1;
144 }
145 }
146
147 if (from_tty && pattern && ! any_matches)
148 printf_unfiltered
149 ("No loaded shared libraries match the pattern `%s'.\n", pattern);
150
151 if (loaded_any_symbols)
152 {
153 /* Getting new symbols may change our opinion about what is
154 frameless. */
155 reinit_frame_cache ();
156 }
157 }
c906108c
SS
158}
159
e1aca11e
JB
160void _initialize_xcoffsolib (void);
161
c906108c 162void
fb39c8f3 163_initialize_xcoffsolib (void)
c906108c
SS
164{
165 add_com ("sharedlibrary", class_files, sharedlibrary_command,
1bedd215 166 _("Load shared object library symbols for files matching REGEXP."));
c5aa993b 167 add_info ("sharedlibrary", solib_info,
1bedd215 168 _("Status of loaded shared object libraries"));
63f58cc5 169
5bf193a2
AC
170 add_setshow_boolean_cmd ("auto-solib-add", class_support,
171 &auto_solib_add, _("\
172Set autoloading of shared library symbols."), _("\
173Show autoloading of shared library symbols."), _("\
b7209cb4
FF
174If \"on\", symbols from all shared object libraries will be loaded\n\
175automatically when the inferior begins execution, when the dynamic linker\n\
176informs gdb that a new library has been loaded, or when attaching to the\n\
3e43a32a
MS
177inferior. Otherwise, symbols must be loaded manually, using \
178`sharedlibrary'."),
5bf193a2
AC
179 NULL,
180 NULL, /* FIXME: i18n: */
181 &setlist, &showlist);
c906108c 182}
This page took 1.318286 seconds and 4 git commands to generate.