From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2057 invoked by alias); 8 Sep 2009 20:05:54 -0000 Received: (qmail 1828 invoked by uid 22791); 8 Sep 2009 20:05:51 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_37,J_CHICKENPOX_42,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Sep 2009 20:05:44 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n88K5gJk008437; Tue, 8 Sep 2009 16:05:42 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n88K5dgH002298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 8 Sep 2009 16:05:41 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n88K5dMc015401; Tue, 8 Sep 2009 22:05:39 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id n88K5bHg015397; Tue, 8 Sep 2009 22:05:37 +0200 Date: Tue, 08 Sep 2009 20:05:00 -0000 From: Jan Kratochvil To: gdb@sourceware.org Cc: gdb-patches@sourceware.org Subject: [patch] Save the history by default Message-ID: <20090908200537.GA14676@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) 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-09/txt/msg00221.txt.bz2 Hi, as 7.0 is close I hope this FAQ item fix can pass flawlessly: #gdb@irc.freenode.net: (2008-06-10 00:23:22) matthewf: is there a way to have my gdb session history preserved? (2008-06-10 00:23:49) matthewf: so that I can quit a gdb session, start a new one, and press up arrow to see my previous commands? (2009-05-15 12:58:19) Guest75615: is the a way to display the gdb command history? (2009-05-15 13:22:47) Guest75615 left the room. (2009-05-15 19:54:46) Bircoph: hello, all; is there any way to save gdb CLI history, so after restarting gdb I'll have all it available? The attached patch breaks backward compatibility with reading project's specific ./.gdb_history files. I believe if someone is using such files (me not) (s)he can add there appropriate `set history filename' to local `.gdbinit' there. Tried a patch defaulting to ./.gdb_history and falling back to $HOME/.gdb_history but I find it needlessly tricky. Experienced user can set it straightforward way according to the needs, just the default should IMO cover the major user base. Following bash'es default of ~/.gdb_history or the readline's default of ~/.history. These GNU projects also do not use ./*history files by default. Another related change is to save the history by default. I find already inconsistent that history is being read by default but not written by default. No regressions on {x86_64,i686}-fedora11-linux-gnu. Thanks, Jan gdb/ 2009-09-08 Jan Kratochvil Save the command history by default and use a file in $HOME. * NEWS: New note on the history file defaults change. * top.c (init_history): Remove using current_directory. New initialization of history_filename from $HOME. (init_main): Initialize write_history_p by 1. gdb/doc/ 2009-09-08 Jan Kratochvil * gdb.texinfo (set history filename @var{fname}): Use $HOME there. (set history save): The default is now enabled. --- a/gdb/NEWS +++ b/gdb/NEWS @@ -81,6 +81,8 @@ registers on ARM targets. Both ARM GNU/Linux native GDB and gdbserver can provide these registers (requires Linux 2.6.30 or later). Remote and simulator targets may also provide them. +* GDB now defaults to save the command history and using a file in $HOME. + * New remote packets qSearch:memory: --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -17722,15 +17722,15 @@ list, and where it writes the command history from this session when it exits. You can access this list through history expansion or through the history command editing characters listed below. This file defaults to the value of the environment variable @code{GDBHISTFILE}, or to -@file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable -is not set. +@file{$HOME/.gdb_history} (@file{$HOME/_gdb_history} on MS-DOS) if this +variable is not set. @cindex save command history @kindex set history save @item set history save @itemx set history save on Record command history in a file, whose name may be specified with the -@code{set history filename} command. By default, this option is disabled. +@code{set history filename} command. By default, this option is enabled. @item set history save off Stop recording command history in a file. --- a/gdb/top.c +++ b/gdb/top.c @@ -1495,17 +1495,16 @@ init_history (void) history_filename = xstrdup (tmpenv); else if (!history_filename) { - /* We include the current directory so that if the user changes - directories the file written will be the same as the one - that was read. */ + const char *homedir = getenv ("HOME"); #ifdef __MSDOS__ /* No leading dots in file names are allowed on MSDOS. */ - history_filename = concat (current_directory, "/_gdb_history", - (char *)NULL); + const char append[] = "/_gdb_history"; #else - history_filename = concat (current_directory, "/.gdb_history", - (char *)NULL); + const char append[] = "/.gdb_history"; #endif + + if (homedir) + history_filename = concat (homedir, append, (char *) NULL); } read_history (history_filename); } @@ -1567,7 +1566,7 @@ init_main (void) /* Set the important stuff up for command editing. */ command_editing_p = 1; history_expansion_p = 0; - write_history_p = 0; + write_history_p = 1; /* Setup important stuff for command line editing. */ rl_completion_word_break_hook = gdb_completion_word_break_characters;