From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30806 invoked by alias); 17 Oct 2013 18:03:48 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 30789 invoked by uid 306); 17 Oct 2013 18:03:48 -0000 Date: Thu, 17 Oct 2013 18:03:00 -0000 Message-ID: <20131017180348.30762.qmail@sourceware.org> From: tromey@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] tromey/split-objfile/msymbol-location-independence: make "file" use the BFD cache better X-Git-Refname: refs/heads/tromey/split-objfile/msymbol-location-independence X-Git-Reftype: branch X-Git-Oldrev: d25a723b8e23a4893cc5f59400442fa7eb783373 X-Git-Newrev: 2de926f10f4b2e1e79b773e5cb1a2c158f8d2a39 X-SW-Source: 2013-q4/txt/msg00005.txt.bz2 List-Id: 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 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.