public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/split-objfile/msymbol-location-independence: make "file" use the BFD cache better
@ 2013-10-17 18:03 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2013-10-17 18:03 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/split-objfile/msymbol-location-independence has been updated
       via  2de926f10f4b2e1e79b773e5cb1a2c158f8d2a39 (commit)
      from  d25a723b8e23a4893cc5f59400442fa7eb783373 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 2de926f10f4b2e1e79b773e5cb1a2c158f8d2a39
Author: Tom Tromey <tromey@redhat.com>
Date:   Thu Oct 17 12:03:06 2013 -0600

    make "file" use the BFD cache better
    
    Right now the "file" command will discard the exec_bfd and then
    possibly open a new one.
    
    If this ends up reopening the same file, it can cause needless work by
    gdb -- destroying all the per-BFD data just to re-read it again.
    
    This patch changes the code to hold a reference to the old exec_bfd
    while opening the new one.
    
    The possible downside of this is a higher peak memory use.
    
    	* exec.c (exec_file_attach): Hold a reference to exec_bfd.

-----------------------------------------------------------------------

Summary of changes:
 gdb/exec.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/gdb/exec.c b/gdb/exec.c
index 758cdc1..d186f5d 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -167,6 +167,14 @@ exec_file_clear (int from_tty)
 void
 exec_file_attach (char *filename, int from_tty)
 {
+  struct cleanup *cleanups;
+
+  /* First, acquire a reference to the current exec_bfd.  We release
+     this at the end of the function; but acquiring it now lets the
+     BFD cache return it if this call refers to the same file.  */
+  gdb_bfd_ref (exec_bfd);
+  cleanups = make_cleanup_bfd_unref (exec_bfd);
+
   /* Remove any previous exec file.  */
   exec_close ();
 
@@ -181,7 +189,6 @@ exec_file_attach (char *filename, int from_tty)
     }
   else
     {
-      struct cleanup *cleanups;
       char *scratch_pathname, *canonical_pathname;
       int scratch_chan;
       struct target_section *sections = NULL, *sections_end = NULL;
@@ -204,7 +211,7 @@ exec_file_attach (char *filename, int from_tty)
       if (scratch_chan < 0)
 	perror_with_name (filename);
 
-      cleanups = make_cleanup (xfree, scratch_pathname);
+      make_cleanup (xfree, scratch_pathname);
 
       /* gdb_bfd_open (and its variants) prefers canonicalized pathname for
 	 better BFD caching.  */
@@ -260,9 +267,10 @@ exec_file_attach (char *filename, int from_tty)
       /* Tell display code (if any) about the changed file name.  */
       if (deprecated_exec_file_display_hook)
 	(*deprecated_exec_file_display_hook) (filename);
-
-      do_cleanups (cleanups);
     }
+
+  do_cleanups (cleanups);
+
   bfd_cache_close_all ();
   observer_notify_executable_changed ();
 }


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-10-17 18:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-17 18:03 [SCM] tromey/split-objfile/msymbol-location-independence: make "file" use the BFD cache better tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).