From patchwork Fri Jul 18 16:25:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 2112 Received: (qmail 15837 invoked by alias); 18 Jul 2014 17:19:12 -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 15824 invoked by uid 89); 18 Jul 2014 17:19:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=unavailable version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 18 Jul 2014 17:19:10 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6IGP6An001268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Jul 2014 12:25:06 -0400 Received: from barimba.redhat.com (ovpn-113-27.phx2.redhat.com [10.3.113.27]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6IGP5me021576; Fri, 18 Jul 2014 12:25:05 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] remove using_exec_ops global Date: Fri, 18 Jul 2014 10:25:03 -0600 Message-Id: <1405700703-29043-1-git-send-email-tromey@redhat.com> This removes the using_exec_ops global from exec.c, in favor of querying the target stack directly using target_is_pushed. This is more in keeping with other code in gdb, and is also more future-proof as it is more multi-target-ready. Built and regtested on x86-64 Fedora 20. 2014-07-18 Tom Tromey * exec.c (using_exec_ops): Remove. (exec_close_1): Update. Remove extraneous block, reindent. (add_target_sections): Use target_is_pushed. --- gdb/ChangeLog | 6 ++++++ gdb/exec.c | 32 +++++++++++--------------------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index 7ba2720..8b6f588 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -63,9 +63,6 @@ void _initialize_exec (void); static struct target_ops exec_ops; -/* True if the exec target is pushed on the stack. */ -static int using_exec_ops; - /* Whether to open exec and core files read-only or read-write. */ int write_files = 0; @@ -115,22 +112,18 @@ exec_close (void) static void exec_close_1 (struct target_ops *self) { - using_exec_ops = 0; + struct program_space *ss; + struct cleanup *old_chain; + old_chain = save_current_program_space (); + ALL_PSPACES (ss) { - struct program_space *ss; - struct cleanup *old_chain; - - old_chain = save_current_program_space (); - ALL_PSPACES (ss) - { - set_current_program_space (ss); - clear_section_table (current_target_sections); - exec_close (); - } - - do_cleanups (old_chain); + set_current_program_space (ss); + clear_section_table (current_target_sections); + exec_close (); } + + do_cleanups (old_chain); } void @@ -445,11 +438,8 @@ add_target_sections (void *owner, /* If these are the first file sections we can provide memory from, push the file_stratum target. */ - if (!using_exec_ops) - { - using_exec_ops = 1; - push_target (&exec_ops); - } + if (!target_is_pushed (&exec_ops)) + push_target (&exec_ops); } }