From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xOrBEUEzV2FqBQAAWB0awg (envelope-from ) for ; Fri, 01 Oct 2021 12:11:45 -0400 Received: by simark.ca (Postfix, from userid 112) id 36AFD1EDF0; Fri, 1 Oct 2021 12:11:45 -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.6 required=5.0 tests=MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 8D92A1E79C for ; Fri, 1 Oct 2021 12:11:44 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C3243857820 for ; Fri, 1 Oct 2021 16:11:44 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id AC89C3857821 for ; Fri, 1 Oct 2021 16:11:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AC89C3857821 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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 3701B1E79C; Fri, 1 Oct 2021 12:11:33 -0400 (EDT) Subject: Re: [PATCH] Fix build failure for 32-bit targets From: Simon Marchi To: Luis Machado , gdb-patches@sourceware.org References: <20211001115002.1681134-1-luis.machado@linaro.org> <46f0c972-d009-d066-bc4f-689660124b63@linaro.org> Message-ID: <8eb3dc0c-f0df-4a5d-969c-fe16d4d5929c@simark.ca> Date: Fri, 1 Oct 2021 12:11:32 -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: 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 12:08 p.m., Simon Marchi wrote: > 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 Or, maybe %p since the goal is to print a pointer for the local host, but I suppose the value would have to be cast to void*. Simon