From: Christian Biesinger via Gdb-patches <gdb-patches@sourceware.org>
To: Christian Biesinger <cbiesinger@google.com>,
gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH/committed] sim: rx: cast bfd_vma when printing
Date: Mon, 3 May 2021 16:47:12 -0500 [thread overview]
Message-ID: <CAPTJ0XEoe+MOrKnE6gkMoy-bS3TDX6HU5P05E6kwnF2wM0hsvA@mail.gmail.com> (raw)
In-Reply-To: <YJBjvE8LMXQ8C7TC@vapier>
On Mon, May 3, 2021 at 3:57 PM Mike Frysinger <vapier@gentoo.org> wrote:
>
> 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.
mingw (and msvc) is special because sizeof(long) is 4, even on a 64-bit system.
https://stackoverflow.com/questions/22344388/size-of-long-int-and-int-in-c-showing-4-bytes
> 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.
But if other places already do that, then eh...
Christian
next prev parent reply other threads:[~2021-05-03 21:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-01 20:29 Mike Frysinger via Gdb-patches
2021-05-03 16:20 ` Christian Biesinger via Gdb-patches
2021-05-03 20:57 ` Mike Frysinger via Gdb-patches
2021-05-03 21:47 ` Christian Biesinger via Gdb-patches [this message]
2021-05-04 0:47 ` Mike Frysinger via Gdb-patches
2021-05-04 2:54 ` Mike Frysinger via Gdb-patches
2021-05-04 12:17 ` [PATCH/committed] sim: clean up bfd_vma printing Mike Frysinger via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPTJ0XEoe+MOrKnE6gkMoy-bS3TDX6HU5P05E6kwnF2wM0hsvA@mail.gmail.com \
--to=gdb-patches@sourceware.org \
--cc=cbiesinger@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox