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

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