From patchwork Fri Apr 15 21:48:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edjunior Barbosa Machado X-Patchwork-Id: 11770 Received: (qmail 8136 invoked by alias); 15 Apr 2016 21:48:44 -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 8083 invoked by uid 89); 15 Apr 2016 21:48:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1493, sk:PPC_FEA, sk:ppc_fea, assure X-HELO: e24smtp02.br.ibm.com Received: from e24smtp02.br.ibm.com (HELO e24smtp02.br.ibm.com) (32.104.18.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 15 Apr 2016 21:48:41 +0000 Received: from localhost by e24smtp02.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Apr 2016 18:48:37 -0300 Received: from d24dlp01.br.ibm.com (9.18.248.204) by e24smtp02.br.ibm.com (10.172.0.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 Apr 2016 18:48:30 -0300 X-IBM-Helo: d24dlp01.br.ibm.com X-IBM-MailFrom: emachado@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.13.184.25]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 560D93520070 for ; Fri, 15 Apr 2016 17:48:18 -0400 (EDT) Received: from d24av04.br.ibm.com (d24av04.br.ibm.com [9.8.31.97]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3FKloR816712120 for ; Fri, 15 Apr 2016 17:47:51 -0300 Received: from d24av04.br.ibm.com (localhost [127.0.0.1]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3FLmTxN014044 for ; Fri, 15 Apr 2016 18:48:29 -0300 Received: from dawn.ibm.com ([9.18.198.227]) by d24av04.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3FLmTaA014031; Fri, 15 Apr 2016 18:48:29 -0300 From: Edjunior Barbosa Machado To: gdb-patches@sourceware.org Cc: "Carl E . Love" , Ulrich Weigand Subject: [PATCH] Fix checks for VSX and Altivec availability on Power Date: Fri, 15 Apr 2016 18:48:01 -0300 Message-Id: <1460756881-25422-1-git-send-email-emachado@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16041521-0021-0000-0000-0000112316BB X-IsSubscribed: yes Hi, in order to identify if it is running in a machine with VSX available, current GDB is relying only on the ptrace call using PTRACE_GETVSXREGS, which is successful in some kernels even if the processor version does not have such feature (as Power6 and previous), leading to show registers that actually do not exist. This simple patch fixes this issue adding checks using PPC_FEATURE_HAS_VSX and PPC_FEATURE_HAS_ALTIVEC from ppc hwcap to assure these features are available. OK? Thanks and regards, --- Edjunior gdb/ChangeLog 2016-04-15 Edjunior Barbosa Machado * ppc-linux-nat.c (ppc_linux_read_description): Use PPC_FEATURE_HAS_VSX and PPC_FEATURE_HAS_ALTIVEC to check if such features are available. diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index bf91462..84c14a1 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -2419,7 +2419,8 @@ ppc_linux_read_description (struct target_ops *ops) perror_with_name (_("Unable to fetch SPE registers")); } - if (have_ptrace_getsetvsxregs) + if (have_ptrace_getsetvsxregs + && (ppc_linux_get_hwcap () & PPC_FEATURE_HAS_VSX)) { gdb_vsxregset_t vsxregset; @@ -2432,7 +2433,8 @@ ppc_linux_read_description (struct target_ops *ops) perror_with_name (_("Unable to fetch VSX registers")); } - if (have_ptrace_getvrregs) + if (have_ptrace_getvrregs + && (ppc_linux_get_hwcap () & PPC_FEATURE_HAS_ALTIVEC)) { gdb_vrregset_t vrregset;