From patchwork Fri May 22 11:23:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 6887 Received: (qmail 113445 invoked by alias); 22 May 2015 11:24:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 113421 invoked by uid 89); 22 May 2015 11:24:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 22 May 2015 11:24:03 +0000 Received: by qkx62 with SMTP id 62so9016123qkx.3 for ; Fri, 22 May 2015 04:24:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8DMlNc0kvgSCyFWqq9WzphDU50J3pDrrOX3ZMV1jl4E=; b=ILdEpTRie9JSZBrJeQ/GgCgf/fCyLsaa1gJ+1W2LKO2Nimk8u1eMBzc1HtM/hq/k2I CEM4bdxxbri+9KCrjpMfKAzUHkfZRu5/ErD5z5FI+v31L+F8FkPmG32xde+fMRgBcqP4 zRaXKIX4La5WvbotWq7EbqwBEXHhNEpinZoCRr0L4EI/TtSzKTWaJE4oQwRKzHb/9FS1 Ef96ZjSwv1xzonhsaxfyjyQRjT2jeertPGCgH8UW72QeQpVw24/srRxjc3wiexoDXa8b PSpH9Fa7y4mAy6VEYBcBD9/NfbIWUercE1wCY1u0RzHQM3o/c8F5B0CnAVStwgz078pW frpg== X-Gm-Message-State: ALoCoQmN/cCXbjFaXZ/oh0tbFyNKI8uC8XpRpUTXd2sxiI7lhOwC4gGrmeMPb2Tat8yFssNbxuhQ X-Received: by 10.55.24.18 with SMTP id j18mr7624790qkh.60.1432293840673; Fri, 22 May 2015 04:24:00 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by mx.google.com with ESMTPSA id l200sm1083267qhl.24.2015.05.22.04.23.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 May 2015 04:24:00 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH 1/2] Read $GDBHISTSIZE instead of $HISTSIZE Date: Fri, 22 May 2015 07:23:50 -0400 Message-Id: <1432293831-23599-1-git-send-email-patrick@parcs.ath.cx> The HISTSIZE environment variable is generally expected to be read by shells, not by applications. Some distros for example globally export HISTSIZE in /etc/profile -- with the intention that it only affects shells -- and by doing so it renders useless GDB's own mechanism for setting the history size via .gdbinit. Also, annoyances may arise when HISTSIZE is not interpreted the same way by the shell and by GDB, e.g. PR gdb/16999. That can always be fixed on a shell-by-shell basis but it may be impossible to be consistent with the behavior of all shells at once. Finally it just makes sense to not confound shell environment variables with application environment variables. gdb/ChangeLog: * NEWS: Add entry. * top.c (init_history): Read from GDBHISTSIZE instead of HISTSIZE. (init_main): Refer to GDBHISTSIZE instead of HISTSIZE. gdb/doc/ChangeLog: * gdb.texinfo (Command History): Replace occurrences of HISTSIZE with GDBHISTSIZE. gdb/testsuite/ChangeLog: * gdb.base/gdbinit-history.exp: Replace occurrences of HISTSIZE with GDBHISTSIZE. * gdb.base/readline.exp: Likewis. --- gdb/NEWS | 4 ++++ gdb/doc/gdb.texinfo | 4 ++-- gdb/testsuite/gdb.base/gdbinit-history.exp | 4 ++-- gdb/testsuite/gdb.base/readline.exp | 12 ++++++------ gdb/top.c | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 745444b..1be239f 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -48,6 +48,10 @@ * GDB now supports the vector ABI on S/390 GNU/Linux targets. +* The HISTSIZE environment variable is no longer read when determining + the size of GDB's command history. GDB now instead reads the dedicated + GDBHISTSIZE environment variable. + * Guile Scripting ** Memory ports can now be unbuffered. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e38fd31..c21a312 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22599,12 +22599,12 @@ Stop recording command history in a file. @cindex history size @kindex set history size -@cindex @env{HISTSIZE}, environment variable +@cindex @env{GDBHISTSIZE}, environment variable @item set history size @var{size} @itemx set history size unlimited Set the number of commands which @value{GDBN} keeps in its history list. This defaults to the value of the environment variable -@code{HISTSIZE}, or to 256 if this variable is not set. If @var{size} +@code{GDBHISTSIZE}, or to 256 if this variable is not set. If @var{size} is @code{unlimited}, the number of commands @value{GDBN} keeps in the history list is unlimited. @end table diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp index 8adfd68..cbd965a 100644 --- a/gdb/testsuite/gdb.base/gdbinit-history.exp +++ b/gdb/testsuite/gdb.base/gdbinit-history.exp @@ -31,10 +31,10 @@ proc test_gdbinit_history_setting { home size } { set env(HOME) "$srcdir/$subdir/$home" - # The HISTSIZE environment variable takes precedence over whatever + # The GDBHISTSIZE environment variable takes precedence over whatever # history size is set in .gdbinit. Make sure the former is not # set. - unset -nocomplain env(HISTSIZE) + unset -nocomplain env(GDBHISTSIZE) set saved_internal_gdbflags $INTERNAL_GDBFLAGS set INTERNAL_GDBFLAGS [string map {"-nx" ""} $INTERNAL_GDBFLAGS] diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp index c444285..f0490a2 100644 --- a/gdb/testsuite/gdb.base/readline.exp +++ b/gdb/testsuite/gdb.base/readline.exp @@ -185,11 +185,11 @@ gdb_test_multiple "if 1 > 0\n\033\[A\033\[A\nend" $msg { if [info exists env(GDBHISTFILE)] { set old_gdbhistfile $env(GDBHISTFILE) } -if [info exists env(HISTSIZE)] { - set old_histsize $env(HISTSIZE) +if [info exists env(GDBHISTSIZE)] { + set old_gdbhistsize $env(GDBHISTSIZE) } set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history" -set env(HISTSIZE) "10" +set env(GDBHISTSIZE) "10" gdb_exit gdb_start @@ -207,10 +207,10 @@ if [info exists old_gdbhistfile] { } else { unset env(GDBHISTFILE) } -if [info exists old_histsize] { - set env(HISTSIZE) $old_histsize +if [info exists old_gdbhistsize] { + set env(GDBHISTSIZE) $old_gdbhistsize } else { - unset env(HISTSIZE) + unset env(GDBHISTSIZE) } set timeout $oldtimeout1 diff --git a/gdb/top.c b/gdb/top.c index 74e1e07..6f0421d 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1680,7 +1680,7 @@ init_history (void) { char *tmpenv; - tmpenv = getenv ("HISTSIZE"); + tmpenv = getenv ("GDBHISTSIZE"); if (tmpenv) { int var; @@ -1856,7 +1856,7 @@ Show the size of the command history,"), _("\ ie. the number of previous commands to keep a record of.\n\ If set to \"unlimited\", the number of commands kept in the history\n\ list is unlimited. This defaults to the value of the environment\n\ -variable \"HISTSIZE\", or to 256 if this variable is not set."), +variable \"GDBHISTSIZE\", or to 256 if this variable is not set."), set_history_size_command, show_history_size, &sethistlist, &showhistlist);