A patch for shared library support
H.J. Lu
hjl@valinux.com
Wed Oct 27 13:43:00 GMT 1999
Hi,
I finally get annoyed enough to port Sam's patch to gdb 4.18 in CVS.
When you set a break point in shared library, gdb will crash when you
restart the program. This patch seems to work for me.
--
H.J. Lu (hjl@gnu.org)
--
Wed Mar 17 19:49:22 1999 Sam Lantinga (slouken@devolution.com)
Added function check_solib_consistency() to reload list of
shared objects when they are added or deleted. This fixed
crashing when the program being debugged unloaded a dynamic
library and added a new library afterwards.
* solib.h (CHECK_SOLIB_CONSISTENCY): New.
(check_solib_consistency): New prototype.
* solib.c (check_solib_consistency): Defined.
* infrun.c (handle_inferior_event): Before calling SOLIB_ADD (),
call CHECK_SOLIB_CONSISTENCY () if defined.
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 1999/10/27 20:35:54
@@ -186,6 +186,11 @@ solib_create_inferior_hook PARAMS ((void
extern char *
solib_address PARAMS ((CORE_ADDR)); /* solib.c */
+/* Check shared library consistency */
+
+#define CHECK_SOLIB_CONSISTENCY() check_solib_consistency()
+extern void check_solib_consistency PARAMS ((void));
+
/* If ADDR lies in a shared library, return its name. */
#define PC_SOLIB(addr) solib_address (addr)
Index: solib.c
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/solib.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 solib.c
--- solib.c 1999/10/19 16:16:27 1.1.1.2
+++ solib.c 1999/10/27 20:29:03
@@ -950,6 +954,38 @@ open_symbol_file_object (arg)
return 1;
}
#endif /* SVR4_SHARED_LIBS */
+
+/*
+
+GLOBAL FUNCTION
+
+ check_solib_consistency -- check solib list consistency
+
+SYNOPSIS
+
+ void check_solib_consistency (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.
+ Without this, dynamic unlinking of objects could crash us.
+ */
+
+void
+check_solib_consistency (void)
+{
+#ifdef SVR4_SHARED_LIBS
+
+ 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();
+ }
+
+#endif /* SVR4_SHARED_LIBS */
+}
/*
Index: infrun.c
===================================================================
RCS file: /work/cvs/gnu/gdb/gdb/infrun.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 infrun.c
--- infrun.c 1999/10/19 16:16:22 1.1.1.2
+++ infrun.c 1999/10/27 20:30:20
@@ -1479,6 +1479,9 @@ handle_inferior_event (struct execution_
/* Switch terminal for any messages produced by
breakpoint_re_set. */
target_terminal_ours_for_output ();
+#ifdef CHECK_SOLIB_CONSISTENCY
+ CHECK_SOLIB_CONSISTENCY();
+#endif
SOLIB_ADD (NULL, 0, NULL);
target_terminal_inferior ();
}
@@ -2409,6 +2412,9 @@ handle_inferior_event (struct execution_
/* Switch terminal for any messages produced by
breakpoint_re_set. */
target_terminal_ours_for_output ();
+#ifdef CHECK_SOLIB_CONSISTENCY
+ CHECK_SOLIB_CONSISTENCY();
+#endif
SOLIB_ADD (NULL, 0, NULL);
target_terminal_inferior ();
}
More information about the Gdb
mailing list