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

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