From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128616 invoked by alias); 26 Jun 2015 14:30:27 -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 128605 invoked by uid 89); 26 Jun 2015 14:30:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 26 Jun 2015 14:30:26 +0000 Received: by oigb199 with SMTP id b199so76530954oig.3 for ; Fri, 26 Jun 2015 07:30:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=QwoGVFqRx4FPdWzF8r1IJTHwCSPbjgR3X0EgICOi7qU=; b=POhoAuxDtqDfVKdFFTCnnmHGyZSLtba1vPMPtXWoXXKkQgYEYGjyw4zmzmdO93R3nx tVNMwUZH/zfUif8kTcbwi+gBHDg8BIAZ/2s3dGGF6+l43Pqa13T5gsc8n0gZmcO7hfdc o93xYt4+DH7ab2Npiy4uYl3skD3OZPA43a/H+AxktCeFavr3QlCj14l406La4oA+hHRG bSUmSgbtSBNUWcfdx+mvRel3SH5TaupBYzKlI0p+RZL4pREWgK32djj01yQfwJtdf7Lq QevZc2PKyuuWWEoKxmOh1pPnlGD0CKMeFvxGwF6SkX9F8Su4q3f+fZPT0kfQXHei9HTB vRuA== X-Gm-Message-State: ALoCoQnXsN17hHzjPNG5aC0EE4sji2xoEse4/OK/IengaSUWbeuwyQup2TwlxGhrbMTaLefuJqEn X-Received: by 10.60.69.7 with SMTP id a7mr1735855oeu.14.1435329024187; Fri, 26 Jun 2015 07:30:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.96.167 with HTTP; Fri, 26 Jun 2015 07:30:04 -0700 (PDT) In-Reply-To: <558D5F26.4040401@redhat.com> References: <5578539E.1020806@redhat.com> <1434756821-7423-1-git-send-email-patrick@parcs.ath.cx> <558D5F26.4040401@redhat.com> From: Patrick Palka Date: Fri, 26 Jun 2015 14:30:00 -0000 Message-ID: Subject: Re: [PATCH] Add option to remove duplicate command history entries To: Pedro Alves Cc: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-06/txt/msg00575.txt.bz2 On Fri, Jun 26, 2015 at 10:18 AM, Pedro Alves wrote: > On 06/20/2015 12:33 AM, Patrick Palka wrote: > >> index c9a532a..c5885eb 100644 >> --- a/gdb/doc/gdb.texinfo >> +++ b/gdb/doc/gdb.texinfo >> @@ -22644,6 +22644,21 @@ to 256 if this variable is not set. Non-numeric values of @env{GDBHISTSIZE} >> are ignored. If @var{size} is @code{unlimited} or if @env{GDBHISTSIZE} is >> either a negative number or the empty string, then the number of commands >> @value{GDBN} keeps in the history list is unlimited. >> + >> +@cindex remove duplicate history >> +@kindex set history remove-duplicates >> +@item set history remove-duplicates @var{size} >> +@itemx set history remove-duplicates unlimited >> +Control the removal of duplicate history entries in the command history list. >> +If @var{size} is non-zero, @value{GDBN} will look back at the last @var{size} > > Somehow, "size" here sounds a bit confusing to me. This not about > that size of the duplicates. :-) And it's not about when the history > gets to a certain size either. I'd suggest s/size/count/, or s/size/lookbehind/ > or some such. Ah yeah, I had already changed that variable name locally to "count". > >> +history entries and remove the first entry that is a duplicate of the current >> +entry being added to the command history list. If @var{size} is >> +@code{unlimited} then this lookbehind is unbounded. If @var{size} is 0, then >> +removal of duplicate history entries is disabled. >> + >> +Only history entries added during the current session are considered for >> +removal. This option is set to 0 by default. >> + > > > >> +proc check_prev_history_entry { entry { test_suffix "" } } { >> + set test "history entry is $entry" >> + if { $test_suffix != "" } { >> + append test " $test_suffix" >> + } >> + >> + # Send ^P followed by ^L. >> + send_gdb "\x10\x0c" > > I have a feeling this may cause problems, but we'll see. Hopefully not because I copied this "technique" of traversing through history from readline.exp. I considered using looking at the output of "show commands" but doing ^P seems easier and more directly tests the code paths we want to test. > >> + >> + gdb_expect { >> + -re $entry { >> + pass $test >> + } >> + timeout { >> + fail $test >> + } >> + } >> +} >> + >> +# By default the option is set to 0. >> +gdb_exit >> +gdb_start >> +gdb_test "show history remove-duplicates" "is 0\\." >> + >> +# Test the "unlimited" setting. >> +with_test_prefix "remove-duplicates=unlimited" { >> + gdb_exit >> + gdb_start >> + gdb_test "set history remove-duplicates unlimited" >> + >> + gdb_test "print 0" >> + gdb_test "print 1" >> + gdb_test "print 2" >> + gdb_test "print 1" >> + gdb_test "print 1" >> + gdb_test "print 2" >> + gdb_test "print 3" >> + gdb_test "print 3" >> + gdb_test "print 4" >> + gdb_test "print 1" >> + gdb_test "print 2" >> + gdb_test "print 3" >> + gdb_test "print 4" > > Duplicate test names here. This should catch all: I could use some kind of loop over a list here I think, prefixing each test name with the index of the list. > > $ make check RUNTESTFLAGS="history-duplicates.exp" > $ grep "PASS" testsuite/gdb.sum | sort | uniq -c | sort -n > > Otherwise this looks good to me. Thanks a lot for reviewing! > > Thanks, > Pedro Alves >