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

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