This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Fix PR gdb/21954: make 'unset environment' work again
- From: Sergio Durigan Junior <sergiodj at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 15 Aug 2017 17:54:27 -0000
- Subject: [binutils-gdb] Fix PR gdb/21954: make 'unset environment' work again
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=206726fbfdd521fbb184daedb71b85030453bf0b
commit 206726fbfdd521fbb184daedb71b85030453bf0b
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Tue Aug 15 13:49:18 2017 -0400
Fix PR gdb/21954: make 'unset environment' work again
When I made commit 9a6c7d9c021cfeb290d76584db7a01e57e7c3d4e, which
C++-fied gdb/common/environ.[ch], I mistakenly altered the behaviour
of the 'unset environment' command. This command, which should delete
all environment variables, is now resetting the list of variables to
the state they were when GDB was started.
This commit fixes this regression, and also adds a test on
gdb.base/environ.exp which really checks if 'unset environment'
worked.
gdb/ChangeLog:
2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/21954
* infcmd.c (unset_environment_command): Use the 'clear' method on
the environment instead of resetting it.
gdb/testsuite/ChangeLog:
2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
PR gdb/21954
* gdb.base/environ.exp: Add test to check if 'unset environment'
works.
Diff:
---
gdb/ChangeLog | 6 ++++++
gdb/infcmd.c | 2 +-
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.base/environ.exp | 3 +++
4 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fbf14dd..94155f5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR gdb/21954
+ * infcmd.c (unset_environment_command): Use the 'clear' method on
+ the environment instead of resetting it.
+
2017-08-15 John Baldwin <jhb@FreeBSD.org>
* fbsd-nat.c (fbsd_convert_siginfo): Fix compile on big-endian
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index defa7b0..c8a82db 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2230,7 +2230,7 @@ unset_environment_command (char *var, int from_tty)
/* If there is no argument, delete all environment variables.
Ask for confirmation if reading from the terminal. */
if (!from_tty || query (_("Delete all environment variables? ")))
- current_inferior ()->environment = gdb_environ::from_host_environ ();
+ current_inferior ()->environment.clear ();
}
else
current_inferior ()->environment.unset (var);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index f9494af..39c49b8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR gdb/21954
+ * gdb.base/environ.exp: Add test to check if 'unset environment'
+ works.
+
2017-08-14 Andreas Arnez <arnez@linux.vnet.ibm.com>
* lib/gdb.exp (universal_compile_options): New caching proc.
diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp
index 0b69a80..bb52063 100644
--- a/gdb/testsuite/gdb.base/environ.exp
+++ b/gdb/testsuite/gdb.base/environ.exp
@@ -46,6 +46,9 @@ gdb_test "unset environment" "" "unset all environment variables" \
"Delete all environment variables. .y or n. $" \
"y"
+gdb_test_no_output "show environment" \
+ "all environment variables have been unset"
+
# Verify that we can set a specific environment variable.
test_set_show_env_var "EDITOR" "emacs" "set environment variable"