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

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