From patchwork Mon Jun 6 21:33:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 12819 Received: (qmail 120145 invoked by alias); 6 Jun 2016 21:34:03 -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 119947 invoked by uid 89); 6 Jun 2016 21:34:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, FSL_HELO_HOME, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=sk:af4ddcc, Hx-languages-length:1246 X-HELO: gproxy8-pub.mail.unifiedlayer.com Received: from gproxy8-pub.mail.unifiedlayer.com (HELO gproxy8-pub.mail.unifiedlayer.com) (67.222.33.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 06 Jun 2016 21:33:45 +0000 Received: (qmail 14428 invoked by uid 0); 6 Jun 2016 21:33:44 -0000 Received: from unknown (HELO cmgw2) (10.0.90.83) by gproxy8.mail.unifiedlayer.com with SMTP; 6 Jun 2016 21:33:44 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id 3ZZd1t01d2f2jeq01ZZgPt; Mon, 06 Jun 2016 15:33:42 -0600 X-Authority-Analysis: v=2.1 cv=ff4+lSgF c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=-N9Dh3nx2ZYA:10 a=pD_ry4oyNxEA:10 a=zstS-IiYAAAA:8 a=qUXFsv20AAAA:8 a=7AOHJmT0xUs_N7fjRdMA:9 a=4G6NA9xxw8l3yy4pmD5M:22 a=9MODbo6-FXLeArg8YEg9:22 Received: from [65.128.48.199] (port=46482 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bA29T-0006Xd-E7; Mon, 06 Jun 2016 15:33:39 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/6] Change reopen_exec_file to check result of stat Date: Mon, 6 Jun 2016 15:33:27 -0600 Message-Id: <1465248812-23902-2-git-send-email-tom@tromey.com> In-Reply-To: <1465248812-23902-1-git-send-email-tom@tromey.com> References: <1465248812-23902-1-git-send-email-tom@tromey.com> X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 65.128.48.199 authed with tom+tromey.com} X-Exim-ID: 1bA29T-0006Xd-E7 X-Source-Sender: (bapiya.Home) [65.128.48.199]:46482 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This seems to be a real bug found by -Wunused-but-set-variable. If "stat" fails for some reason, gdb would use the uninitialized "st". 2016-06-06 Tom Tromey * corefile.c (reopen_exec_file): Only examine st.st_mtime if stat succeeded. --- gdb/ChangeLog | 5 +++++ gdb/corefile.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index af4ddcc..649bb0b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2016-06-06 Tom Tromey + + * corefile.c (reopen_exec_file): Only examine st.st_mtime if stat + succeeded. + 2016-06-02 Jon Turney * windows-nat.c (handle_output_debug_string): Return type of diff --git a/gdb/corefile.c b/gdb/corefile.c index 6cc2afc..64de931 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -144,7 +144,7 @@ reopen_exec_file (void) cleanups = make_cleanup (xfree, filename); res = stat (filename, &st); - if (exec_bfd_mtime && exec_bfd_mtime != st.st_mtime) + if (res == 0 && exec_bfd_mtime && exec_bfd_mtime != st.st_mtime) exec_file_attach (filename, 0); else /* If we accessed the file since last opening it, close it now;