This is the mail archive of the
gdb@sourceware.cygnus.com
mailing list for the GDB project.
Re: Preparing for the GDB 5.0 / GDB 2000 / GDB2k release
On Mon, Feb 07, 2000 at 06:15:57PM -0800, Daniel Berlin wrote:
> Furthermore, i don't see how it's necessary.
> Why did he add this consistency hook, to fix a problem that occurs when
> you restart.
> Why not implement the SOLIB_REMOVE_INFERIOR hook, and rather than the
> other implementations, which say they don't disable the breakpoints
> (mainly because of their own reasons), disable the breakpoints in those
> shared libs.
>
Thanks for your tip. Sam's patch is for gdb 4.17. I ported it to the
current one. SOLIB_REMOVE_INFERIOR is not available in 4.17. Here is
a patch which uses SOLIB_REMOVE_INFERIOR.
Thanks.
H.J.
----
Mon Feb 7 20:06:42 2000 H.J. Lu <hjl@gnu.org>
Based on a patch from Sam Lantinga (slouken@devolution.com):
* solib.c (solib_remove_inferior_hook): New function. Reload
list of shared objects when they are added or deleted and dump
symbols from unloaded shared objects.
* solib.h (SOLIB_REMOVE_INFERIOR_HOOK): New. Defined as
solib_remove_inferior_hook.
Index: solib.c
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/solib.c,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 solib.c
--- solib.c 1999/11/19 23:38:54 1.1.1.3
+++ solib.c 2000/02/08 03:52:15
@@ -950,6 +954,69 @@ open_symbol_file_object (arg)
return 1;
}
#endif /* SVR4_SHARED_LIBS */
+
+/*
+
+GLOBAL FUNCTION
+
+ solib_remove_inferior_hook -- check solib list consistency and
+ dump symbols from unloaded shared
+ objects
+
+SYNOPSIS
+
+ void solib_remove_inferior_hook (void)
+
+DESCRIPTION
+
+ This module is called whenever we hit a dynamic linker
+ breakpoint and allows us to check the consistency of our shared
+ object list and unload objects which are no longer valid in the
+ in the inferior. Without this, dynamic unlinking of objects
+ could crash us.
+
+AUTHOR
+ Sam Lantinga <hercules@lokigames.com>
+ */
+
+void
+solib_remove_inferior_hook (void)
+{
+#ifdef SVR4_SHARED_LIBS
+ struct objfile *current;
+
+ if (debug_base)
+ {
+ read_memory (debug_base, (char *) &debug_copy,
+ sizeof (struct r_debug));
+ /* If the shared object state is consistent, we can reload our
+ list */
+ if ( debug_copy.r_state == RT_CONSISTENT )
+ clear_solib();
+ }
+
+ for (current = symfile_objfile; current; current = current->next)
+ {
+ struct so_list *so;
+ char *bfd_filename;
+ for (so = so_list_head; so; so = so->next)
+ {
+ if (so->abfd)
+ {
+ bfd_filename = bfd_get_filename (so->abfd);
+ if (bfd_filename
+ && strcmp(bfd_filename, current->name) == 0)
+ break;
+ }
+ }
+ if ((current != symfile_objfile) && (so == NULL))
+ {
+ /*printf("Freeing objfile: %s\n", current->name);*/
+ free_objfile(current);
+ }
+ }
+#endif /* SVR4_SHARED_LIBS */
+}
/*
Index: solib.h
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/solib.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 solib.h
--- solib.h 1999/09/09 00:38:38 1.1.1.1
+++ solib.h 2000/02/08 04:06:07
@@ -48,10 +48,10 @@ solib_add PARAMS ((char *, int, struct t
dynamic linker that was established by SOLIB_CREATE_INFERIOR_HOOK.
(This operation does not remove shared library information from
the debugger, as CLEAR_SOLIB does.)
-
- This functionality is presently not implemented for this target.
*/
-#define SOLIB_REMOVE_INFERIOR_HOOK(PID) (0)
+extern void solib_remove_inferior_hook PARAMS ((void));
+
+#define SOLIB_REMOVE_INFERIOR_HOOK(PID) solib_remove_inferior_hook ();
extern void
solib_create_inferior_hook PARAMS ((void)); /* solib.c */