diff --git a/gdb/Makefile.in b/gdb/Makefile.in
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
-@@ -1735,7 +1735,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
+@@ -1749,7 +1749,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force
install: all
@$(MAKE) $(FLAGS_TO_PASS) install-only
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e "$$t"` ; \
if test "x$$transformed_name" = x; then \
-@@ -1784,7 +1784,25 @@ install-guile:
+@@ -1798,7 +1798,25 @@ install-guile:
install-python:
$(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb
transformed_name=`t='$(program_transform_name)'; \
echo gdb | sed -e $$t` ; \
if test "x$$transformed_name" = x; then \
-@@ -1807,6 +1825,18 @@ uninstall: force $(CONFIG_UNINSTALL)
+@@ -1821,6 +1839,18 @@ uninstall: force $(CONFIG_UNINSTALL)
fi
@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gstack.exp
-@@ -0,0 +1,66 @@
+@@ -0,0 +1,84 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+ fail $test
+ return
+}
++
++# The spawn id of the test inferior.
++set test_spawn_id $res
++
+set use_gdb_stub 1
+set pid [exp_pid -i $res]
+gdb_expect {
+ return
+ }
+}
-+gdb_exit
+
+# Testcase uses the most simple notification not to get caught by attach on
+# exiting the function. Still we could retry the gstack command if we fail.
+ perror "Spawning $command failed."
+ fail $test
+}
-+set pid [exp_pid -i $res]
++
++set gdb_spawn_id $res
++
+gdb_test_multiple "" $test {
+ -re "^#0 +(0x\[0-9a-f\]+ in )?\\.?func \\(\\) at \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in \\.?main \\(\\) at \[^\r\n\]*\r\nGSTACK-END\r\n\$" {
+ pass $test
+ }
+}
-+gdb_exit
+
-+remote_exec host "kill -9 $pid"
++gdb_test_multiple "" "gstack exits" {
++ eof {
++ set result [wait -i $gdb_spawn_id]
++ verbose $result
++
++ gdb_assert { [lindex $result 2] == 0 } "gstack exits with no error"
++ gdb_assert { [lindex $result 3] == 0 } "gstack's exit status is 0"
++
++ remote_close host
++ clear_gdb_spawn_id
++ }
++}
++
++# Kill the test inferior.
++kill_wait_spawned_process $test_spawn_id