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

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