From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11165 invoked by alias); 13 Oct 2009 18:06:40 -0000 Received: (qmail 11155 invoked by uid 22791); 13 Oct 2009 18:06:40 -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; Tue, 13 Oct 2009 18:06:35 +0000 Received: from jupiter.vmware.com (mailhost5.vmware.com [10.16.68.131]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 08703460C5; Tue, 13 Oct 2009 11:06:34 -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 F1466DC07E; Tue, 13 Oct 2009 11:06:33 -0700 (PDT) Message-ID: <4AD4C07D.20502@vmware.com> Date: Tue, 13 Oct 2009 18:06:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Hui Zhu CC: Jiang Jilin , "gdb-patches@sourceware.org" Subject: Re: [RFA] Fix off-by-one error in record.c (record_list_release_first) References: <4AD35AB6.2050903@vmware.com> <7d77a27d0910121917w4abfc09cx43e5667393ef9f79@mail.gmail.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------050403070704000909040904" 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/msg00278.txt.bz2 This is a multi-part message in MIME format. --------------050403070704000909040904 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 580 Hui Zhu wrote: > Thanks Michael and Jilin, > > I think the Michael's patch is more spend up. Jilin's patch is more > clear and can handle set_record_insn_max_num. > > I suggest we choice speed up. Do you think it's OK? > > If we choice it, Michael, could you please add some comments to > "record_list_release_first" or change it's name to > "record_list_release_first_without_update_xxx" to make it clear. > And please update set_record_insn_max_num. Hah, sorry, I completely missed the implications for set_record_insn_max_num. Thanks Jilin for catching it. New diff: --------------050403070704000909040904 Content-Type: text/plain; name="insn_num2.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="insn_num2.txt" Content-length: 1517 2009-10-12 Michael Snyder * record.c (record_list_release_first): Do not decrement record_insn_num. (set_insn_num_max): Remove printf. Decrement record_insn_num in the loop. Index: record.c =================================================================== RCS file: /cvs/src/src/gdb/record.c,v retrieving revision 1.20 diff -u -p -r1.20 record.c --- record.c 27 Sep 2009 02:49:34 -0000 1.20 +++ record.c 13 Oct 2009 18:04:44 -0000 @@ -177,6 +177,11 @@ record_list_release_next (void) } } +/* Delete the first instruction from the beginning of the log, to make + room for adding a new instruction at the end of the log. + + Note -- this function does not modify record_insn_num. */ + static void record_list_release_first (void) { @@ -209,8 +214,6 @@ record_list_release_first (void) if (type == record_end) break; } - - record_insn_num--; } /* Add a struct record_entry to record_arch_list. */ @@ -1260,12 +1263,12 @@ set_record_insn_max_num (char *args, int { if (record_insn_num > record_insn_max_num && record_insn_max_num) { - printf_unfiltered (_("Record instructions number is bigger than " - "record instructions max number. Auto delete " - "the first ones?\n")); - + /* Count down record_insn_num while releasing records from list. */ while (record_insn_num > record_insn_max_num) - record_list_release_first (); + { + record_list_release_first (); + record_insn_num--; + } } } --------------050403070704000909040904--