From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13463 invoked by alias); 1 Dec 2014 20:50:33 -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 13443 invoked by uid 89); 1 Dec 2014 20:50:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 01 Dec 2014 20:50:26 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sB1KoNpp010810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 Dec 2014 15:50:23 -0500 Received: from localhost (dhcp-10-15-16-169.yyz.redhat.com [10.15.16.169]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sB1KoNFA014153 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Mon, 1 Dec 2014 15:50:23 -0500 From: Sergio Durigan Junior To: Patrick Palka Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Append to input history file instead of overwriting it References: <1417226462-11254-1-git-send-email-patrick@parcs.ath.cx> X-URL: http://blog.sergiodj.net Date: Mon, 01 Dec 2014 20:50:00 -0000 In-Reply-To: <1417226462-11254-1-git-send-email-patrick@parcs.ath.cx> (Patrick Palka's message of "Fri, 28 Nov 2014 21:01:02 -0500") Message-ID: <87vblvxfg1.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00027.txt.bz2 On Friday, November 28 2014, Patrick Palka wrote: > This patch makes readline append new history lines to the GDB history > file on exit instead of overwriting the entire history file on exit. > This change allows us to run multiple simultaneous GDB sessions without > having each session overwrite the added history of each other session on > exit. It is particularly helpful when debugging GDB with GDB. > > Does this look OK to commit? Tested on x86_64-unknown-linux-gnu. Thanks, Patrick. The patch makes sense to me, and it is a good thing to have, I agree. > gdb/ChangeLog: > > * top.h (gdb_add_history): Declare. > * top.c (command_count): New variable. > (gdb_add_history): New function. > (quit_force): Append to history file instead of overwriting it. > (command_line_input): Use gdb_add_history instead of > add_history. > * event-top.c (command_line_handler): Likewise. > --- > gdb/event-top.c | 2 +- > gdb/top.c | 19 ++++++++++++++++--- > gdb/top.h | 2 ++ > 3 files changed, 19 insertions(+), 4 deletions(-) > > diff --git a/gdb/event-top.c b/gdb/event-top.c > index cb438ac..490bca6 100644 > --- a/gdb/event-top.c > +++ b/gdb/event-top.c > @@ -667,7 +667,7 @@ command_line_handler (char *rl) > > /* Add line to history if appropriate. */ > if (*linebuffer && input_from_terminal_p ()) > - add_history (linebuffer); > + gdb_add_history (linebuffer); > > /* Note: lines consisting solely of comments are added to the command > history. This is useful when you type a command, and then > diff --git a/gdb/top.c b/gdb/top.c > index c4b5c2c..6ec3acc 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -895,7 +895,20 @@ gdb_rl_operate_and_get_next (int count, int key) > > return rl_newline (1, key); > } > - > + > +/* Number of user commands executed during this session. */ > + > +static int command_count; You should initialize this variable. Other than that, looks good. Let's wait for a maintainer to take a look. > + > +/* Add the user command COMMAND to the input history list. */ > + > +void > +gdb_add_history (const char *command) > +{ > + add_history (command); > + command_count++; > +} > + > /* Read one line from the command input stream `instream' > into the local static buffer `linebuffer' (whose current length > is `linelength'). > @@ -1090,7 +1103,7 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix) > > /* Add line to history if appropriate. */ > if (*linebuffer && input_from_terminal_p ()) > - add_history (linebuffer); > + gdb_add_history (linebuffer); > > /* Save into global buffer if appropriate. */ > if (repeat) > @@ -1441,7 +1454,7 @@ quit_force (char *args, int from_tty) > { > if (write_history_p && history_filename > && input_from_terminal_p ()) > - write_history (history_filename); > + append_history (command_count, history_filename); > } > DO_PRINT_EX; > > diff --git a/gdb/top.h b/gdb/top.h > index 94f6c48..d8baea8 100644 > --- a/gdb/top.h > +++ b/gdb/top.h > @@ -79,6 +79,8 @@ extern int history_expansion_p; > extern int server_command; > extern char *lim_at_start; > > +extern void gdb_add_history (const char *); > + > extern void show_commands (char *args, int from_tty); > > extern void set_history (char *, int); > -- > 2.2.0.rc1.23.gf570943 -- Sergio GPG key ID: 0x65FC5E36 Please send encrypted e-mail if possible http://sergiodj.net/