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., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #include "xcoffsolib.h"
29 #include "gdb_regex.h"
32 /* Return the module name of a given text address. Note that returned buffer
36 pc_load_segment_name (CORE_ADDR addr)
38 static char buffer[BUFSIZ];
39 struct vmap *vp = vmap;
41 buffer[0] = buffer[1] = '\0';
42 for (; vp; vp = vp->nxt)
43 if (vp->tstart <= addr && addr < vp->tend)
48 strcat (&buffer[1], vp->member);
51 strcat (buffer, vp->name);
54 return "(unknown load module)";
57 static void solib_info (char *, int);
58 static void sharedlibrary_command (char *pattern, int from_tty);
61 solib_info (char *args, int from_tty)
63 struct vmap *vp = vmap;
65 /* Check for new shared libraries loaded with load (). */
67 xcoff_relocate_symtab (inferior_pid);
69 if (vp == NULL || vp->nxt == NULL)
71 printf_unfiltered ("No shared libraries loaded at this time.\n");
75 /* Skip over the first vmap, it is the main program, always loaded. */
79 Text Range Data Range Syms Shared Object Library\n");
81 for (; vp != NULL; vp = vp->nxt)
83 printf_unfiltered ("0x%s-0x%s 0x%s-0x%s %s %s%s%s%s\n",
84 paddr (vp->tstart),paddr (vp->tend),
85 paddr (vp->dstart), paddr (vp->dend),
86 vp->loaded ? "Yes" : "No ",
87 *vp->member ? "(" : "",
89 *vp->member ? ") " : "",
95 sharedlibrary_command (char *pattern, int from_tty)
99 /* Check for new shared libraries loaded with load (). */
101 xcoff_relocate_symtab (inferior_pid);
105 char *re_err = re_comp (pattern);
108 error ("Invalid regexp: %s", re_err);
111 /* Walk the list of currently loaded shared libraries, and read
112 symbols for any that match the pattern --- or any whose symbols
113 aren't already loaded, if no pattern was given. */
116 int loaded_any_symbols = 0;
117 struct vmap *vp = vmap;
122 /* skip over the first vmap, it is the main program, always loaded. */
123 for (vp = vp->nxt; vp; vp = vp->nxt)
125 || re_exec (vp->name)
126 || (*vp->member && re_exec (vp->member)))
133 printf_unfiltered ("Symbols already loaded for %s\n",
138 if (vmap_add_symbols (vp))
139 loaded_any_symbols = 1;
143 if (from_tty && pattern && ! any_matches)
145 ("No loaded shared libraries match the pattern `%s'.\n", pattern);
147 if (loaded_any_symbols)
149 /* Getting new symbols may change our opinion about what is
151 reinit_frame_cache ();
157 _initialize_solib (void)
159 add_com ("sharedlibrary", class_files, sharedlibrary_command,
160 "Load shared object library symbols for files matching REGEXP.");
161 add_info ("sharedlibrary", solib_info,
162 "Status of loaded shared object libraries");
165 (add_set_cmd ("auto-solib-add", class_support, var_zinteger,
166 (char *) &auto_solib_add,
167 "Set autoloading of shared library symbols.\n\
168 If nonzero, symbols from all shared object libraries will be loaded\n\
169 automatically when the inferior begins execution or when the dynamic linker\n\
170 informs gdb that a new library has been loaded. Otherwise, symbols\n\
171 must be loaded manually, using `sharedlibrary'.",