From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1697 invoked by alias); 20 Mar 2013 02:48:38 -0000 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 Received: (qmail 1682 invoked by uid 89); 20 Mar 2013 02:48:31 -0000 X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 20 Mar 2013 02:48:29 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1UI94l-0002Xh-2x from Yao_Qi@mentor.com ; Tue, 19 Mar 2013 19:48:27 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 19 Mar 2013 19:48:26 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Tue, 19 Mar 2013 19:48:25 -0700 Message-ID: <51492341.9080503@codesourcery.com> Date: Wed, 20 Mar 2013 03:48:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Joel Brobecker CC: Subject: Re: [PATCH 2/3] Write CTF in host byte order References: <83ip4s4ixc.fsf@gnu.org> <1363407692-18959-1-git-send-email-yao@codesourcery.com> <1363407692-18959-3-git-send-email-yao@codesourcery.com> <20130319210534.GC4506@adacore.com> In-Reply-To: <20130319210534.GC4506@adacore.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-03/txt/msg00727.txt.bz2 On 03/20/2013 05:05 AM, Joel Brobecker wrote: >> > ctf_save_write_metadata (handler, metadata_fmt, >> > CTF_SAVE_MAJOR, CTF_SAVE_MINOR, >> >- BYTE_ORDER == LITTLE_ENDIAN ? "le" : "be"); >> >+ HOST_ENDIANNESS); > + WORDS_BIGENDIAN ? "be" : "le"); > > Either way really works for me, especially if you think you might > be using HOST_ENDIANNESS elsewhere again sometime. > Joel, thanks for the review. Your suggestion doesn't compile on little endian machine, because WORDS_BIGENDIAN is not defined. In the autoconf manual: "The default for action-if-true is to define ‘WORDS_BIGENDIAN’. The default for action-if-false is to do nothing." > You can commit with a comment or the change I suggested. If someone > objects, it's easy to revert or adjust. Patch below is what I committed. -- Yao (齐尧) gdb: 2013-03-20 Yao Qi * ctf.c (ctf_save_metadata_header): Define macro HOST_ENDIANNESS and write it to CTF metadata. --- gdb/ctf.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/gdb/ctf.c b/gdb/ctf.c index f77eb7d..455bfde 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -242,9 +242,17 @@ ctf_save_metadata_header (struct trace_write_handler *handler) " } := chars;\n"); ctf_save_write_metadata (handler, "\n"); + /* Get the byte order of the host and write CTF data in this byte + order. */ +#if WORDS_BIGENDIAN +#define HOST_ENDIANNESS "be" +#else +#define HOST_ENDIANNESS "le" +#endif + ctf_save_write_metadata (handler, metadata_fmt, CTF_SAVE_MAJOR, CTF_SAVE_MINOR, - BYTE_ORDER == LITTLE_ENDIAN ? "le" : "be"); + HOST_ENDIANNESS); ctf_save_write_metadata (handler, "\n"); } -- 1.7.7.6