Re: [PATCH] Fix cygwin build error with i386-linux-tdep.c

Jiang Jilin
2009-08-31T08:46:25Z

On Mon, Aug 31, 2009 at 4:22 PM, Hui Zhu<teawater@gmail.com> wrote:

> Hi guys,
>
> I make a new patch that change regcache_raw_read to regcache_raw_read_unsigned.
> Please help me review it.
>
> Thanks,
> Hui
>
> 2009-08-31  Hui Zhu  <teawater@gmail.com>
>
>        * i386-linux-tdep.c (i386_linux_intx80_sysenter_record): Change
>        regcache_raw_read to regcache_raw_read_unsigned.
>
> ---
>  i386-linux-tdep.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> --- a/i386-linux-tdep.c
> +++ b/i386-linux-tdep.c
> @@ -367,18 +367,18 @@ static int
>  i386_linux_intx80_sysenter_record (struct regcache *regcache)
>  {
>   int ret;
> -  uint32_t tmpu32;
> +  ULONGEST num;
>
> -  regcache_raw_read (regcache, I386_EAX_REGNUM, (gdb_byte *) &tmpu32);
> +  regcache_raw_read_unsigned (regcache, I386_EAX_REGNUM, &num);
>
> -  if (tmpu32 > 499)
> +  if (num > 499)
>     {
>       printf_unfiltered (_("Process record and replay target doesn't "
> -                           "support syscall number %u\n"), tmpu32);
> +                           "support syscall number %d\n"), (int) num);

if you want an integer read, why not use regcache_raw_read_signed() instead?

>       return -1;
>     }
>
> -  ret = record_linux_system_call (tmpu32, regcache,
> +  ret = record_linux_system_call ((int) num, regcache,
>                                  &i386_linux_record_tdep);
>   if (ret)
>     return ret;
>

I think it's not very sensible to cast unsigned to signed, think about
if the unsigned value is _very_ big.

--
Thanks

Jiang