66631b1
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
66631b1
From: Jan Kratochvil <jan.kratochvil@redhat.com>
66631b1
Date: Fri, 1 Aug 2014 23:02:17 +0200
575318a
Subject: gdb-vla-intel-stringbt-fix.patch
66631b1
66631b1
;;=push+jan
66631b1
66631b1
http://sourceware.org/ml/gdb-patches/2014-08/msg00025.html
66631b1
66631b1
On Fri, 01 Aug 2014 09:20:19 +0200, Keven Boell wrote:
66631b1
> I just tried it on Fedora 20 i686.  Applied the patch, you mentioned, on top of
66631b1
> the Fortran VLA series and executed your dynamic-other-frame test.  Everything
66631b1
> is working fine here, I cannot reproduce the crash.
66631b1
66631b1
I have it reproducible on Fedora 20 i686 with plain
66631b1
CFLAGS=-g ./configure;make;cd gdb/testsuite;make site.exp;runtest gdb.fortran/dynamic-other-frame.exp
66631b1
66631b1
Besides that I have updated the testcase with
66631b1
	gdb_test_no_output "set print frame-arguments all"
66631b1
so that there is no longer needed the patch:
66631b1
	[patch] Display Fortran strings in backtraces
66631b1
	https://sourceware.org/ml/gdb-patches/2014-07/msg00709.html
66631b1
66631b1
The fix below has no regressions for me.  Unfortunately I do not see why you
66631b1
cannot reproduce it.
66631b1
66631b1
Thanks,
66631b1
Jan
66631b1
66631b1
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
66631b1
--- a/gdb/dwarf2loc.c
66631b1
+++ b/gdb/dwarf2loc.c
2c41ca0
@@ -2154,6 +2154,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
277df3b
   ctx.per_cu = per_cu;
277df3b
   ctx.obj_address = 0;
Patrick Monnerat 648e801
 
66631b1
+frame_id old_frame_id (get_frame_id (deprecated_safe_get_selected_frame ()));
277df3b
+class RestoreCall {
277df3b
+private:
277df3b
+  const std::function<void ()> func;
277df3b
+public:
277df3b
+  RestoreCall(std::function<void ()> func_):func(func_) {}
277df3b
+  ~RestoreCall() { func(); }
66631b1
+} restore_frame([=]() {
66631b1
+  frame_info *old_frame (frame_find_by_id (old_frame_id));
66631b1
+  if (old_frame != NULL)
66631b1
+    select_frame (old_frame);
277df3b
+});
277df3b
+if (frame != NULL) select_frame (frame);
Patrick Monnerat 648e801
+
277df3b
   scoped_value_mark free_values;
277df3b
 
277df3b
   ctx.gdbarch = get_objfile_arch (objfile);
