From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47290 invoked by alias); 24 Aug 2017 21:51:46 -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 47278 invoked by uid 89); 24 Aug 2017 21:51:46 -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,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Aug 2017 21:51:44 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A71374DD7C; Thu, 24 Aug 2017 21:51:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A71374DD7C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07E78424F; Thu, 24 Aug 2017 21:51:42 +0000 (UTC) Subject: Re: [PATCH] break gdb build on 32-bit host with ADI support To: Wei-min Pan , gdb-patches@sourceware.org References: <1503595405-89600-1-git-send-email-weimin.pan@oracle.com> <479506e1-9478-1a38-d15c-3df13a817fff@redhat.com> <19930243-307d-b126-d4f2-d83eea74c3a4@redhat.com> <1ed3ad56-1f9e-a6a7-7736-741989c5ed86@oracle.com> From: Pedro Alves Message-ID: <0cc71221-6713-a449-fb49-65be69507e70@redhat.com> Date: Thu, 24 Aug 2017 21:51:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1ed3ad56-1f9e-a6a7-7736-741989c5ed86@oracle.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-08/txt/msg00481.txt.bz2 On 08/24/2017 09:27 PM, Wei-min Pan wrote: >>>> Use paddress instead? Also spaces around '*' and after the cast. >>> Where is paddress defined? I tried casting to "uint64" which yields to >>> "unsigned long" on a 64-bit host and didn't bode well with %llx. >> $ grep paddress *.h >> utils.h:extern const char *paddress (struct gdbarch *gdbarch, >> CORE_ADDR addr); > > On a 64-bit host: > ... > sparc64-tdep.c: In function 'void do_assign(CORE_ADDR, size_t, int)': > sparc64-tdep.c:449:56: error: expected ')' before 'vaddr' > error(_("No ADI information at 0x%llx"), (paddress)vaddr); > ^~~~~ > sparc64-tdep.c:449:61: error: format '%llx' expects argument of type > 'long long > unsigned int', but argument 2 has type 'const char* (*)(gdbarch*, > CORE_ADDR) {ak > a const char* (*)(gdbarch*, long unsigned int)}' [-Werror=format=] > error(_("No ADI information at 0x%llx"), (paddress)vaddr); > ^ > cc1plus: all warnings being treated as errors > make: *** [sparc64-tdep.o] Error 1 Of course. paddress is a function. See any of the other ~400 uses in the tree. Something like: error(_("No ADI information at %s"), paddress (gdbarch, vaddr)); >>>> looks suspiciously bogus to me. Consider a 32-bit host >>>> remote/cross debugging a SPARC64 target machine. Also consider >>>> a Win64-hosted GDB. >>> Good point. Changing it to: >>> >>> return ((long long)(((long long)addr << ast.nbits) >> >>> ast.nbits)); >>> >>> Thanks. >> Still looks odd to me. >> Why are you shifting signed types, for instance? >> Any why do you need the casts in the first place, BTW? > > We need to sign extend to get a normalized address, based on the > definitions in ADI space: > > ADI versioned address - a VA with ADI bits (63-60) set > Normalized address - a VA with bit 59 sign extended into ADI bits OK, but then please do it with valid/portable C/C++ code, with the usual masking and xoring. Left shifting signed integer values is undefined C++11. Right shifting a signed integer is implementation defined. Thanks, Pedro Alves