From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18644 invoked by alias); 18 Oct 2009 03:56:33 -0000 Received: (qmail 18636 invoked by uid 22791); 18 Oct 2009 03:56:32 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Oct 2009 03:56:29 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id C7DC12200D; Sat, 17 Oct 2009 20:56:25 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by mailhost4.vmware.com (Postfix) with ESMTP id BBFD6C9B89; Sat, 17 Oct 2009 20:56:25 -0700 (PDT) Message-ID: <4ADA908C.1030808@vmware.com> Date: Sun, 18 Oct 2009 03:56:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Hui Zhu CC: "gdb-patches@sourceware.org" Subject: Re: [RFA] record.c - save some memory in record log. References: <4AD761AD.40307@vmware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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: 2009-10/txt/msg00405.txt.bz2 Hui Zhu wrote: > Thanks Michael, This patch is very cool. > > +struct record_reg_entry > +{ > + unsigned short num; > + unsigned short len; > + union > + { > + gdb_byte *ptr; > + gdb_byte buf[2 * sizeof (gdb_byte *)]; > > Why this part use "2 * sizeof (gdb_byte *)"? Oh, no strong reason. I just noticed that mem_entry is larger than reg_entry, and since it is used in a union, that space is otherwise going to waste. I do not assume that a target general register is the same size as a host pointer -- only that the larger we make this buf, the less likely that we have to use malloc. > > + rec->u.reg.u.ptr = (gdb_byte *) xmalloc (MAX_REGISTER_SIZE); > I suggest change MAX_REGISTER_SIZE to rec->u.reg.len. Ah, good idea, thanks. I'll make that change. Any other comments?