public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Cc: Ozkan Sezer <sezeroz@gmail.com>
Subject: Re: [ping] [gdbserver] paddress() can truncate its argument
Date: Tue, 20 Jul 2010 18:00:00 -0000	[thread overview]
Message-ID: <201007201900.36018.pedro@codesourcery.com> (raw)
In-Reply-To: <AANLkTimkJEMJE6ufr6PeytSn5vyDFWn1-ufFstsp1085@mail.gmail.com>

On Tuesday 20 July 2010 18:51:40, Ozkan Sezer wrote:
> PING.
> Any objections? Can I apply this change?

Yes.

> 
> 
> On Fri, Jul 16, 2010 at 11:49 PM, Ozkan Sezer <sezeroz@gmail.com> wrote:
> > Hi:
> >
> > Noticed this while messing around with win64 support: paddress() casts
> > its CORE_ADDR argument (which is specifically defined as long long in
> > gdbserver) to long, probably assuming LP64 convention. For win64, which
> > is LLP64, it is not true (sizeof(long) == 4 always) and it truncates
> > its argument.
> >
> > Shouldn't paddress() just return phex_nz() instead, like the following:
> >
> > Index: utils.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/gdbserver/utils.c,v
> > retrieving revision 1.23
> > diff -u -p -r1.23 utils.c
> > --- utils.c     1 Jun 2010 13:20:52 -0000       1.23
> > +++ utils.c     16 Jul 2010 20:41:14 -0000
> > @@ -257,17 +257,6 @@ xsnprintf (char *str, size_t size, const
> >   return ret;
> >  }
> >
> > -/* Convert a CORE_ADDR into a HEX string, like %lx.
> > -   The result is stored in a circular static buffer, NUMCELLS deep.  */
> > -
> > -char *
> > -paddress (CORE_ADDR addr)
> > -{
> > -  char *str = get_cell ();
> > -  xsnprintf (str, CELLSIZE, "%lx", (long) addr);
> > -  return str;
> > -}
> > -
> >  static char *
> >  decimal2str (char *sign, ULONGEST addr, int width)
> >  {
> > @@ -372,3 +361,12 @@ phex_nz (ULONGEST l, int sizeof_l)
> >
> >   return str;
> >  }
> > +
> > +/* Convert a CORE_ADDR into a HEX string, like %lx.
> > +   The result is stored in a circular static buffer, NUMCELLS deep.  */
> > +
> > +char *
> > +paddress (CORE_ADDR addr)
> > +{
> > +  return phex_nz (addr, sizeof (CORE_ADDR));
> > +}
> >
> > Comments?
> >
> > --
> > Ozkan
> >
> 


-- 
Pedro Alves

  reply	other threads:[~2010-07-20 18:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16 20:49 [RFC] " Ozkan Sezer
2010-07-20 17:51 ` [ping] " Ozkan Sezer
2010-07-20 18:00   ` Pedro Alves [this message]
2010-07-20 18:12     ` Ozkan Sezer

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=201007201900.36018.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sezeroz@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).