* [RFC] [gdbserver] paddress() can truncate its argument
@ 2010-07-16 20:49 Ozkan Sezer
2010-07-20 17:51 ` [ping] " Ozkan Sezer
0 siblings, 1 reply; 4+ messages in thread
From: Ozkan Sezer @ 2010-07-16 20:49 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ping] [gdbserver] paddress() can truncate its argument
2010-07-16 20:49 [RFC] [gdbserver] paddress() can truncate its argument Ozkan Sezer
@ 2010-07-20 17:51 ` Ozkan Sezer
2010-07-20 18:00 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Ozkan Sezer @ 2010-07-20 17:51 UTC (permalink / raw)
To: gdb-patches
PING.
Any objections? Can I apply this change?
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ping] [gdbserver] paddress() can truncate its argument
2010-07-20 17:51 ` [ping] " Ozkan Sezer
@ 2010-07-20 18:00 ` Pedro Alves
2010-07-20 18:12 ` Ozkan Sezer
0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2010-07-20 18:00 UTC (permalink / raw)
To: gdb-patches; +Cc: Ozkan Sezer
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ping] [gdbserver] paddress() can truncate its argument
2010-07-20 18:00 ` Pedro Alves
@ 2010-07-20 18:12 ` Ozkan Sezer
0 siblings, 0 replies; 4+ messages in thread
From: Ozkan Sezer @ 2010-07-20 18:12 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Tue, Jul 20, 2010 at 9:00 PM, Pedro Alves <pedro@codesourcery.com> wrote:
> On Tuesday 20 July 2010 18:51:40, Ozkan Sezer wrote:
>> PING.
>> Any objections? Can I apply this change?
>
> Yes.
>
Applied. Thanks.
>>
>>
>> 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
>
--
Ozkan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-20 18:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-16 20:49 [RFC] [gdbserver] paddress() can truncate its argument Ozkan Sezer
2010-07-20 17:51 ` [ping] " Ozkan Sezer
2010-07-20 18:00 ` Pedro Alves
2010-07-20 18:12 ` Ozkan Sezer
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).