From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id B7JPOpQyV2EBBQAAWB0awg (envelope-from ) for ; Fri, 01 Oct 2021 12:08:52 -0400 Received: by simark.ca (Postfix, from userid 112) id DDA2A1EDF0; Fri, 1 Oct 2021 12:08:52 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=MAILING_LIST_MULTI, NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2C82C1E79C for ; Fri, 1 Oct 2021 12:08:52 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 91B1A3857810 for ; Fri, 1 Oct 2021 16:08:51 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id CFEE83858406 for ; Fri, 1 Oct 2021 16:08:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CFEE83858406 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 2A9291E79C; Fri, 1 Oct 2021 12:08:39 -0400 (EDT) Subject: Re: [PATCH] Fix build failure for 32-bit targets To: Luis Machado , gdb-patches@sourceware.org References: <20211001115002.1681134-1-luis.machado@linaro.org> <46f0c972-d009-d066-bc4f-689660124b63@linaro.org> From: Simon Marchi Message-ID: Date: Fri, 1 Oct 2021 12:08:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <46f0c972-d009-d066-bc4f-689660124b63@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-10-01 11:53 a.m., Luis Machado via Gdb-patches wrote: > On 10/1/21 12:25 PM, Mike Frysinger wrote: >> On 01 Oct 2021 08:50, Luis Machado via Gdb-patches wrote: >>> When building master GDB, I ran into the following: >>> >>> binutils-gdb/gdb/bt-utils.c: In function ‘int libbacktrace_print(void*, uintptr_t, const char*, int, const char*)’: >>> binutils-gdb/gdb/bt-utils.c:93:44: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uintptr_t {aka unsigned int}’ [-Werror=format=] >>> snprintf (buf, sizeof (buf), "0x%lx ", pc); >>> >>> Fix this by using phex and %s as opposed to 0x%lx. >> >> wouldn't PRIxPTR fix it and be simpler ? >> -mike >> > > I'm happy either way, but GDB uses phex/phex_nz/pulongest much more often. > > grep "phex" gdb -R | wc -l > 143 > > grep "PRIx" gdb -R | wc -l > 25 That's probably because GDB (for historical reasons I suppose) uses these LONGEST/ULONGEST types, so we can't use standard things like PRIx64 directly. Although we could also define, say, PRIxLONGEST and PRIxULONGEST and use them in format strings. But here, since we want to print a uintptr_t, I would also go for PRIxPTR, it's standard after all: https://en.cppreference.com/w/cpp/types/integer Simon