From: Pedro Alves <pedro@codesourcery.com>
To: Michael Snyder <msnyder@vmware.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Pierre Muller <muller@ics.u-strasbg.fr>
Subject: Re: New ARI regression Fri Oct 23 01:57:01 UTC 2009
Date: Fri, 23 Oct 2009 18:49:00 -0000 [thread overview]
Message-ID: <200910231949.35405.pedro@codesourcery.com> (raw)
In-Reply-To: <4AE1E3FD.7050203@vmware.com>
On Friday 23 October 2009 18:12:29, Michael Snyder wrote:
> 2009-10-23 Michael Snyder <msnyder@vmware.com>
>
> * record.c (netorder64): Add gdbarch argument. Use for byte order.
> (netorder32): Ditto.
> (netorder16): Ditto.
> (record_restore): Get gdbarch and pass to netorder.
> (cmd_record_save): Ditto.
>
> Index: record.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/record.c,v
> retrieving revision 1.32
> diff -u -p -r1.32 record.c
> --- record.c 23 Oct 2009 14:35:30 -0000 1.32
> +++ record.c 23 Oct 2009 17:17:21 -0000
> @@ -31,7 +31,6 @@
> #include "elf-bfd.h"
> #include "gcore.h"
>
> -#include <byteswap.h>
> #include <signal.h>
>
> /* This module implements "target record", also known as "process
> @@ -59,7 +58,7 @@
> #define RECORD_IS_REPLAY \
> (record_list->next || execution_direction == EXEC_REVERSE)
>
> -#define RECORD_FILE_MAGIC netorder32(0x20091016)
> +#define RECORD_FILE_MAGIC netorder32(gdbarch, 0x20091016)
I'd still make the magic target order independent. As simple as:
static unsigned char record_file_magic[] = { 0x20, 0x09, 0x10, 0x16 };
and then use straight memcmp to compare this:
read 4 bytes of header into buf
if (memcmp (buf, record_file_magic, 4) == 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.
> static inline uint64_t
> -netorder64 (uint64_t fromfile)
> +netorder64 (struct gdbarch *gdbarch, uint64_t input)
> {
> - return (BYTE_ORDER == LITTLE_ENDIAN)
> - ? bswap_64 (fromfile)
> - : fromfile;
> + uint64_t ret;
> +
> + store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret),
> + gdbarch_byte_order (gdbarch), input);
> + return ret;
> }
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.
--
Pedro Alves
next prev parent reply other threads:[~2009-10-23 18:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20091023015701.GA26378@sourceware.org>
2009-10-23 8:58 ` Pierre Muller
2009-10-23 16:07 ` Michael Snyder
2009-10-23 16:51 ` Pedro Alves
2009-10-23 17:19 ` Michael Snyder
2009-10-23 18:49 ` Pedro Alves [this message]
2009-10-23 22:37 ` Michael Snyder
2009-10-23 22:58 ` Pedro Alves
2009-10-23 23:42 ` Michael Snyder
2009-10-24 3:33 ` Hui Zhu
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=200910231949.35405.pedro@codesourcery.com \
--to=pedro@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@vmware.com \
--cc=muller@ics.u-strasbg.fr \
/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