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 0300a2e
--- ./gdb/dwarf2loc.c	2016-08-29 04:01:25.000000000 +0200
Jan Kratochvil 0300a2e
+++ ./gdb/dwarf2loc.c	2016-09-01 11:00:20.258909494 +0200
Jan Kratochvil 0300a2e
@@ -2289,6 +2289,15 @@ const struct dwarf_expr_context_funcs dw
Jan Kratochvil 0300a2e
   dwarf_expr_get_obj_addr
Jan Kratochvil 0300a2e
 };
Jan Kratochvil 0300a2e
 
Jan Kratochvil 0300a2e
+static void
Jan Kratochvil 0300a2e
+select_frame_cleanup (void *arg)
Jan Kratochvil 0300a2e
+{
Jan Kratochvil 0300a2e
+  struct frame_info *frame = (struct frame_info *) arg;
Jan Kratochvil 0300a2e
+
Jan Kratochvil 0300a2e
+  if (frame != NULL)
Jan Kratochvil 0300a2e
+    select_frame (frame);
Jan Kratochvil 0300a2e
+}
Jan Kratochvil 0300a2e
+
Jan Kratochvil 0300a2e
 /* Evaluate a location description, starting at DATA and with length
Jan Kratochvil 0300a2e
    SIZE, to find the current location of variable of TYPE in the
Jan Kratochvil 0300a2e
    context of FRAME.  BYTE_OFFSET is applied after the contents are
Jan Kratochvil 0300a2e
@@ -2318,6 +2327,11 @@ dwarf2_evaluate_loc_desc_full (struct ty
Jan Kratochvil 0300a2e
 
Jan Kratochvil 0300a2e
   ctx = new_dwarf_expr_context ();
Jan Kratochvil 0300a2e
   old_chain = make_cleanup_free_dwarf_expr_context (ctx);
Jan Kratochvil 0300a2e
+
Jan Kratochvil 0300a2e
+  make_cleanup (select_frame_cleanup, deprecated_safe_get_selected_frame ());
Jan Kratochvil 0300a2e
+  if (frame != NULL)
Jan Kratochvil 0300a2e
+    select_frame (frame);
Jan Kratochvil 0300a2e
+
Jan Kratochvil 0300a2e
   value_chain = make_cleanup_value_free_to_mark (value_mark ());
Jan Kratochvil 0300a2e
 
Jan Kratochvil 0300a2e
   ctx->gdbarch = get_objfile_arch (objfile);
Jan Kratochvil 32f92b2
Index: gdb-7.9.50.20150520/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 32f92b2
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90	2015-05-31 16:14:05.844545344 +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 32f92b2
Index: gdb-7.9.50.20150520/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 32f92b2
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp	2015-05-31 16:14:05.845545351 +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 32f92b2
Index: gdb-7.9.50.20150520/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 32f92b2
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90	2015-05-31 16:14:05.845545351 +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