* valprint.c (print_longest): Fix a syntax error in #ifdef
[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
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
1eeba686
PB
21#include <sys/types.h>
22#include <sys/ldr.h>
23
24#include "defs.h"
25#include "bfd.h"
1eeba686
PB
26#include "xcoffsolib.h"
27
2aefe6e4
JK
28#ifdef SOLIB_SYMBOLS_MANUAL
29
1eeba686
PB
30extern struct symtab *current_source_symtab;
31extern int current_source_line;
32
1eeba686
PB
33/* The real work of adding a shared library file to the symtab and
34 the section list. */
35
36void
37solib_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
199b2450 77 printf_unfiltered ("%s%s%s%s: already loaded.\n",
1eeba686
PB
78 *vp->member ? "(" : "",
79 vp->member,
80 *vp->member ? ") " : "",
81 vp->name);
82 continue;
83 }
84
199b2450 85 printf_unfiltered ("Loading %s%s%s%s...",
1eeba686
PB
86 *vp->member ? "(" : "",
87 vp->member,
88 *vp->member ? ") " : "",
89 vp->name);
199b2450 90 gdb_flush (gdb_stdout);
1eeba686 91
2aefe6e4
JK
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. */
1eeba686
PB
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
2d6d969c
FF
101 syms_from_objfile (obj, 0, 0, 0);
102 new_symfile_objfile (obj, 0, 0);
1eeba686 103 vmap_symtab (vp, 0, 0);
199b2450 104 printf_unfiltered ("Done.\n");
1eeba686
PB
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)
199b2450 121 printf_unfiltered ("No matching shared object found.\n");
1eeba686 122}
2aefe6e4 123#endif /* SOLIB_SYMBOLS_MANUAL */
1eeba686
PB
124
125/* Return the module name of a given text address. Note that returned buffer
126 is not persistent. */
127
128char *
129pc_load_segment_name (addr)
130CORE_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
150solib_info (ldi)
151register struct ld_info *ldi;
152{
153
154 struct vmap *vp = vmap;
155
156 if (!vp || !vp->nxt) {
199b2450 157 printf_unfiltered("No shared libraries loaded at this time.\n");
1eeba686
PB
158 return;
159 }
160
161 /* skip over the first vmap, it is the main program, always loaded. */
162 vp = vp->nxt;
163
199b2450 164 printf_unfiltered ("\
1eeba686
PB
165Text Range Data Range Syms Shared Object Library\n");
166
167 for (; vp; vp = vp->nxt) {
168
199b2450 169 printf_unfiltered ("0x%08x-0x%08x 0x%08x-0x%08x %s %s%s%s%s\n",
1eeba686
PB
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
2aefe6e4 180#ifdef SOLIB_SYMBOLS_MANUAL
1eeba686
PB
181void
182sharedlibrary_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}
2aefe6e4 189#endif /* SOLIB_SYMBOLS_MANUAL */
1eeba686
PB
190
191void
192_initialize_solib()
193{
194
2aefe6e4 195#ifdef SOLIB_SYMBOLS_MANUAL
1eeba686
PB
196 add_com("sharedlibrary", class_files, sharedlibrary_command,
197 "Load shared object library symbols for files matching REGEXP.");
2aefe6e4 198#endif
1eeba686
PB
199 add_info("sharedlibrary", solib_info,
200 "Status of loaded shared object libraries");
201}
This page took 0.210426 seconds and 4 git commands to generate.