1 /* Shared library support for RS/6000 (xcoff) object files, for GDB.
2 Copyright 1991, 1992, 1995, 1996, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Contributed by IBM Corporation.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "xcoffsolib.h"
30 #include "gdb_regex.h"
33 /* If ADDR lies in a shared library, return its name.
34 Note that returned name points to static data whose content is overwritten
38 xcoff_solib_address (CORE_ADDR addr
)
40 static char *buffer
= NULL
;
41 struct vmap
*vp
= vmap
;
43 /* The first vmap entry is for the exec file. */
47 for (vp
= vp
->nxt
; vp
; vp
= vp
->nxt
)
48 if (vp
->tstart
<= addr
&& addr
< vp
->tend
)
51 xasprintf (&buffer
, "%s%s%s%s",
53 *vp
->member
? "(" : "",
55 *vp
->member
? ")" : "");
61 static void solib_info (char *, int);
62 static void sharedlibrary_command (char *pattern
, int from_tty
);
65 solib_info (char *args
, int from_tty
)
67 struct vmap
*vp
= vmap
;
69 /* Check for new shared libraries loaded with load (). */
70 if (! ptid_equal (inferior_ptid
, null_ptid
))
71 xcoff_relocate_symtab (PIDGET (inferior_ptid
));
73 if (vp
== NULL
|| vp
->nxt
== NULL
)
75 printf_unfiltered ("No shared libraries loaded at this time.\n");
79 /* Skip over the first vmap, it is the main program, always loaded. */
83 Text Range Data Range Syms Shared Object Library\n");
85 for (; vp
!= NULL
; vp
= vp
->nxt
)
87 printf_unfiltered ("0x%s-0x%s 0x%s-0x%s %s %s%s%s%s\n",
88 paddr (vp
->tstart
),paddr (vp
->tend
),
89 paddr (vp
->dstart
), paddr (vp
->dend
),
90 vp
->loaded
? "Yes" : "No ",
92 *vp
->member
? "(" : "",
94 *vp
->member
? ")" : "");
99 sharedlibrary_command (char *pattern
, int from_tty
)
103 /* Check for new shared libraries loaded with load (). */
104 if (! ptid_equal (inferior_ptid
, null_ptid
))
105 xcoff_relocate_symtab (PIDGET (inferior_ptid
));
109 char *re_err
= re_comp (pattern
);
112 error ("Invalid regexp: %s", re_err
);
115 /* Walk the list of currently loaded shared libraries, and read
116 symbols for any that match the pattern --- or any whose symbols
117 aren't already loaded, if no pattern was given. */
120 int loaded_any_symbols
= 0;
121 struct vmap
*vp
= vmap
;
126 /* skip over the first vmap, it is the main program, always loaded. */
127 for (vp
= vp
->nxt
; vp
; vp
= vp
->nxt
)
129 || re_exec (vp
->name
)
130 || (*vp
->member
&& re_exec (vp
->member
)))
137 printf_unfiltered ("Symbols already loaded for %s\n",
142 if (vmap_add_symbols (vp
))
143 loaded_any_symbols
= 1;
147 if (from_tty
&& pattern
&& ! any_matches
)
149 ("No loaded shared libraries match the pattern `%s'.\n", pattern
);
151 if (loaded_any_symbols
)
153 /* Getting new symbols may change our opinion about what is
155 reinit_frame_cache ();
162 no_shared_libraries -- handle command to explicitly discard symbols
163 from shared libraries.
167 Implements the command "nosharedlibrary", which discards symbols
168 that have been auto-loaded from shared libraries. Symbols from
169 shared libraries that were added by explicit request of the user
170 are not discarded. Also called from remote.c. */
173 no_shared_libraries (char *ignored
, int from_tty
)
179 _initialize_xcoffsolib (void)
181 add_com ("sharedlibrary", class_files
, sharedlibrary_command
,
182 "Load shared object library symbols for files matching REGEXP.");
183 add_info ("sharedlibrary", solib_info
,
184 "Status of loaded shared object libraries");
187 (add_set_cmd ("auto-solib-add", class_support
, var_boolean
,
188 (char *) &auto_solib_add
,
189 "Set autoloading of shared library symbols.\n\
190 If \"on\", symbols from all shared object libraries will be loaded\n\
191 automatically when the inferior begins execution, when the dynamic linker\n\
192 informs gdb that a new library has been loaded, or when attaching to the\n\
193 inferior. Otherwise, symbols must be loaded manually, using `sharedlibrary'.",
This page took 0.032497 seconds and 4 git commands to generate.