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