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

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