From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8844 invoked by alias); 13 Jan 2015 17:00:56 -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 8826 invoked by uid 89); 13 Jan 2015 17:00:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e36.co.us.ibm.com Received: from e36.co.us.ibm.com (HELO e36.co.us.ibm.com) (32.97.110.154) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 13 Jan 2015 17:00:48 +0000 Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Jan 2015 10:00:46 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 13 Jan 2015 10:00:45 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 8DA803E4003B for ; Tue, 13 Jan 2015 10:00:44 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0DH1EgA46137432 for ; Tue, 13 Jan 2015 10:01:14 -0700 Received: from d03av02.boulder.ibm.com (localhost [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0DH0h9K014883 for ; Tue, 13 Jan 2015 10:00:44 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id t0DH0eDu014515; Tue, 13 Jan 2015 10:00:41 -0700 Message-Id: <201501131700.t0DH0eDu014515@d03av02.boulder.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 13 Jan 2015 18:00:30 +0100 Subject: Re: [PATCH 2/2] Detect 64-bit-ness in PowerPC Book III-E To: yao@codesourcery.com (Yao Qi) Date: Tue, 13 Jan 2015 17:00:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <1420964846-18881-3-git-send-email-yao@codesourcery.com> from "Yao Qi" at Jan 11, 2015 04:27:26 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15011317-0021-0000-0000-000007BB9B3F X-SW-Source: 2015-01/txt/msg00350.txt.bz2 Yao Qi wrote: > gdb: > > 2015-01-11 Yao Qi > > * Makefile.in (ppc-linux.o): New rule. > * config/powerpc/ppc64-linux.mh (NATDEPFILES): Add ppc-linux.o. > * nat/ppc-linux.h [__powerpc64__] (ppc64_64bit_inferior_p): > Declare. > * nat/ppc-linux.c: New file. > * ppc-linux-nat.c (ppc_linux_target_wordsize) [__powerpc64__]: > Call ppc64_64bit_inferior_p. > > gdb/gdbserver: > > 2015-01-11 Yao Qi > > * Makefile.in (SFILES): Add nat/ppc-linux.c. > (ppc-linux.o): New rule. > * configure.srv (powerpc*-*-linux*): Add ppc-linux.o. > * linux-ppc-low.c (ppc_arch_setup) [__powerpc64__]: Call > ppc64_64bit_inferior_p This is OK in principle, however: > +static void > +ppc64_host_hwcap (unsigned long *valp) > +{ > + unsigned char data[2 * 8]; > + FILE *f = fopen ("/proc/self/auxv", "r"); > + > + if (f == NULL) > + return; > + > + while (fread (data, sizeof (data), 1, f) > 0) > + { > + unsigned long *data_p = (unsigned long *) data; > + > + if (data_p[0] == AT_HWCAP) > + { > + *valp = data_p[1]; > + break; > + } > + } > + > + fclose (f); > +} All this can be done using "getauxval (AT_HWCAP)", which is faster and works even if /proc is not mounted. However, getauxval was only introduced with glibc 2.16, so we'll probably still need the fallback ... Bye, Ulrich -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com