* stabs.texinfo (Negative Type Numbers): FORTRAN LOGICAL fix.
[deliverable/binutils-gdb.git] / gdb / xcoffsolib.c
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
5 This file is part of GDB.
6
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.
11
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.
16
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #include <sys/types.h>
22 #include <sys/ldr.h>
23
24 #include "defs.h"
25 #include "bfd.h"
26 #include "xcoffsolib.h"
27
28 #ifdef SOLIB_SYMBOLS_MANUAL
29
30 extern struct symtab *current_source_symtab;
31 extern int current_source_line;
32
33 /* The real work of adding a shared library file to the symtab and
34 the section list. */
35
36 void
37 solib_add (arg_string, from_tty, target)
38 char *arg_string;
39 int from_tty;
40 struct target_ops *target;
41 {
42 char *val;
43 struct vmap *vp = vmap;
44 struct objfile *obj;
45 struct symtab *saved_symtab;
46 int saved_line;
47
48 int loaded = 0; /* true if any shared obj loaded */
49 int matched = 0; /* true if any shared obj matched */
50
51 if (arg_string == 0)
52 re_comp (".");
53 else if (val = (char *) re_comp (arg_string)) {
54 error ("Invalid regexp: %s", val);
55 }
56 if (!vp || !vp->nxt)
57 return;
58
59 /* save current symbol table and line number, in case they get changed
60 in symbol loading process. */
61
62 saved_symtab = current_source_symtab;
63 saved_line = current_source_line;
64
65 /* skip over the first vmap, it is the main program, always loaded. */
66 vp = vp->nxt;
67
68 for (; vp; vp = vp->nxt) {
69
70 if (re_exec (vp->name) || (*vp->member && re_exec (vp->member))) {
71
72 matched = 1;
73
74 /* if already loaded, continue with the next one. */
75 if (vp->loaded) {
76
77 printf ("%s%s%s%s: already loaded.\n",
78 *vp->member ? "(" : "",
79 vp->member,
80 *vp->member ? ") " : "",
81 vp->name);
82 continue;
83 }
84
85 printf ("Loading %s%s%s%s...",
86 *vp->member ? "(" : "",
87 vp->member,
88 *vp->member ? ") " : "",
89 vp->name);
90 fflush (stdout);
91
92 /* This is gross and doesn't work. If this code is re-enabled,
93 just stick a objfile member into the struct vmap; that's the
94 way solib.c (for SunOS/SVR4) does it. */
95 obj = lookup_objfile_bfd (vp->bfd);
96 if (!obj) {
97 warning ("\nObj structure for the shared object not found. Loading failed.");
98 continue;
99 }
100
101 syms_from_objfile (obj, 0, 0, 0);
102 new_symfile_objfile (obj, 0, 0);
103 vmap_symtab (vp, 0, 0);
104 printf ("Done.\n");
105 loaded = vp->loaded = 1;
106 }
107 }
108 /* if any shared object is loaded, then misc_func_vector needs sorting. */
109 if (loaded) {
110 #if 0
111 sort_misc_function_vector ();
112 #endif
113 current_source_symtab = saved_symtab;
114 current_source_line = saved_line;
115
116 /* Getting new symbols might change our opinion about what is frameless.
117 Is this correct?? FIXME. */
118 /* reinit_frame_cache(); */
119 }
120 else if (!matched)
121 printf ("No matching shared object found.\n");
122 }
123 #endif /* SOLIB_SYMBOLS_MANUAL */
124
125 /* Return the module name of a given text address. Note that returned buffer
126 is not persistent. */
127
128 char *
129 pc_load_segment_name (addr)
130 CORE_ADDR addr;
131 {
132 static char buffer [BUFSIZ];
133 struct vmap *vp = vmap;
134
135 buffer [0] = buffer [1] = '\0';
136 for (; vp; vp = vp->nxt)
137 if (vp->tstart <= addr && addr < vp->tend) {
138 if (*vp->member) {
139 buffer [0] = '(';
140 strcat (&buffer[1], vp->member);
141 strcat (buffer, ")");
142 }
143 strcat (buffer, vp->name);
144 return buffer;
145 }
146 return "(unknown load module)";
147 }
148
149
150 solib_info (ldi)
151 register struct ld_info *ldi;
152 {
153
154 struct vmap *vp = vmap;
155
156 if (!vp || !vp->nxt) {
157 printf("No shared libraries loaded at this time.\n");
158 return;
159 }
160
161 /* skip over the first vmap, it is the main program, always loaded. */
162 vp = vp->nxt;
163
164 printf ("\
165 Text Range Data Range Syms Shared Object Library\n");
166
167 for (; vp; vp = vp->nxt) {
168
169 printf ("0x%08x-0x%08x 0x%08x-0x%08x %s %s%s%s%s\n",
170 vp->tstart, vp->tend,
171 vp->dstart, vp->dend,
172 vp->loaded ? "Yes" : "No ",
173 *vp->member ? "(" : "",
174 vp->member,
175 *vp->member ? ") " : "",
176 vp->name);
177 }
178 }
179
180 #ifdef SOLIB_SYMBOLS_MANUAL
181 void
182 sharedlibrary_command (args, from_tty)
183 char *args;
184 int from_tty;
185 {
186 dont_repeat();
187 solib_add (args, from_tty, (struct target_ops *)0);
188 }
189 #endif /* SOLIB_SYMBOLS_MANUAL */
190
191 void
192 _initialize_solib()
193 {
194
195 #ifdef SOLIB_SYMBOLS_MANUAL
196 add_com("sharedlibrary", class_files, sharedlibrary_command,
197 "Load shared object library symbols for files matching REGEXP.");
198 #endif
199 add_info("sharedlibrary", solib_info,
200 "Status of loaded shared object libraries");
201 }
This page took 0.034068 seconds and 4 git commands to generate.