From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kY0sE8JjkGBWTAAAWB0awg (envelope-from ) for ; Mon, 03 May 2021 16:57:38 -0400 Received: by simark.ca (Postfix, from userid 112) id 413091F11C; Mon, 3 May 2021 16:57:38 -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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,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 8C1811E813 for ; Mon, 3 May 2021 16:57:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BD754385DC39; Mon, 3 May 2021 20:57:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD754385DC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1620075456; bh=DOQtijNcarnsdUT5rsov68/aRjkNIj9bwD+9vcEWay8=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QZUqpEWPOW/EJ3r0FHWUUKF0wLH+RsvHl2AwymVXtgIi5SjnAjFGniH6KAYDOZ2ls /ild1rqKi1Ipe/ESulC2qU96P1PNVHN6VvrudT7Ewk28I9h2zyOTRMBAqrkch3w6ir MpVbnYxOZhku0/mDpkIJf7FjZFpTfhL6KOuvBF14= Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 632F8385DC39 for ; Mon, 3 May 2021 20:57:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 632F8385DC39 Received: from vapier (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 43A0833BF51; Mon, 3 May 2021 20:57:33 +0000 (UTC) Date: Mon, 3 May 2021 16:57:32 -0400 To: Christian Biesinger Subject: Re: [PATCH/committed] sim: rx: cast bfd_vma when printing Message-ID: Mail-Followup-To: Christian Biesinger , gdb-patches References: <20210501202929.29766-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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: , From: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Cc: gdb-patches Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 03 May 2021 11:20, Christian Biesinger wrote: > On Sat, May 1, 2021, 15:29 Mike Frysinger wrote: > > A bit of a hack, but it's what we've been doing so far when printing > > bfd_vma's since bfd doesn't provide PRI helper types for us to use. > > > > --- a/sim/rx/load.c > > +++ b/sim/rx/load.c > > @@ -151,7 +151,7 @@ rx_load (bfd *prog, host_callback *callback) > > } > > if (bfd_bread (buf, size, prog) != size) > > { > > - fprintf (stderr, "Failed to read %lx bytes\n", size); > > + fprintf (stderr, "Failed to read %lx bytes\n", (long) size); > > Wouldn't it be better to use "long long", especially for mingw? not sure why mingw is special here. but let's ignore that. bfd_vma printing is poorly handled in many places in sim when bfd_vma is 64-bit but the host cpu is 32-bit (i.e. sizeof(long) == 4). the (long) cast pattern that i used here for printing is based on those. i don't think sim is the only place that does this poorly tbh, it's just what i'm focusing on. imo picking any type to cast to and copying & pasting that everywhere is a bit of a losing proposition. imo we should provide a PRI constant for code to use as that'll align with other fixed types (e.g. uint64_t). that makes it obvious when code is doing it correctly vs the compiler not happening to warn because the current configuration provides typedefs that align with the hardcoded sizes. but i don't really have the energy to take on that work. specifically for the rx_load code, this stuff needs to get deleted entirely and switched to the existing common/ logic. which is why i preferred a hacky patch here rather than diving deeper into the problem. so you're not wrong, i'm just not investing in code that i know will die :). -mike