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 Tue, Feb 08, 2000 at 09:42:24AM +0100, Mark Kettenis wrote:
> Date: Mon, 7 Feb 2000 20:14:40 -0800
> From: "H . J . Lu" <hjl@lucon.org>
>
> 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.
>
> And this patch solves the big problems you were having with debugging
> apps with shared libraries, and the testcase you have (but still have
> not showed to us) is working now? I really doubt that.
>
> For one, this can never solve the dlopen(A), dlclose(A), dlopen(B)
> case since SOLIB_REMOVE_INFERIOR_HOOK is only called from within
> infrun.c:follow_inferior_fork(), which isn't necessarily called in
> this scenario.
>
> Moreover, the comment on solib.c:solib_remove_inferior_hook() is
> grossly misappropriate now. The function isn't called "whenever we
> hit a dynamic linker breakpoint". And this function calls
> clear_solib() although the comment on SOLIB_REMOVE_INFERIOR_HOOK
> clearly states that this hook isn't meant to remove all shared library
> information from the debugger.
May I suggest this
1. We have to fix it in 5.0, even with a hack.
2. We combine 2 patches into one since they are always called one after
another. My patch already does that. Just give a different name.
How about this patch?
H.J.
----
Tue Feb 8 09:17:56 2000 H.J. Lu <hjl@gnu.org>
Based on patches from Sam Lantinga (slouken@devolution.com):
* solib.c (verify_solib): New function. Reload list of shared objects
when they are added or deleted and dump symbols from unloaded shared
objects.
(solib_add): Call it.
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 17:16:33
@@ -194,6 +198,8 @@ static int solib_map_sections PARAMS ((P
#ifdef SVR4_SHARED_LIBS
+static void verify_solib PARAMS ((void));
+
static CORE_ADDR
elf_locate_base PARAMS ((void));
@@ -951,6 +957,68 @@ open_symbol_file_object (arg)
}
#endif /* SVR4_SHARED_LIBS */
+#ifdef SVR4_SHARED_LIBS
+/*
+
+LOCAL FUNCTION
+
+ verify_solib -- check solib list consistency and dump symbols
+ from unloaded shared objects
+
+SYNOPSIS
+
+ void verify_solib (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>
+ */
+
+static void
+verify_solib (void)
+{
+ 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 */
+
/*
LOCAL FUNCTION
@@ -1165,6 +1233,8 @@ solib_add (arg_string, from_tty, target)
int old;
#ifdef SVR4_SHARED_LIBS
+ verify_solib ();
+
/* If we are attaching to a running process for which we
have not opened a symbol file, we may be able to get its
symbols now! */