From patchwork Mon Apr 13 17:30:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 6187 Received: (qmail 117249 invoked by alias); 13 Apr 2015 17:33:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 117146 invoked by uid 89); 13 Apr 2015 17:33:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-wi0-f174.google.com Received: from mail-wi0-f174.google.com (HELO mail-wi0-f174.google.com) (209.85.212.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 13 Apr 2015 17:33:14 +0000 Received: by widdi4 with SMTP id di4so82281876wid.0 for ; Mon, 13 Apr 2015 10:33:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=VzAJMDopCrry+m26oRma6ekYO+haxiY+p5xhMfoou9M=; b=Y3JuUMOAJUhjYM9ks42YCaPJc9M8b6nbucwjzfpZOBlck0m3UMkNCT6WU2bkoYBzyg saJULyH4k2dZkeSijIBO4hTq5CDCY1xN2SlnHf4629GMhg8mj6kYdtIiAKJtjOEX/npZ uCbDUB1Yguzm6Uu5XZhVewqzRgWJs7rXCzRgFv13P6VHurzBCCvTVFmdjXeFVYRqSYkp 2vZhSHVlZcRUojYURtz5znpEwQBQ9acEFWDOHLEyeGhDxcUEI4fAQi4ZBiMresCEERlW Klx8Aj1VIrRY7dpx/ujdTzTZNhc//q+0g/RSKI3tiYCi7TkDtdn1q03OknftbBX0Aapg MuuA== X-Gm-Message-State: ALoCoQmyvsVfRNIZtwgY0mfPN2hG5YwDIM145UnhuAbbhKYLQtWck7A6y9cwfmy8m8fjuQ7c5ONI X-Received: by 10.180.99.166 with SMTP id er6mr6779779wib.58.1428946391196; Mon, 13 Apr 2015 10:33:11 -0700 (PDT) Received: from localhost (host86-133-100-115.range86-133.btcentralplus.com. [86.133.100.115]) by mx.google.com with ESMTPSA id uo6sm12380896wjc.49.2015.04.13.10.33.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 10:33:10 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/3] gdb: New maintenance command to disable bfd sharing. Date: Mon, 13 Apr 2015 18:30:08 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes In some rare maintainer cases it is desirable to be able to disable bfd sharing. This patch adds new commands maintenance set/show commands for bfd-sharing, allowing gdb's bfd cache to be turned off. OK to apply? Thanks, Andrew gdb/ChangeLog: * gdb_bfd.c (bfd_sharing): New variable. (gdb_bfd_open): Check bfd_sharing variable. (_initialize_gdb_bfd): Add new set/show command. * NEWS: Mention new command. --- gdb/ChangeLog | 7 +++++++ gdb/NEWS | 4 ++++ gdb/gdb_bfd.c | 29 +++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d79d8e3..291c1be 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2015-04-13 Andrew Burgess + * gdb_bfd.c (bfd_sharing): New variable. + (gdb_bfd_open): Check bfd_sharing variable. + (_initialize_gdb_bfd): Add new set/show command. + * NEWS: Mention new command. + +2015-04-13 Andrew Burgess + * gdb_bfd.c (struct gdb_bfd_data): Add size field. (struct gdb_bfd_cache_search): Likewise. (eq_bfd): Compare the size fields. diff --git a/gdb/NEWS b/gdb/NEWS index c24195e..673aca4 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -62,6 +62,10 @@ show max-completions to avoid generating large completion lists, the computation of which can cause the debugger to become temporarily unresponsive. +maint set bfd-sharing +maint show bfd-sharing + Control the reuse of bfd objects. + maint set symbol-cache-size maint show symbol-cache-size Control the size of the symbol cache. diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 35c068f..48838cc 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -104,6 +104,11 @@ DEFINE_REGISTRY (bfd, GDB_BFD_DATA_ACCESSOR) static htab_t gdb_bfd_cache; +/* When true gdb will reuse an existing bfd object if the filename, + modification time, and file size all match. */ + +static int bfd_sharing; + /* The type of an object being looked up in gdb_bfd_cache. We use htab's capability of storing one kind of object (BFD in this case) and using a different sort of object for searching. */ @@ -389,7 +394,7 @@ gdb_bfd_open (const char *name, const char *target, int fd) opening the BFD may fail; and this would violate hashtab invariants. */ abfd = htab_find_with_hash (gdb_bfd_cache, &search, hash); - if (abfd != NULL) + if (bfd_sharing && abfd != NULL) { close (fd); gdb_bfd_ref (abfd); @@ -400,9 +405,12 @@ gdb_bfd_open (const char *name, const char *target, int fd) if (abfd == NULL) return NULL; - slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, INSERT); - gdb_assert (!*slot); - *slot = abfd; + if (bfd_sharing) + { + slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, INSERT); + gdb_assert (!*slot); + *slot = abfd; + } gdb_bfd_ref (abfd); return abfd; @@ -923,4 +931,17 @@ _initialize_gdb_bfd (void) add_cmd ("bfds", class_maintenance, maintenance_info_bfds, _("\ List the BFDs that are currently open."), &maintenanceinfolist); + + add_setshow_boolean_cmd ("bfd-sharing", no_class, + &bfd_sharing, _("\ +Set whether gdb will share bfds that appear to be the same file."), _("\ +Show whether gdb will share bfds that appear to be the same file."), _("\ +Tells gdb whether to share bfds that appear to be the same file. The\n\ +modification time and file size are used to determine if a file on\n\ +disc has changed."), + NULL, + NULL, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); + bfd_sharing = 1; }