Blame SOURCES/gdb-vla-intel-stringbt-fix.patch

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