keiths / rpms / gdb

Forked from rpms/gdb 14 days ago
Clone
Jan Kratochvil b37d386
commit 51dab9e418741ac7065cd5a6ec9b57285e90227c
Jan Kratochvil b37d386
https://bugzilla.redhat.com/show_bug.cgi?id=738482
Jan Kratochvil b37d386
Jan Kratochvil b37d386
--- a/gdb/printcmd.c
Jan Kratochvil b37d386
+++ b/gdb/printcmd.c
Jan Kratochvil b37d386
@@ -1981,6 +1981,10 @@ print_variable_and_value (const char *name, struct symbol *var,
Jan Kratochvil b37d386
       struct value_print_options opts;
Jan Kratochvil b37d386
 
Jan Kratochvil b37d386
       val = read_var_value (var, frame);
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+      make_cleanup_restore_selected_frame ();
Jan Kratochvil b37d386
+      select_frame (frame);
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
       get_user_print_options (&opts);
Jan Kratochvil b37d386
       common_val_print (val, stream, indent, &opts, current_language);
Jan Kratochvil b37d386
     }
Jan Kratochvil b37d386
--- /dev/null
Jan Kratochvil b37d386
+++ b/gdb/testsuite/gdb.base/vla-frame.c
Jan Kratochvil b37d386
@@ -0,0 +1,31 @@
Jan Kratochvil b37d386
+/* This testcase is part of GDB, the GNU debugger.
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+   Copyright 2011 Free Software Foundation, Inc.
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+   This program is free software; you can redistribute it and/or modify
Jan Kratochvil b37d386
+   it under the terms of the GNU General Public License as published by
Jan Kratochvil b37d386
+   the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil b37d386
+   (at your option) any later version.
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+   This program is distributed in the hope that it will be useful,
Jan Kratochvil b37d386
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil b37d386
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil b37d386
+   GNU General Public License for more details.
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+   You should have received a copy of the GNU General Public License
Jan Kratochvil b37d386
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+#include <string.h>
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+int
Jan Kratochvil b37d386
+main (int argc, char **argv)
Jan Kratochvil b37d386
+{
Jan Kratochvil b37d386
+  char s[2 + argc];
Jan Kratochvil b37d386
+  void (*f) (char *) = 0;
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+  memset (s, 0, sizeof (s));
Jan Kratochvil b37d386
+  s[0] = 'X';
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+  f (s);
Jan Kratochvil b37d386
+  return 0;
Jan Kratochvil b37d386
+}
Jan Kratochvil b37d386
--- /dev/null
Jan Kratochvil b37d386
+++ b/gdb/testsuite/gdb.base/vla-frame.exp
Jan Kratochvil b37d386
@@ -0,0 +1,38 @@
Jan Kratochvil b37d386
+# Copyright 2011 Free Software Foundation, Inc.
Jan Kratochvil b37d386
+#
Jan Kratochvil b37d386
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil b37d386
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil b37d386
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil b37d386
+# (at your option) any later version.
Jan Kratochvil b37d386
+#
Jan Kratochvil b37d386
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil b37d386
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil b37d386
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil b37d386
+# GNU General Public License for more details.
Jan Kratochvil b37d386
+#
Jan Kratochvil b37d386
+# You should have received a copy of the GNU General Public License
Jan Kratochvil b37d386
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+set testfile vla-frame
Jan Kratochvil b37d386
+set executable ${testfile}
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+if { [prepare_for_testing ${testfile}.exp ${executable}] } {
Jan Kratochvil b37d386
+    return -1
Jan Kratochvil b37d386
+}
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+if ![runto_main] {
Jan Kratochvil b37d386
+    return -1
Jan Kratochvil b37d386
+}
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+set test "continue"
Jan Kratochvil b37d386
+gdb_test_multiple $test $test {
Jan Kratochvil b37d386
+    -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
Jan Kratochvil b37d386
+	pass $test
Jan Kratochvil b37d386
+    }
Jan Kratochvil b37d386
+    -re "\r\n$gdb_prompt $" {
Jan Kratochvil b37d386
+	untested ${testfile}.exp
Jan Kratochvil b37d386
+	return
Jan Kratochvil b37d386
+    }
Jan Kratochvil b37d386
+}
Jan Kratochvil b37d386
+
Jan Kratochvil b37d386
+gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"