66631b1
diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
66631b1
new file mode 100644
66631b1
--- /dev/null
66631b1
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
66631b1
@@ -0,0 +1,24 @@
66631b1
+! Copyright 2010 Free Software Foundation, Inc.
66631b1
+!
66631b1
+! This program is free software; you can redistribute it and/or modify
66631b1
+! it under the terms of the GNU General Public License as published by
66631b1
+! the Free Software Foundation; either version 2 of the License, or
66631b1
+! (at your option) any later version.
66631b1
+!
66631b1
+! This program is distributed in the hope that it will be useful,
66631b1
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
66631b1
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
66631b1
+! GNU General Public License for more details.
66631b1
+!
66631b1
+! You should have received a copy of the GNU General Public License
66631b1
+! along with this program; if not, write to the Free Software
66631b1
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
66631b1
+!
66631b1
+! Ihis file is the Fortran source file for dynamic.exp.
66631b1
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
66631b1
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
66631b1
+
66631b1
+subroutine bar
66631b1
+  real :: dummy
66631b1
+  dummy = 1
66631b1
+end subroutine bar
66631b1
diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
66631b1
new file mode 100644
66631b1
--- /dev/null
66631b1
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
Patrick Monnerat 648e801
@@ -0,0 +1,39 @@
Patrick Monnerat 648e801
+# Copyright 2010 Free Software Foundation, Inc.
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+# This program is free software; you can redistribute it and/or modify
Patrick Monnerat 648e801
+# it under the terms of the GNU General Public License as published by
Patrick Monnerat 648e801
+# the Free Software Foundation; either version 2 of the License, or
Patrick Monnerat 648e801
+# (at your option) any later version.
Patrick Monnerat 648e801
+# 
Patrick Monnerat 648e801
+# This program is distributed in the hope that it will be useful,
Patrick Monnerat 648e801
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Patrick Monnerat 648e801
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Patrick Monnerat 648e801
+# GNU General Public License for more details.
Patrick Monnerat 648e801
+# 
Patrick Monnerat 648e801
+# You should have received a copy of the GNU General Public License
Patrick Monnerat 648e801
+# along with this program; if not, write to the Free Software
Patrick Monnerat 648e801
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+set testfile "dynamic-other-frame"
Patrick Monnerat 648e801
+set srcfile1 ${testfile}.f90
Patrick Monnerat 648e801
+set srcfile2 ${testfile}-stub.f90
Patrick Monnerat 648e801
+set objfile2 [standard_output_file ${testfile}-stub.o]
Patrick Monnerat 648e801
+set executable ${testfile}
Patrick Monnerat 648e801
+set binfile [standard_output_file ${executable}]
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != ""
Patrick Monnerat 648e801
+     || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } {
Patrick Monnerat 648e801
+    untested "Couldn't compile ${srcfile1} or ${srcfile2}"
Patrick Monnerat 648e801
+    return -1
Patrick Monnerat 648e801
+}
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+clean_restart ${executable}
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+gdb_test_no_output "set print frame-arguments all"
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+if ![runto bar_] then {
Patrick Monnerat 648e801
+    perror "couldn't run to bar_"
Patrick Monnerat 648e801
+    continue
Patrick Monnerat 648e801
+}
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+gdb_test "bt" {foo \(string='hello'.*}
66631b1
diff --git a/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90 b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
66631b1
new file mode 100644
66631b1
--- /dev/null
66631b1
+++ b/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
Patrick Monnerat 648e801
@@ -0,0 +1,36 @@
Patrick Monnerat 648e801
+! Copyright 2010 Free Software Foundation, Inc.
Patrick Monnerat 648e801
+!
Patrick Monnerat 648e801
+! This program is free software; you can redistribute it and/or modify
Patrick Monnerat 648e801
+! it under the terms of the GNU General Public License as published by
Patrick Monnerat 648e801
+! the Free Software Foundation; either version 2 of the License, or
Patrick Monnerat 648e801
+! (at your option) any later version.
Patrick Monnerat 648e801
+!
Patrick Monnerat 648e801
+! This program is distributed in the hope that it will be useful,
Patrick Monnerat 648e801
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Patrick Monnerat 648e801
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Patrick Monnerat 648e801
+! GNU General Public License for more details.
Patrick Monnerat 648e801
+!
Patrick Monnerat 648e801
+! You should have received a copy of the GNU General Public License
Patrick Monnerat 648e801
+! along with this program; if not, write to the Free Software
Patrick Monnerat 648e801
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Patrick Monnerat 648e801
+!
Patrick Monnerat 648e801
+! Ihis file is the Fortran source file for dynamic.exp.
Patrick Monnerat 648e801
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
Patrick Monnerat 648e801
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
Patrick Monnerat 648e801
+
Patrick Monnerat 648e801
+subroutine foo (string)
Patrick Monnerat 648e801
+  interface
Patrick Monnerat 648e801
+    subroutine bar
Patrick Monnerat 648e801
+    end subroutine
Patrick Monnerat 648e801
+  end interface
Patrick Monnerat 648e801
+  character string*(*)
Patrick Monnerat 648e801
+  call bar                                ! stop-here
Patrick Monnerat 648e801
+end subroutine foo
Patrick Monnerat 648e801
+program test
Patrick Monnerat 648e801
+  interface
Patrick Monnerat 648e801
+    subroutine foo (string)
Patrick Monnerat 648e801
+    character string*(*)
Patrick Monnerat 648e801
+    end subroutine
Patrick Monnerat 648e801
+  end interface
Patrick Monnerat 648e801
+  call foo ('hello')
Patrick Monnerat 648e801
+end