Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Kai Tietz <Kai.Tietz@onevision.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org, Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [RFC] convert a host address to a string
Date: Fri, 09 Jan 2009 14:28:00 -0000	[thread overview]
Message-ID: <OFA542D22E.A1D54DEA-ONC1257539.004F0A73-C1257539.004F65BE@onevision.de> (raw)
In-Reply-To: <20090109131227.GL24105@adacore.com>

Hi Joel,

gdb-patches-owner@sourceware.org wrote on 09.01.2009 14:12:27:
> > >   3. Work through uintptr_t.
> > > 
> > >        #ifdef PRINTF_HAS_LONG_LONG
> > >          fprintf (buf, "0x%llx", (unsigned long long) 
> (uintptr_t) address);
> > >        #else
> > >          fprintf (buf, "0x%lx", (unsigned long) (uintptr_t) 
address);
> > >        #endif
> > 
> > This wouldn't be the first place where we'd use a double cast in
> > connection with intptr_t/uintptr_t.  So I'd say that while this is a
> > bit ugly, it's certainly acceptable.  It's by far the simplest way to
> > fix things.
> 
> Here is a new patch implementing this approach.  As I told Kai,
> it's probably not going to work for x86_64/XP, but it works for
> x86_64/Vista (I think Kai agreed to take on the job of improving
> this approach to work on XP as well :-).
> 
> 2009-01-09  Joel Brobecker  <brobecker@adacore.com>
> 
>         * utils.c (host_address_to_string): Cast the address to 
uintptr_t
>         first to avoid a possible compilation warning about casting to
>         an integer of the wrong size.  Then format the address using
>         unsigned long long if supported by printf.  Otherwise, fallback
>         on using usingned long, hoping that long is large enough to hold
>         an address.
> 
> Tested on x86-linux. I also verified that it still builds on
> x86_64 Vista, as well as x86/Windows XP (on XP, PRINTF_HAS_LONG_LONG
> is undefined).

I think it is a sub-optimal solution to have just support for Vista64, but 
not for XP. On a second thought, I remembered, that bfd does things right 
;) There is the macro sprintf_vma in bfd.h, which handles things pretty 
well and can be used here in utils.c, too.


Cheers,
Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.


  reply	other threads:[~2009-01-09 14:28 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-07 12:19 Joel Brobecker
2009-01-07 16:17 ` Mark Kettenis
2009-01-08 10:19   ` Joel Brobecker
2009-01-08 10:25     ` Kai Tietz
2009-01-08 10:48       ` Joel Brobecker
2009-01-08 11:02         ` Kai Tietz
2009-01-08 11:25           ` Joel Brobecker
2009-01-08 11:31             ` Kai Tietz
2009-01-08 12:49           ` Mark Kettenis
2009-01-08 12:54             ` Joel Brobecker
2009-01-08 13:04               ` Kai Tietz
2009-01-08 13:12               ` Mark Kettenis
2009-01-08 13:26     ` Mark Kettenis
2009-01-08 13:35       ` Kai Tietz
2009-01-08 13:42         ` Joel Brobecker
2009-01-08 14:04           ` Kai Tietz
2009-01-08 16:18         ` Mark Kettenis
2009-01-08 16:23           ` Kai Tietz
2009-01-09  9:57             ` Joel Brobecker
2009-01-09 10:05               ` Kai Tietz
2009-01-09 13:12       ` Joel Brobecker
2009-01-09 14:28         ` Kai Tietz [this message]
2009-01-10  7:12           ` Joel Brobecker
2009-01-10 13:31             ` Kai Tietz
2009-01-10 13:34               ` Kai Tietz
2009-01-10 13:58               ` Mark Kettenis
2009-01-10 14:04               ` Mark Kettenis
2009-01-10 14:15                 ` Kai Tietz
2009-01-10 14:22                   ` Mark Kettenis
2009-01-10 14:25                     ` Kai Tietz
2009-01-11 13:31                     ` Joel Brobecker
2009-01-11 13:53                       ` Mark Kettenis
2009-01-13 12:09                     ` Joel Brobecker

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=OFA542D22E.A1D54DEA-ONC1257539.004F0A73-C1257539.004F65BE@onevision.de \
    --to=kai.tietz@onevision.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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