From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2097 invoked by alias); 18 Oct 2012 18:49:59 -0000 Received: (qmail 1717 invoked by uid 22791); 18 Oct 2012 18:49:58 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_NO,TW_BJ X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Oct 2012 18:49:52 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2E8F52E00E; Thu, 18 Oct 2012 14:49:51 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4VBDghL42AdD; Thu, 18 Oct 2012 14:49:51 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id ED11C1C7BB8; Thu, 18 Oct 2012 14:49:50 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 762FDC6F87; Thu, 18 Oct 2012 11:49:41 -0700 (PDT) Date: Thu, 18 Oct 2012 18:49:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: RFA: probable rs6000-aix-tdep.c bug found by clang Message-ID: <20121018184941.GU3050@adacore.com> References: <87mwzk279g.fsf@fleche.redhat.com> <20121017212417.GP3050@adacore.com> <507FC786.50400@redhat.com> <20121018153304.GS3050@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="x4pBfXISqBoDm8sr" Content-Disposition: inline In-Reply-To: <20121018153304.GS3050@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 X-SW-Source: 2012-10/txt/msg00338.txt.bz2 --x4pBfXISqBoDm8sr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 932 > OK - I will take care of removing the condition and simplifying > the function. Here is what I propose we check in. I can't test it at the moment, because we've suffered a massive power outage and we're still working on getting every machine back up. I'm fairly confident, though. Rather than remove the check, I added an assertion. That's because eventually I want to add an extra check, for Lynx178. On the GDB side, the Lynx178 port is roughly a bareboard powerpc configuration. But it is using XCOFF, and I wanted to make sure that we'd never match a Lynx178 binary with the AIX ABI. To do that, I use a BFD/XCOFF function, so I thought adding the explict assertion would help. While at it, I added a function description, that explicitly mentions the pre-condition/assertion. If there are no objections, I will commit the attached patch within the next few days, after being able to test on AIX again. Thanks, -- Joel --x4pBfXISqBoDm8sr Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-ppc-aix-osabi-sniffer-Turn-test-of-bfd-flavour-into-.patch" Content-length: 1756 >From a2aff2ac36f9573ede236e899994054e6194ba65 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Thu, 18 Oct 2012 11:31:28 -0700 Subject: [PATCH] ppc-aix osabi sniffer: Turn test of bfd flavour into assertion Due to the way this function is registers, we know that given bfd's flavour should always be bfd_target_xcoff_flavour, thus making the former test always true, which means that this function should always return GDB_OSABI_AIX, and never return GDB_OSABI_UNKNOWN. This patch also fixes a typo detected by Tom Tromey that caused the test itself to be completely ineffective. gdb/ChangeLog (by Tom Tromey and Joel Brobecker): * rs6000-aix-tdep.c (rs6000_aix_osabi_sniffer): Replace inneffective if condition by gdb assertion. Add function description comment. --- gdb/rs6000-aix-tdep.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 59cfa73..06b43de 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -719,14 +719,19 @@ rs6000_software_single_step (struct frame_info *frame) return 1; } +/* Implement an osabi sniffer for RS6000/AIX. + + This function assumes that ABFD's flavour is XCOFF. In other words, + it should be registered as a sniffer for bfd_target_xcoff_flavour + objfiles only. A failed assertion will be raised if this condition + is not met. */ + static enum gdb_osabi rs6000_aix_osabi_sniffer (bfd *abfd) { - - if (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour); - return GDB_OSABI_AIX; + gdb_assert (bfd_get_flavour (abfd) == bfd_target_xcoff_flavour); - return GDB_OSABI_UNKNOWN; + return GDB_OSABI_AIX; } static void -- 1.7.9.5 --x4pBfXISqBoDm8sr--