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

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