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

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