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