This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[hercules@lokigames.com: solib patch for gdb 4.17.0.14]


----- Forwarded message from Sam Lantinga <hercules@lokigames.com> -----

Delivered-To: hjl@lucon.org
Date: Mon, 31 Jan 2000 17:00:17 -0800
From: Sam Lantinga <hercules@lokigames.com>
Organization: Loki Entertainment Software
X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.2.13 i686)
X-Accept-Language: en
To: hjl@lucon.org
Cc: coders@lokigames.com, Sam Lantinga <hercules@lokigames.com>
Subject: solib patch for gdb 4.17.0.14


This patch fixes the shared library problem I mailed you about earlier.
This affects any code which dynamically unloads shared objects.  Games
are notorious for this. :)

See ya!
-- 
	-Sam Lantinga, Lead Programmer, Loki Entertainment Software
diff -ruN gdb-4.17/gdb/infrun.c gdb-4.17.new/gdb/infrun.c
--- gdb-4.17/gdb/infrun.c	Mon Jan 31 16:47:48 2000
+++ gdb-4.17.new/gdb/infrun.c	Mon Jan 31 16:39:20 2000
@@ -1192,6 +1192,9 @@
                   CHECK_SOLIB_CONSISTENCY();
 #endif
 		  SOLIB_ADD (NULL, 0, NULL);
+#ifdef UNLOAD_UNUSED_SOLIB
+                  UNLOAD_UNUSED_SOLIB();
+#endif
 	          target_terminal_inferior ();
 		}
 
diff -ruN gdb-4.17/gdb/solib.c gdb-4.17.new/gdb/solib.c
--- gdb-4.17/gdb/solib.c	Mon Jan 31 16:47:48 2000
+++ gdb-4.17.new/gdb/solib.c	Mon Jan 31 16:46:31 2000
@@ -918,6 +918,58 @@
 
 /*
 
+GLOBAL FUNCTION
+
+	unload_unused_solib -- dump symbols from unloaded shared objects
+
+SYNOPSIS
+
+	void unload_unused_solib (void)
+
+DESCRIPTION
+
+	This module is called whenever we hit a dynamic linker breakpoint
+	and allows us to unload objects which are no longer valid in the
+	in the inferior.
+
+AUTHOR
+	Sam Lantinga <hercules@lokigames.com>
+ */
+
+void
+unload_unused_solib (void)
+{
+
+#ifdef SVR4_SHARED_LIBS
+
+    struct objfile *current;
+
+    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 ) {
+                    if ( strcmp(bfd_filename, current->name) == 0 ) {
+                        break;
+                    }
+                }
+            }
+        }
+        if ( (current != symfile_objfile) && (so == NULL) ) {
+/*printf("Freeing objfile: %s\n", current->name);*/
+            free_objfile(current);
+            break;
+        }
+    }
+
+#endif	/* SVR4_SHARED_LIBS */
+
+}
+
+/*
+
 LOCAL FUNCTION
 
 	find_solib -- step through list of shared objects
diff -ruN gdb-4.17/gdb/solib.h gdb-4.17.new/gdb/solib.h
--- gdb-4.17/gdb/solib.h	Mon Jan 31 16:47:48 2000
+++ gdb-4.17.new/gdb/solib.h	Mon Jan 31 16:40:14 2000
@@ -59,6 +59,10 @@
 
 #define CHECK_SOLIB_CONSISTENCY()	check_solib_consistency()
 
+/* Brute force check of library consistency */
+
+#define UNLOAD_UNUSED_SOLIB()		unload_unused_solib()
+
 /* If ADDR lies in a shared library, return its name.  */
 
 #define PC_SOLIB(addr)	solib_address (addr)


----- End forwarded message -----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]