From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OFZoGM0Ijl9yRwAAWB0awg (envelope-from ) for ; Mon, 19 Oct 2020 17:44:45 -0400 Received: by simark.ca (Postfix, from userid 112) id 5F0B41EFC1; Mon, 19 Oct 2020 17:44:45 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 6E6AE1E58E for ; Mon, 19 Oct 2020 17:44:43 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12A79388701C; Mon, 19 Oct 2020 21:44:39 +0000 (GMT) Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.50.28]) by sourceware.org (Postfix) with ESMTPS id 6E0373865C2A for ; Mon, 19 Oct 2020 21:44:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E0373865C2A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 91C99400C47CA for ; Mon, 19 Oct 2020 16:42:52 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id UcxEkSRSWPiqfUcxEkYhQ6; Mon, 19 Oct 2020 16:44:32 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Wzs0qoY3mcUKhSljAMrZy6aqgHEUu00tRtAy+G2YkwY=; b=cm5HphyNQUeimEM2/UkUbKmOFk NvJYZu6SELD2WehEQbzbtX/c8+nKsJk+R2H9xEpm6MKnPXbEFaMfauwI7LRrWYnzZ123I6ehozYaq 8chBRPkboqeH7IStI5OlMnsce; Received: from 75-166-102-113.hlrn.qwest.net ([75.166.102.113]:45712 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kUcxE-004Oci-Lv; Mon, 19 Oct 2020 15:44:32 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH v2 02/16] Remove exec_filename macro Date: Mon, 19 Oct 2020 15:44:15 -0600 Message-Id: <20201019214429.13815-3-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20201019214429.13815-1-tom@tromey.com> References: <20201019214429.13815-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.102.113 X-Source-L: No X-Exim-ID: 1kUcxE-004Oci-Lv X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-102-113.hlrn.qwest.net (bapiya.Home) [75.166.102.113]:45712 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This removes the exec_filename macro, replacing it with uses of the member of current_program_space. This also renames that member, and changes it to be a unique pointer. gdb/ChangeLog 2020-10-19 Tom Tromey * progspace.h (struct program_space) : Rename from pspace_exec_filename. Now a unique_xmalloc_ptr. * inferior.c (print_selected_inferior): Update. (print_inferior): Update. * mi/mi-main.c (print_one_inferior): Update. * exec.h (exec_filename): Remove macro. * corefile.c (get_exec_file): Update. * exec.c (exec_close): Update. (exec_file_attach): Update. * progspace.c (clone_program_space): Update. (print_program_space): Update. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/corefile.c | 4 ++-- gdb/exec.c | 11 ++++++----- gdb/exec.h | 1 - gdb/inferior.c | 6 +++--- gdb/mi/mi-main.c | 4 ++-- gdb/progspace.c | 8 ++++---- gdb/progspace.h | 6 +++--- 8 files changed, 34 insertions(+), 20 deletions(-) diff --git a/gdb/corefile.c b/gdb/corefile.c index fed0e4fe8ad..c1eec199342 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -144,8 +144,8 @@ validate_files (void) const char * get_exec_file (int err) { - if (exec_filename) - return exec_filename; + if (current_program_space->exec_filename != nullptr) + return current_program_space->exec_filename.get (); if (!err) return NULL; diff --git a/gdb/exec.c b/gdb/exec.c index 0646a4df89b..98b7fbbe5a4 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -167,8 +167,7 @@ exec_close (void) remove_target_sections (&exec_bfd); - xfree (exec_filename); - exec_filename = NULL; + current_program_space->exec_filename.reset (nullptr); } } @@ -486,11 +485,13 @@ exec_file_attach (const char *filename, int from_tty) /* gdb_realpath_keepfile resolves symlinks on the local filesystem and so cannot be used for "target:" files. */ - gdb_assert (exec_filename == NULL); + gdb_assert (current_program_space->exec_filename == nullptr); if (load_via_target) - exec_filename = xstrdup (bfd_get_filename (exec_bfd)); + current_program_space->exec_filename + = make_unique_xstrdup (bfd_get_filename (exec_bfd)); else - exec_filename = gdb_realpath_keepfile (scratch_pathname).release (); + current_program_space->exec_filename + = gdb_realpath_keepfile (scratch_pathname); if (!bfd_check_format_matches (exec_bfd, bfd_object, &matching)) { diff --git a/gdb/exec.h b/gdb/exec.h index 24489654ddc..b2f51509bcf 100644 --- a/gdb/exec.h +++ b/gdb/exec.h @@ -32,7 +32,6 @@ struct objfile; #define exec_bfd current_program_space->ebfd #define exec_bfd_mtime current_program_space->ebfd_mtime -#define exec_filename current_program_space->pspace_exec_filename /* Builds a section table, given args BFD. */ diff --git a/gdb/inferior.c b/gdb/inferior.c index f775938721d..5c63dfa0bf1 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -415,7 +415,7 @@ void print_selected_inferior (struct ui_out *uiout) { struct inferior *inf = current_inferior (); - const char *filename = inf->pspace->pspace_exec_filename; + const char *filename = inf->pspace->exec_filename.get (); if (filename == NULL) filename = _(""); @@ -518,8 +518,8 @@ print_inferior (struct ui_out *uiout, const char *requested_inferiors) std::string conn = uiout_field_connection (inf->process_target ()); uiout->field_string ("connection-id", conn.c_str ()); - if (inf->pspace->pspace_exec_filename != NULL) - uiout->field_string ("exec", inf->pspace->pspace_exec_filename); + if (inf->pspace->exec_filename != nullptr) + uiout->field_string ("exec", inf->pspace->exec_filename.get ()); else uiout->field_skip ("exec"); diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index c5c7be7246a..41bafd2f70d 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -649,10 +649,10 @@ print_one_inferior (struct inferior *inferior, bool recurse, if (inferior->pid != 0) uiout->field_signed ("pid", inferior->pid); - if (inferior->pspace->pspace_exec_filename != NULL) + if (inferior->pspace->exec_filename != nullptr) { uiout->field_string ("executable", - inferior->pspace->pspace_exec_filename); + inferior->pspace->exec_filename.get ()); } if (inferior->pid != 0) diff --git a/gdb/progspace.c b/gdb/progspace.c index 67ea8bdb9e9..76001234255 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -233,8 +233,8 @@ clone_program_space (struct program_space *dest, struct program_space *src) set_current_program_space (dest); - if (src->pspace_exec_filename != NULL) - exec_file_attach (src->pspace_exec_filename, 0); + if (src->exec_filename != NULL) + exec_file_attach (src->exec_filename.get (), 0); if (src->symfile_object_file != NULL) symbol_file_add_main (objfile_name (src->symfile_object_file), @@ -315,8 +315,8 @@ print_program_space (struct ui_out *uiout, int requested) uiout->field_signed ("id", pspace->num); - if (pspace->pspace_exec_filename) - uiout->field_string ("exec", pspace->pspace_exec_filename); + if (pspace->exec_filename != nullptr) + uiout->field_string ("exec", pspace->exec_filename.get ()); else uiout->field_skip ("exec"); diff --git a/gdb/progspace.h b/gdb/progspace.h index 6a0e9036399..3acce50b32f 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -284,9 +284,9 @@ struct program_space /* The last-modified time, from when the exec was brought in. */ long ebfd_mtime = 0; /* Similar to bfd_get_filename (exec_bfd) but in original form given - by user, without symbolic links and pathname resolved. - It needs to be freed by xfree. It is not NULL iff EBFD is not NULL. */ - char *pspace_exec_filename = NULL; + by user, without symbolic links and pathname resolved. It is not + NULL iff EBFD is not NULL. */ + gdb::unique_xmalloc_ptr exec_filename; /* Binary file diddling handle for the core file. */ gdb_bfd_ref_ptr cbfd; -- 2.17.2