1 /* Shared library support for RS/6000 (xcoff) object files, for GDB.
2 Copyright 1991, 1992 Free Software Foundation.
3 Contributed by IBM Corporation.
5 This file is part of GDB.
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.
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.
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. */
22 #include <sys/types.h>
28 #include "xcoffsolib.h"
31 #ifdef SOLIB_SYMBOLS_MANUAL
33 extern struct symtab
*current_source_symtab
;
34 extern int current_source_line
;
36 /* The real work of adding a shared library file to the symtab and
40 solib_add (arg_string
, from_tty
, target
)
43 struct target_ops
*target
;
46 struct vmap
*vp
= vmap
;
48 struct symtab
*saved_symtab
;
51 int loaded
= 0; /* true if any shared obj loaded */
52 int matched
= 0; /* true if any shared obj matched */
56 else if (val
= (char *) re_comp (arg_string
)) {
57 error ("Invalid regexp: %s", val
);
62 /* save current symbol table and line number, in case they get changed
63 in symbol loading process. */
65 saved_symtab
= current_source_symtab
;
66 saved_line
= current_source_line
;
68 /* skip over the first vmap, it is the main program, always loaded. */
71 for (; vp
; vp
= vp
->nxt
) {
73 if (re_exec (vp
->name
) || (*vp
->member
&& re_exec (vp
->member
))) {
77 /* if already loaded, continue with the next one. */
80 printf_unfiltered ("%s%s%s%s: already loaded.\n",
81 *vp
->member
? "(" : "",
83 *vp
->member
? ") " : "",
88 printf_unfiltered ("Loading %s%s%s%s...",
89 *vp
->member
? "(" : "",
91 *vp
->member
? ") " : "",
93 gdb_flush (gdb_stdout
);
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. */
98 obj
= lookup_objfile_bfd (vp
->bfd
);
100 warning ("\nObj structure for the shared object not found. Loading failed.");
104 syms_from_objfile (obj
, 0, 0, 0);
105 new_symfile_objfile (obj
, 0, 0);
106 vmap_symtab (vp
, 0, 0);
107 printf_unfiltered ("Done.\n");
108 loaded
= vp
->loaded
= 1;
111 /* if any shared object is loaded, then misc_func_vector needs sorting. */
114 sort_misc_function_vector ();
116 current_source_symtab
= saved_symtab
;
117 current_source_line
= saved_line
;
119 /* Getting new symbols might change our opinion about what is frameless.
120 Is this correct?? FIXME. */
121 /* reinit_frame_cache(); */
124 printf_unfiltered ("No matching shared object found.\n");
126 #endif /* SOLIB_SYMBOLS_MANUAL */
128 /* Return the module name of a given text address. Note that returned buffer
129 is not persistent. */
132 pc_load_segment_name (addr
)
135 static char buffer
[BUFSIZ
];
136 struct vmap
*vp
= vmap
;
138 buffer
[0] = buffer
[1] = '\0';
139 for (; vp
; vp
= vp
->nxt
)
140 if (vp
->tstart
<= addr
&& addr
< vp
->tend
) {
143 strcat (&buffer
[1], vp
->member
);
144 strcat (buffer
, ")");
146 strcat (buffer
, vp
->name
);
149 return "(unknown load module)";
152 static void solib_info
PARAMS ((char *, int));
155 solib_info (args
, from_tty
)
159 struct vmap
*vp
= vmap
;
161 /* Check for new shared libraries loaded with load (). */
162 xcoff_relocate_symtab (inferior_pid
);
164 if (vp
== NULL
|| vp
->nxt
== NULL
)
166 printf_unfiltered ("No shared libraries loaded at this time.\n");
170 /* Skip over the first vmap, it is the main program, always loaded. */
173 printf_unfiltered ("\
174 Text Range Data Range Syms Shared Object Library\n");
176 for (; vp
!= NULL
; vp
= vp
->nxt
)
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
? "(" : "",
184 *vp
->member
? ") " : "",
190 sharedlibrary_command (args
, from_tty
)
196 /* Check for new shared libraries loaded with load (). */
197 xcoff_relocate_symtab (inferior_pid
);
199 #ifdef SOLIB_SYMBOLS_MANUAL
200 solib_add (args
, from_tty
, (struct target_ops
*)0);
201 #endif /* SOLIB_SYMBOLS_MANUAL */
207 add_com ("sharedlibrary", class_files
, sharedlibrary_command
,
208 "Load shared object library symbols for files matching REGEXP.");
209 add_info ("sharedlibrary", solib_info
,
210 "Status of loaded shared object libraries");
This page took 0.034044 seconds and 4 git commands to generate.