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

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