From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130804 invoked by alias); 26 Oct 2018 18:31:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 130428 invoked by uid 89); 26 Oct 2018 18:31:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Oct 2018 18:31:25 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w9QIV3rN019480 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Oct 2018 14:31:08 -0400 Received: by simark.ca (Postfix, from userid 112) id 78C001EA70; Fri, 26 Oct 2018 14:31:03 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 4EBC21E4C2; Fri, 26 Oct 2018 14:31:02 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 26 Oct 2018 18:31:00 -0000 From: Simon Marchi To: Tom Tromey Cc: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH] Check return value of bfd_init In-Reply-To: <875zxoiulq.fsf@tromey.com> References: <20181025150340.28844-1-tom@tromey.com> <87efcehwlx.fsf@tromey.com> <875zxoiulq.fsf@tromey.com> Message-ID: <4f3a2fce7baa5ee639c8ae514db50552@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00633.txt.bz2 On 2018-10-26 11:41, Tom Tromey wrote: >>>>>> "Tom" == Tom Tromey writes: > > Tom> Moving the call to bfd_init below the call to "new ui" makes it > work. > > Like so. > > Tom > > commit 2d0b2f3697a1f289e843f047697f252bf653d4db > Author: Tom Tromey > Date: Thu Oct 25 09:00:52 2018 -0600 > > Check return value of bfd_init > > Alan recently added a way for BFD library users to check whether > they > were in fact loading a compatible version of BFD: > > https://sourceware.org/ml/binutils/2018-10/msg00198.html > > It seemed reasonable to me that gdb should do this check as well, > in > case someone is dynamically linking against BFD. > > Simon pointed out that an earlier version of the patch would cause > a > gdb crash if the test failed. This version works around this by > lowering the call to bfd_init and adding a comment explaining where > 'error' can safely be called in captured_main_1. > > gdb/ChangeLog > 2018-10-25 Tom Tromey > > * main.c (captured_main_1): Check return value of bfd_init. > > diff --git a/gdb/ChangeLog b/gdb/ChangeLog > index 61dc039d4fe..a90c2978185 100644 > --- a/gdb/ChangeLog > +++ b/gdb/ChangeLog > @@ -1,3 +1,7 @@ > +2018-10-25 Tom Tromey > + > + * main.c (captured_main_1): Check return value of bfd_init. > + > 2018-10-25 Andrew Burgess > > * python/py-function.c (convert_values_to_python): Return > diff --git a/gdb/main.c b/gdb/main.c > index 8709357e924..bf6a58180a0 100644 > --- a/gdb/main.c > +++ b/gdb/main.c > @@ -506,7 +506,6 @@ captured_main_1 (struct captured_main_args > *context) > textdomain (PACKAGE); > #endif > > - bfd_init (); > notice_open_fds (); > > saved_command_line = (char *) xstrdup (""); > @@ -517,12 +516,17 @@ captured_main_1 (struct captured_main_args > *context) > setvbuf (stderr, NULL, _IONBF, BUFSIZ); > #endif > > + /* Note: `error' cannot be called before this point, because the > + caller will crash when trying to print the exception. */ > main_ui = new ui (stdin, stdout, stderr); > current_ui = main_ui; > > gdb_stdtargerr = gdb_stderr; /* for moment */ > gdb_stdtargin = gdb_stdin; /* for moment */ > > + if (bfd_init () == BFD_INIT_MAGIC) > + error (_("fatal error: libbfd ABI mismatch")); The comparison operator is the wrong one (== instead of !=), you probably left it like this after testing. LGTM with that fixed. Simon