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

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