From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2980 invoked by alias); 2 Oct 2012 21:07:22 -0000 Received: (qmail 2971 invoked by uid 22791); 2 Oct 2012 21:07:22 -0000 X-SWARE-Spam-Status: No, hits=-3.2 required=5.0 tests=AWL,BAYES_00,KHOP_SPAMHAUS_DROP,RP_MATCHES_RCVD,TW_CP X-Spam-Check-By: sourceware.org Received: from mms2.broadcom.com (HELO mms2.broadcom.com) (216.31.210.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Oct 2012 21:07:17 +0000 Received: from [10.9.200.133] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Tue, 02 Oct 2012 14:05:34 -0700 X-Server-Uuid: 4500596E-606A-40F9-852D-14843D8201B2 Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Tue, 2 Oct 2012 14:06:36 -0700 Received: from [10.177.252.33] (unknown [10.177.252.33]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 7BADD40FE3 for ; Tue, 2 Oct 2012 14:07:09 -0700 (PDT) Message-ID: <506B577B.5030306@broadcom.com> Date: Tue, 02 Oct 2012 21:07:00 -0000 From: "Andrew Burgess" User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: "gdb-patches@sourceware.org" Subject: [PATCH] more output from remote-sim dump_mem Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit 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: 2012-10/txt/msg00027.txt.bz2 The dump_mem function in gdb/remote-sim.c is only used for debugging but has a couple of interesting features, (1) It casts an array of bytes to an array of long in order to print the original array in 4 byte chunks, this is fine except long might not be 4 bytes in size. I've changed this to use uint32_t. (2) The function produces no output at all if the original buffer is more than 8 bytes in length. I've changed this so we always get some output from the function. Ok to apply ? Thanks, Andrew gdb/ChangeLog 2012-10-02 Andrew Burgess * remote-sim.c (dump_mem): Always dump buffer contents, zero fill output and use uint32_t not long to ensure 4 byte size. diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index d87f668..962420e 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -273,27 +273,24 @@ sim_inferior_data_cleanup (struct inferior *inf, void *data) static void dump_mem (char *buf, int len) { - if (len <= 8) + if (len == 8 || len == 4) { - if (len == 8 || len == 4) - { - long l[2]; + uint32_t l[2]; - memcpy (l, buf, len); - printf_filtered ("\t0x%lx", l[0]); - if (len == 8) - printf_filtered (" 0x%lx", l[1]); - printf_filtered ("\n"); - } - else - { - int i; + memcpy (l, buf, len); + printf_filtered ("\t0x%08x", l[0]); + if (len == 8) + printf_filtered (" 0x%08x", l[1]); + printf_filtered ("\n"); + } + else + { + int i; - printf_filtered ("\t"); - for (i = 0; i < len; i++) - printf_filtered ("0x%x ", buf[i]); - printf_filtered ("\n"); - } + printf_filtered ("\t"); + for (i = 0; i < len; i++) + printf_filtered ("0x%02x ", buf[i]); + printf_filtered ("\n"); } }