From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24943 invoked by alias); 31 Aug 2009 08:23:14 -0000 Received: (qmail 24934 invoked by uid 22791); 31 Aug 2009 08:23:13 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-yw0-f176.google.com (HELO mail-yw0-f176.google.com) (209.85.211.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 31 Aug 2009 08:23:08 +0000 Received: by ywh6 with SMTP id 6so5797991ywh.0 for ; Mon, 31 Aug 2009 01:23:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.88.2 with SMTP id l2mr8604790ybb.260.1251706985334; Mon, 31 Aug 2009 01:23:05 -0700 (PDT) In-Reply-To: References: <200908301356.n7UDuO4a006136@brahms.sibelius.xs4all.nl> From: Hui Zhu Date: Mon, 31 Aug 2009 08:46:00 -0000 Message-ID: Subject: Re: [PATCH] Fix cygwin build error with i386-linux-tdep.c To: Mark Kettenis Cc: gdb-patches@sourceware.org, msnyder@vmware.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00575.txt.bz2 On Sun, Aug 30, 2009 at 22:37, Hui Zhu wrote: > On Sun, Aug 30, 2009 at 22:09, Hui Zhu wrote: >> On Sun, Aug 30, 2009 at 21:56, Mark Kettenis wr= ote: >>>> From: Hui Zhu >>>> Date: Sun, 30 Aug 2009 21:15:22 +0800 >>>> >>>> 2009-08-29 =A0Hui Zhu =A0 >>>> >>>> =A0 =A0 =A0 * i386-linux-tdep.c (i386_linux_intx80_sysenter_record): A= dd >>>> =A0 =A0 =A0 (unsigned) before tmpu32. >>> >>> Ugh! =A0Casts like that are ugly. >>> >>> This made me look at the code again and realize that what you're doing >>> in that function is wrong. =A0You should be using >>> regcache_{raw|cooked}_read_unsigned() instead of regcache_raw_read(). >>> Then the whole issue of printing an uint32_t goes away. =A0When you do >>> change the code like that please use a more meaningful variable name >>> instead of 'tmpu32'. =A0My suggestion would be 'syscall'. >> >> For the regcache_raw_read_unsigned, I am not agres with it. >> >> void >> regcache_raw_read_unsigned (struct regcache *regcache, int regnum, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ULONGEST *val) >> { >> =A0gdb_byte *buf; >> =A0gdb_assert (regcache !=3D NULL); >> =A0gdb_assert (regnum >=3D 0 && regnum < regcache->descr->nr_raw_registe= rs); >> =A0buf =3D alloca (regcache->descr->sizeof_register[regnum]); >> =A0regcache_raw_read (regcache, regnum, buf); >> =A0(*val) =3D extract_unsigned_integer >> =A0 =A0 =A0 =A0 =A0 =A0 (buf, regcache->descr->sizeof_register[regnum], >> =A0 =A0 =A0 =A0 =A0 =A0 =A0gdbarch_byte_order (regcache->descr->gdbarch)= ); >> } >> >> It just add a "extract_unsigned_integer". =A0For this code, it in >> i386-linux-tdep.c. =A0We know that I386_EAX_REGNUM is 32 bits. =A0So we >> don't need extract_unsigned_integer to set anything. >> >> Thanks, >> Hui > > Oops, I forget that we have the byte order trouble. =A0Thanks for remind > me. =A0I will fix it. > > Thanks, > Hui > >> >>> >>> Cheers, >>> >>> Mark >>> >>>> Index: gdb/i386-linux-tdep.c >>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>>> --- gdb.orig/i386-linux-tdep.c =A0 =A0 =A0 =A02009-08-23 21:17:37.0000= 00000 +0800 >>>> +++ gdb/i386-linux-tdep.c =A0 =A0 2009-08-30 20:19:53.828125000 +0800 >>>> @@ -374,7 +374,7 @@ >>>> =A0 =A0if (tmpu32 > 499) >>>> =A0 =A0 =A0{ >>>> =A0 =A0 =A0 =A0printf_unfiltered (_("Process record and replay target = doesn't " >>>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "support syscall= number %u\n"), tmpu32); >>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "support syscall= number %u\n"), (unsigned) tmpu32); >>>> =A0 =A0 =A0 =A0return -1; >>>> =A0 =A0 =A0} >>>> >>> >> > Hi guys, I make a new patch that change regcache_raw_read to regcache_raw_read_unsig= ned. Please help me review it. Thanks, Hui 2009-08-31 Hui Zhu * 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); return -1; } - ret =3D record_linux_system_call (tmpu32, regcache, + ret =3D record_linux_system_call ((int) num, regcache, &i386_linux_record_tdep); if (ret) return ret;