* MAINTAINERS: Specify the vax-dec-vms5.5 target tupple.
[deliverable/binutils-gdb.git] / gdb / xcoffsolib.c
CommitLineData
c906108c
SS
1/* Shared library support for RS/6000 (xcoff) object files, for GDB.
2 Copyright 1991, 1992 Free Software Foundation.
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
9 the Free Software Foundation; either version 2 of the License, or
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
JM
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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
c906108c
SS
21
22#if 0
23#include <sys/types.h>
24#include <sys/ldr.h>
25#endif
26
27#include "defs.h"
28#include "bfd.h"
29#include "xcoffsolib.h"
30#include "inferior.h"
31#include "command.h"
32
33/* Hook to relocate symbols at runtime. If gdb is build natively, this
34 hook is initialized in by rs6000-nat.c. If not, it is currently left
35 NULL and never called. */
36
507f3c78 37void (*xcoff_relocate_symtab_hook) (unsigned int) = NULL;
c906108c
SS
38
39#ifdef SOLIB_SYMBOLS_MANUAL
40
41extern struct symtab *current_source_symtab;
c5aa993b 42extern int current_source_line;
c906108c
SS
43
44/* The real work of adding a shared library file to the symtab and
45 the section list. */
46
47void
fba45db2 48solib_add (char *arg_string, int from_tty, struct target_ops *target)
c5aa993b 49{
c906108c
SS
50 char *val;
51 struct vmap *vp = vmap;
52 struct objfile *obj;
53 struct symtab *saved_symtab;
54 int saved_line;
55
c5aa993b
JM
56 int loaded = 0; /* true if any shared obj loaded */
57 int matched = 0; /* true if any shared obj matched */
c906108c
SS
58
59 if (arg_string == 0)
c5aa993b
JM
60 re_comp (".");
61 else if (val = (char *) re_comp (arg_string))
62 {
c906108c 63 error ("Invalid regexp: %s", val);
c5aa993b 64 }
c906108c
SS
65 if (!vp || !vp->nxt)
66 return;
67
68 /* save current symbol table and line number, in case they get changed
69 in symbol loading process. */
c5aa993b 70
c906108c
SS
71 saved_symtab = current_source_symtab;
72 saved_line = current_source_line;
73
74 /* skip over the first vmap, it is the main program, always loaded. */
75 vp = vp->nxt;
76
c5aa993b
JM
77 for (; vp; vp = vp->nxt)
78 {
c906108c 79
c5aa993b
JM
80 if (re_exec (vp->name) || (*vp->member && re_exec (vp->member)))
81 {
82
83 matched = 1;
84
85 /* if already loaded, continue with the next one. */
86 if (vp->loaded)
87 {
88
89 printf_unfiltered ("%s%s%s%s: already loaded.\n",
90 *vp->member ? "(" : "",
91 vp->member,
92 *vp->member ? ") " : "",
93 vp->name);
94 continue;
95 }
96
97 printf_unfiltered ("Loading %s%s%s%s...",
98 *vp->member ? "(" : "",
99 vp->member,
100 *vp->member ? ") " : "",
101 vp->name);
102 gdb_flush (gdb_stdout);
103
104 /* This is gross and doesn't work. If this code is re-enabled,
105 just stick a objfile member into the struct vmap; that's the
106 way solib.c (for SunOS/SVR4) does it. */
107 obj = lookup_objfile_bfd (vp->bfd);
108 if (!obj)
109 {
110 warning ("\nObj structure for the shared object not found. Loading failed.");
111 continue;
112 }
113
2acceee2 114 syms_from_objfile (obj, NULL, 0, 0);
c5aa993b 115 new_symfile_objfile (obj, 0, 0);
8956470d 116 vmap_symtab (vp);
c5aa993b
JM
117 printf_unfiltered ("Done.\n");
118 loaded = vp->loaded = 1;
c906108c 119 }
c906108c 120 }
c906108c 121 /* if any shared object is loaded, then misc_func_vector needs sorting. */
c5aa993b
JM
122 if (loaded)
123 {
c906108c 124#if 0
c5aa993b 125 sort_misc_function_vector ();
c906108c 126#endif
c5aa993b
JM
127 current_source_symtab = saved_symtab;
128 current_source_line = saved_line;
c906108c 129
c5aa993b
JM
130 /* Getting new symbols might change our opinion about what is frameless.
131 Is this correct?? FIXME. */
c906108c 132/* reinit_frame_cache(); */
c5aa993b 133 }
c906108c
SS
134 else if (!matched)
135 printf_unfiltered ("No matching shared object found.\n");
136}
137#endif /* SOLIB_SYMBOLS_MANUAL */
138
139/* Return the module name of a given text address. Note that returned buffer
140 is not persistent. */
141
142char *
fba45db2 143pc_load_segment_name (CORE_ADDR addr)
c906108c 144{
c5aa993b
JM
145 static char buffer[BUFSIZ];
146 struct vmap *vp = vmap;
147
148 buffer[0] = buffer[1] = '\0';
149 for (; vp; vp = vp->nxt)
150 if (vp->tstart <= addr && addr < vp->tend)
151 {
152 if (*vp->member)
153 {
154 buffer[0] = '(';
155 strcat (&buffer[1], vp->member);
156 strcat (buffer, ")");
157 }
c906108c
SS
158 strcat (buffer, vp->name);
159 return buffer;
c5aa993b
JM
160 }
161 return "(unknown load module)";
c906108c
SS
162}
163
a14ed312 164static void solib_info (char *, int);
c906108c
SS
165
166static void
fba45db2 167solib_info (char *args, int from_tty)
c906108c
SS
168{
169 struct vmap *vp = vmap;
170
171 /* Check for new shared libraries loaded with load (). */
172 if (xcoff_relocate_symtab_hook != NULL)
173 (*xcoff_relocate_symtab_hook) (inferior_pid);
174
175 if (vp == NULL || vp->nxt == NULL)
176 {
c5aa993b 177 printf_unfiltered ("No shared libraries loaded at this time.\n");
c906108c
SS
178 return;
179 }
180
181 /* Skip over the first vmap, it is the main program, always loaded. */
182 vp = vp->nxt;
183
184 printf_unfiltered ("\
185Text Range Data Range Syms Shared Object Library\n");
186
187 for (; vp != NULL; vp = vp->nxt)
188 {
d4f3574e
SS
189 printf_unfiltered ("0x%s-0x%s 0x%s-0x%s %s %s%s%s%s\n",
190 paddr (vp->tstart),paddr (vp->tend),
191 paddr (vp->dstart), paddr (vp->dend),
c906108c
SS
192 vp->loaded ? "Yes" : "No ",
193 *vp->member ? "(" : "",
194 vp->member,
195 *vp->member ? ") " : "",
196 vp->name);
197 }
198}
199
200void
fba45db2 201sharedlibrary_command (char *args, int from_tty)
c906108c
SS
202{
203 dont_repeat ();
204
205 /* Check for new shared libraries loaded with load (). */
206 if (xcoff_relocate_symtab_hook != NULL)
207 (*xcoff_relocate_symtab_hook) (inferior_pid);
208
209#ifdef SOLIB_SYMBOLS_MANUAL
c5aa993b 210 solib_add (args, from_tty, (struct target_ops *) 0);
c906108c
SS
211#endif /* SOLIB_SYMBOLS_MANUAL */
212}
213
214void
fba45db2 215_initialize_solib (void)
c906108c
SS
216{
217 add_com ("sharedlibrary", class_files, sharedlibrary_command,
218 "Load shared object library symbols for files matching REGEXP.");
c5aa993b 219 add_info ("sharedlibrary", solib_info,
c906108c
SS
220 "Status of loaded shared object libraries");
221}
This page took 0.095016 seconds and 4 git commands to generate.