aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Ristovski <aristovski@qnx.com>2011-09-12 19:00:22 +0000
committerAleksandar Ristovski <aristovski@qnx.com>2011-09-12 19:00:22 +0000
commit59145f8cfba57000c8d920bea89652586a686837 (patch)
tree5dfd90ece58949339cc52d770a9c766b8d975d67
parent7b5b197e80f04c9b95fe7fafbd9907fc61a1e43d (diff)
downloadgdb-59145f8cfba57000c8d920bea89652586a686837.zip
gdb-59145f8cfba57000c8d920bea89652586a686837.tar.gz
gdb-59145f8cfba57000c8d920bea89652586a686837.tar.bz2
* solib.c (solib_used): New function.
(update_solib_list, reload_shared_libraries_1): Check if objfile is used by another so_list object before freeing it.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/solib.c20
2 files changed, 24 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 74aef61..2006913 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-01 Aleksandar Ristovski <aristovski@qnx.com>
+
+ * solib.c (used): New function.
+ (update_solib_list, reload_shared_libraries_1): Check if objfile is used
+ by another so_list object before freeing it.
+
2011-09-11 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
diff --git a/gdb/solib.c b/gdb/solib.c
index 6c0a899..402e9bc 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -633,6 +633,20 @@ solib_read_symbols (struct so_list *so, int flags)
return 0;
}
+/* Return 1 if KNOWN->objfile is used by any other so_list object in the
+ SO_LIST_HEAD list. Return 0 otherwise. */
+
+static int
+solib_used (const struct so_list *const known)
+{
+ const struct so_list *pivot;
+
+ for (pivot = so_list_head; pivot != NULL; pivot = pivot->next)
+ if (pivot != known && pivot->objfile == known->objfile)
+ return 1;
+ return 0;
+}
+
/* Synchronize GDB's shared object list with inferior's.
Extract the list of currently loaded shared objects from the
@@ -749,7 +763,8 @@ update_solib_list (int from_tty, struct target_ops *target)
*gdb_link = gdb->next;
/* Unless the user loaded it explicitly, free SO's objfile. */
- if (gdb->objfile && ! (gdb->objfile->flags & OBJF_USERLOADED))
+ if (gdb->objfile && ! (gdb->objfile->flags & OBJF_USERLOADED)
+ && !solib_used (gdb))
free_objfile (gdb->objfile);
/* Some targets' section tables might be referring to
@@ -1225,7 +1240,8 @@ reload_shared_libraries_1 (int from_tty)
|| (found_pathname != NULL
&& filename_cmp (found_pathname, so->so_name) != 0))
{
- if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED))
+ if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)
+ && !solib_used (so))
free_objfile (so->objfile);
remove_target_sections (so->abfd);
free_so_symbols (so);