Update FSF address.
[deliverable/binutils-gdb.git] / gdb / xcoffsolib.c
CommitLineData
5140562f
JG
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
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
6c9638b4 19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
5140562f 20
fb494327 21#if 0
1eeba686
PB
22#include <sys/types.h>
23#include <sys/ldr.h>
fb494327 24#endif
1eeba686
PB
25
26#include "defs.h"
27#include "bfd.h"
1eeba686 28#include "xcoffsolib.h"
fb494327 29#include "inferior.h"
1eeba686 30
2aefe6e4
JK
31#ifdef SOLIB_SYMBOLS_MANUAL
32
1eeba686
PB
33extern struct symtab *current_source_symtab;
34extern int current_source_line;
35
1eeba686
PB
36/* The real work of adding a shared library file to the symtab and
37 the section list. */
38
39void
40solib_add (arg_string, from_tty, target)
41 char *arg_string;
42 int from_tty;
43 struct target_ops *target;
44{
45 char *val;
46 struct vmap *vp = vmap;
47 struct objfile *obj;
48 struct symtab *saved_symtab;
49 int saved_line;
50
51 int loaded = 0; /* true if any shared obj loaded */
52 int matched = 0; /* true if any shared obj matched */
53
54 if (arg_string == 0)
55 re_comp (".");
56 else if (val = (char *) re_comp (arg_string)) {
57 error ("Invalid regexp: %s", val);
58 }
59 if (!vp || !vp->nxt)
60 return;
61
62 /* save current symbol table and line number, in case they get changed
63 in symbol loading process. */
64
65 saved_symtab = current_source_symtab;
66 saved_line = current_source_line;
67
68 /* skip over the first vmap, it is the main program, always loaded. */
69 vp = vp->nxt;
70
71 for (; vp; vp = vp->nxt) {
72
73 if (re_exec (vp->name) || (*vp->member && re_exec (vp->member))) {
74
75 matched = 1;
76
77 /* if already loaded, continue with the next one. */
78 if (vp->loaded) {
79
199b2450 80 printf_unfiltered ("%s%s%s%s: already loaded.\n",
1eeba686
PB
81 *vp->member ? "(" : "",
82 vp->member,
83 *vp->member ? ") " : "",
84 vp->name);
85 continue;
86 }
87
199b2450 88 printf_unfiltered ("Loading %s%s%s%s...",
1eeba686
PB
89 *vp->member ? "(" : "",
90 vp->member,
91 *vp->member ? ") " : "",
92 vp->name);
199b2450 93 gdb_flush (gdb_stdout);
1eeba686 94
2aefe6e4
JK
95 /* This is gross and doesn't work. If this code is re-enabled,
96 just stick a objfile member into the struct vmap; that's the
97 way solib.c (for SunOS/SVR4) does it. */
1eeba686
PB
98 obj = lookup_objfile_bfd (vp->bfd);
99 if (!obj) {
100 warning ("\nObj structure for the shared object not found. Loading failed.");
101 continue;
102 }
103
2d6d969c
FF
104 syms_from_objfile (obj, 0, 0, 0);
105 new_symfile_objfile (obj, 0, 0);
1eeba686 106 vmap_symtab (vp, 0, 0);
199b2450 107 printf_unfiltered ("Done.\n");
1eeba686
PB
108 loaded = vp->loaded = 1;
109 }
110 }
111 /* if any shared object is loaded, then misc_func_vector needs sorting. */
112 if (loaded) {
113#if 0
114 sort_misc_function_vector ();
115#endif
116 current_source_symtab = saved_symtab;
117 current_source_line = saved_line;
118
119 /* Getting new symbols might change our opinion about what is frameless.
120 Is this correct?? FIXME. */
121/* reinit_frame_cache(); */
122 }
123 else if (!matched)
199b2450 124 printf_unfiltered ("No matching shared object found.\n");
1eeba686 125}
2aefe6e4 126#endif /* SOLIB_SYMBOLS_MANUAL */
1eeba686
PB
127
128/* Return the module name of a given text address. Note that returned buffer
129 is not persistent. */
130
131char *
132pc_load_segment_name (addr)
133CORE_ADDR addr;
134{
135 static char buffer [BUFSIZ];
136 struct vmap *vp = vmap;
137
138 buffer [0] = buffer [1] = '\0';
139 for (; vp; vp = vp->nxt)
140 if (vp->tstart <= addr && addr < vp->tend) {
141 if (*vp->member) {
142 buffer [0] = '(';
143 strcat (&buffer[1], vp->member);
144 strcat (buffer, ")");
145 }
146 strcat (buffer, vp->name);
147 return buffer;
148 }
149 return "(unknown load module)";
150}
151
fb494327 152static void solib_info PARAMS ((char *, int));
1eeba686 153
fb494327
JK
154static void
155solib_info (args, from_tty)
156 char *args;
157 int from_tty;
1eeba686 158{
fb494327 159 struct vmap *vp = vmap;
1eeba686 160
fb494327
JK
161 /* Check for new shared libraries loaded with load (). */
162 xcoff_relocate_symtab (inferior_pid);
1eeba686 163
fb494327
JK
164 if (vp == NULL || vp->nxt == NULL)
165 {
166 printf_unfiltered ("No shared libraries loaded at this time.\n");
167 return;
168 }
1eeba686 169
fb494327
JK
170 /* Skip over the first vmap, it is the main program, always loaded. */
171 vp = vp->nxt;
1eeba686 172
fb494327 173 printf_unfiltered ("\
1eeba686
PB
174Text Range Data Range Syms Shared Object Library\n");
175
fb494327
JK
176 for (; vp != NULL; vp = vp->nxt)
177 {
178 printf_unfiltered ("0x%08x-0x%08x 0x%08x-0x%08x %s %s%s%s%s\n",
179 vp->tstart, vp->tend,
180 vp->dstart, vp->dend,
181 vp->loaded ? "Yes" : "No ",
182 *vp->member ? "(" : "",
183 vp->member,
184 *vp->member ? ") " : "",
185 vp->name);
186 }
1eeba686
PB
187}
188
1eeba686
PB
189void
190sharedlibrary_command (args, from_tty)
fb494327
JK
191 char *args;
192 int from_tty;
1eeba686 193{
fb494327
JK
194 dont_repeat ();
195
196 /* Check for new shared libraries loaded with load (). */
197 xcoff_relocate_symtab (inferior_pid);
198
199#ifdef SOLIB_SYMBOLS_MANUAL
1eeba686 200 solib_add (args, from_tty, (struct target_ops *)0);
2aefe6e4 201#endif /* SOLIB_SYMBOLS_MANUAL */
fb494327 202}
1eeba686
PB
203
204void
205_initialize_solib()
206{
fb494327 207 add_com ("sharedlibrary", class_files, sharedlibrary_command,
1eeba686 208 "Load shared object library symbols for files matching REGEXP.");
fb494327
JK
209 add_info ("sharedlibrary", solib_info,
210 "Status of loaded shared object libraries");
1eeba686 211}
This page took 0.227546 seconds and 4 git commands to generate.