From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13791 invoked by alias); 23 Oct 2009 17:19:27 -0000 Received: (qmail 13780 invoked by uid 22791); 23 Oct 2009 17:19:25 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Oct 2009 17:19:20 +0000 Received: from jupiter.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 7ED775400B; Fri, 23 Oct 2009 10:19:19 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by jupiter.vmware.com (Postfix) with ESMTP id 7551DDC060; Fri, 23 Oct 2009 10:19:19 -0700 (PDT) Message-ID: <4AE1E3FD.7050203@vmware.com> Date: Fri, 23 Oct 2009 17:19:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Pedro Alves CC: "gdb-patches@sourceware.org" , Pierre Muller Subject: Re: New ARI regression Fri Oct 23 01:57:01 UTC 2009 References: <20091023015701.GA26378@sourceware.org> <006301ca53be$eedd1b80$cc975280$@u-strasbg.fr> <4AE1D314.4030601@vmware.com> <200910231750.54862.pedro@codesourcery.com> In-Reply-To: <200910231750.54862.pedro@codesourcery.com> Content-Type: multipart/mixed; boundary="------------010803040107060002010306" 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/msg00599.txt.bz2 This is a multi-part message in MIME format. --------------010803040107060002010306 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 860 Pedro Alves wrote: > On Friday 23 October 2009 17:00:20, Michael Snyder wrote: >> Pierre Muller wrote: >>> Is there a valid reason to use LITTLE_ENDIAN rather than >>> BFD_LITTLE_ENDIAN as required by the ARI rule: >>> >>> LITTLE ENDIAN 3 Do not use LITTLE_ENDIAN, instead use >>> BFD_ENDIAN_LITTLE >>> See: >>> http://sourceware.org/gdb/current/ari/ >>> >>> Pierre Muller >>> as ARI "maintainer" >> >> Thanks Pierre. Checked in as obvious. > > No, this is wrong. BYTE_ORDER isn't available on all hosts, and > even if it did, its values surely don't match enum bfd_endian... Dang. How about this? The byte order that's saved in the file is never actually used. We just need to make sure that it's a consistent order, and that hopefully we can read the execution log into gdb on a different host. So target byte order should be all that matters. --------------010803040107060002010306 Content-Type: text/plain; name="nobyteorder.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="nobyteorder.txt" Content-length: 6424 2009-10-23 Michael Snyder * 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 #include /* 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) /* These are the core structs of the process record functionality. @@ -1916,7 +1915,7 @@ info_record_command (char *args, int fro n bytes: memory value (n == memory length). Version 2 - 4 bytes: magic number netorder32(0x20091016). + 4 bytes: magic number netorder32(gdbarch, 0x20091016). NOTE: be sure to change whenever this file format changes! Records: @@ -1953,27 +1952,33 @@ bfdcore_read (bfd *obfd, asection *osec, } 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; } static inline uint32_t -netorder32 (uint32_t fromfile) +netorder32 (struct gdbarch *gdbarch, uint32_t input) { - return (BYTE_ORDER == LITTLE_ENDIAN) - ? bswap_32 (fromfile) - : fromfile; + uint32_t ret; + + store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), + gdbarch_byte_order (gdbarch), input); + return ret; } static inline uint16_t -netorder16 (uint16_t fromfile) +netorder16 (struct gdbarch *gdbarch, uint16_t input) { - return (BYTE_ORDER == LITTLE_ENDIAN) - ? bswap_16 (fromfile) - : fromfile; + uint16_t ret; + + store_unsigned_integer ((gdb_byte *) &ret, sizeof (ret), + gdbarch_byte_order (gdbarch), input); + return ret; } /* Restore the execution log from a core_bfd file. */ @@ -1987,6 +1992,7 @@ record_restore (void) uint32_t osec_size; int bfd_offset = 0; struct regcache *regcache; + struct gdbarch *gdbarch; /* We restore the execution log from the open core bfd, if there is one. */ @@ -2010,6 +2016,9 @@ record_restore (void) if (record_debug) printf_filtered ("%s", bfd_section_name (core_bfd, osec)); + regcache = get_current_regcache (); + gdbarch = get_regcache_arch (regcache); + /* Check the magic code. */ bfdcore_read (core_bfd, osec, &magic, sizeof (magic), &bfd_offset); if (magic != RECORD_FILE_MAGIC) @@ -2018,7 +2027,7 @@ record_restore (void) if (record_debug) printf_filtered ("\ Reading 4-byte magic cookie RECORD_FILE_MAGIC (0x%s)\n", - phex_nz (netorder32 (magic), 4)); + phex_nz (netorder32 (gdbarch, magic), 4)); /* Restore the entries in recfd into record_arch_list_head and record_arch_list_tail. */ @@ -2026,7 +2035,6 @@ record_restore (void) record_arch_list_tail = NULL; record_insn_num = 0; old_cleanups = make_cleanup (record_arch_list_cleanups, 0); - regcache = get_current_regcache (); while (1) { @@ -2046,7 +2054,7 @@ record_restore (void) /* Get register number to regnum. */ bfdcore_read (core_bfd, osec, ®num, sizeof (regnum), &bfd_offset); - regnum = netorder32 (regnum); + regnum = netorder32 (gdbarch, regnum); rec = record_reg_alloc (regcache, regnum); @@ -2066,12 +2074,12 @@ record_restore (void) /* Get len. */ bfdcore_read (core_bfd, osec, &len, sizeof (len), &bfd_offset); - len = netorder32 (len); + len = netorder32 (gdbarch, len); /* Get addr. */ bfdcore_read (core_bfd, osec, &addr, sizeof (addr), &bfd_offset); - addr = netorder64 (addr); + addr = netorder64 (gdbarch, addr); rec = record_mem_alloc (addr, len); @@ -2096,13 +2104,13 @@ record_restore (void) /* Get signal value. */ bfdcore_read (core_bfd, osec, &signal, sizeof (signal), &bfd_offset); - signal = netorder32 (signal); + signal = netorder32 (gdbarch, signal); rec->u.end.sigval = signal; /* Get insn count. */ bfdcore_read (core_bfd, osec, &count, sizeof (count), &bfd_offset); - count = netorder32 (count); + count = netorder32 (gdbarch, count); rec->u.end.insn_num = count; record_insn_count = count + 1; if (record_debug) @@ -2314,7 +2322,7 @@ cmd_record_save (char *args, int from_tt record_list->u.reg.len); /* Write regnum. */ - regnum = netorder32 (record_list->u.reg.num); + regnum = netorder32 (gdbarch, record_list->u.reg.num); bfdcore_write (obfd, osec, ®num, sizeof (regnum), &bfd_offset); @@ -2334,11 +2342,11 @@ cmd_record_save (char *args, int from_tt record_list->u.mem.len); /* Write memlen. */ - len = netorder32 (record_list->u.mem.len); + len = netorder32 (gdbarch, record_list->u.mem.len); bfdcore_write (obfd, osec, &len, sizeof (len), &bfd_offset); /* Write memaddr. */ - addr = netorder64 (record_list->u.mem.addr); + addr = netorder64 (gdbarch, record_list->u.mem.addr); bfdcore_write (obfd, osec, &addr, sizeof (addr), &bfd_offset); @@ -2354,12 +2362,12 @@ cmd_record_save (char *args, int from_tt (unsigned long) sizeof (signal), (unsigned long) sizeof (count)); /* Write signal value. */ - signal = netorder32 (record_list->u.end.sigval); + signal = netorder32 (gdbarch, record_list->u.end.sigval); bfdcore_write (obfd, osec, &signal, sizeof (signal), &bfd_offset); /* Write insn count. */ - count = netorder32 (record_list->u.end.insn_num); + count = netorder32 (gdbarch, record_list->u.end.insn_num); bfdcore_write (obfd, osec, &count, sizeof (count), &bfd_offset); break; --------------010803040107060002010306--