From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13420 invoked by alias); 23 Oct 2009 18:49:33 -0000 Received: (qmail 13412 invoked by uid 22791); 23 Oct 2009 18:49:32 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Oct 2009 18:49:29 +0000 Received: (qmail 17972 invoked from network); 23 Oct 2009 18:49:27 -0000 Received: from unknown (HELO orlando) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Oct 2009 18:49:27 -0000 From: Pedro Alves To: Michael Snyder Subject: Re: New ARI regression Fri Oct 23 01:57:01 UTC 2009 Date: Fri, 23 Oct 2009 18:49:00 -0000 User-Agent: KMail/1.9.10 Cc: "gdb-patches@sourceware.org" , Pierre Muller References: <20091023015701.GA26378@sourceware.org> <200910231750.54862.pedro@codesourcery.com> <4AE1E3FD.7050203@vmware.com> In-Reply-To: <4AE1E3FD.7050203@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200910231949.35405.pedro@codesourcery.com> 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-10/txt/msg00601.txt.bz2 On Friday 23 October 2009 18:12:29, Michael Snyder wrote: > 2009-10-23 =A0Michael Snyder =A0 >=20 > =A0=A0=A0=A0=A0=A0=A0=A0* record.c (netorder64): Add gdbarch argument. = =A0Use for byte order. > =A0=A0=A0=A0=A0=A0=A0=A0(netorder32): Ditto. > =A0=A0=A0=A0=A0=A0=A0=A0(netorder16): Ditto. > =A0=A0=A0=A0=A0=A0=A0=A0(record_restore): Get gdbarch and pass to netorde= r. > =A0=A0=A0=A0=A0=A0=A0=A0(cmd_record_save): Ditto. >=20 > Index: record.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 > RCS file: /cvs/src/src/gdb/record.c,v > retrieving revision 1.32 > diff -u -p -r1.32 record.c > --- record.c=A0=A0=A0=A023 Oct 2009 14:35:30 -0000=A0=A0=A0=A0=A0=A01.32 > +++ record.c=A0=A0=A0=A023 Oct 2009 17:17:21 -0000 > @@ -31,7 +31,6 @@ > =A0#include "elf-bfd.h" > =A0#include "gcore.h" > =A0 > -#include > =A0#include > =A0 > =A0/* This module implements "target record", also known as "process > @@ -59,7 +58,7 @@ > =A0#define RECORD_IS_REPLAY \ > =A0 =A0 =A0 (record_list->next || execution_direction =3D=3D EXEC_REVERSE) > =A0 > -#define RECORD_FILE_MAGIC=A0=A0=A0=A0=A0=A0netorder32(0x20091016) > +#define RECORD_FILE_MAGIC=A0=A0=A0=A0=A0=A0netorder32(gdbarch, 0x2009101= 6) I'd still make the magic target order independent. As simple as: static unsigned char record_file_magic[] =3D { 0x20, 0x09, 0x10, 0x16 }; and then use straight memcmp to compare this: read 4 bytes of header into buf =20=20=20=20=20=20=20=20 if (memcmp (buf, record_file_magic, 4) =3D=3D 0) success!! Or simply store_unsigned_integer/extract_unsigned_integer with one of BFD_ENDIAN_LITTLE|BIG hardcoded... I'd also add a simple version field after the magic; a simple incrementing integer, so that you don't have to keep inventing a new magic for every bump. > =A0static inline uint64_t > -netorder64 (uint64_t fromfile) > +netorder64 (struct gdbarch *gdbarch, uint64_t input) > =A0{ > - =A0return (BYTE_ORDER =3D=3D LITTLE_ENDIAN)=20 > - =A0 =A0? bswap_64 (fromfile)=20 > - =A0 =A0: fromfile; > + =A0uint64_t ret; > + > + =A0store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret),=20 > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = =A0gdbarch_byte_order (gdbarch), input); > + =A0return ret; > =A0} These functions aren't always "network order" now, and are hence misnamed. Rename or eliminate them by inlining they bodies at the call sites. Alternatively, if you wanted to keep using "netorder", you could just simply always hardcode BFD_ENDIAN_BIG, or pull htonl from gnulib. --=20 Pedro Alves