191ccfb
http://sourceware.org/ml/gdb-patches/2014-08/msg00025.html
191ccfb
Subject: [patch 1/2] Re: Crash regression(?) printing Fortran strings in bt  [Re: [V2 00/23] Fortran dynamic array support]
191ccfb
191ccfb
191ccfb
--FCuugMFkClbJLl1L
191ccfb
Content-Type: text/plain; charset=us-ascii
191ccfb
Content-Disposition: inline
191ccfb
191ccfb
On Fri, 01 Aug 2014 09:20:19 +0200, Keven Boell wrote:
191ccfb
> I just tried it on Fedora 20 i686.  Applied the patch, you mentioned, on top of
191ccfb
> the Fortran VLA series and executed your dynamic-other-frame test.  Everything
191ccfb
> is working fine here, I cannot reproduce the crash.
191ccfb
191ccfb
I have it reproducible on Fedora 20 i686 with plain
191ccfb
CFLAGS=-g ./configure;make;cd gdb/testsuite;make site.exp;runtest gdb.fortran/dynamic-other-frame.exp
191ccfb
191ccfb
Besides that I have updated the testcase with
191ccfb
	gdb_test_no_output "set print frame-arguments all"
191ccfb
so that there is no longer needed the patch:
191ccfb
	[patch] Display Fortran strings in backtraces
191ccfb
	https://sourceware.org/ml/gdb-patches/2014-07/msg00709.html
191ccfb
191ccfb
The fix below has no regressions for me.  Unfortunately I do not see why you
191ccfb
cannot reproduce it.
191ccfb
191ccfb
191ccfb
Thanks,
191ccfb
Jan
191ccfb
0300a2e
--- ./gdb/dwarf2loc.c	2016-08-29 04:01:25.000000000 +0200
0300a2e
+++ ./gdb/dwarf2loc.c	2016-09-01 11:00:20.258909494 +0200
0300a2e
@@ -2289,6 +2289,15 @@ const struct dwarf_expr_context_funcs dw
0300a2e
   dwarf_expr_get_obj_addr
0300a2e
 };
0300a2e
 
0300a2e
+static void
0300a2e
+select_frame_cleanup (void *arg)
0300a2e
+{
0300a2e
+  struct frame_info *frame = (struct frame_info *) arg;
0300a2e
+
0300a2e
+  if (frame != NULL)
0300a2e
+    select_frame (frame);
0300a2e
+}
0300a2e
+
0300a2e
 /* Evaluate a location description, starting at DATA and with length
0300a2e
    SIZE, to find the current location of variable of TYPE in the
0300a2e
    context of FRAME.  BYTE_OFFSET is applied after the contents are
0300a2e
@@ -2318,6 +2327,11 @@ dwarf2_evaluate_loc_desc_full (struct ty
0300a2e
 
0300a2e
   ctx = new_dwarf_expr_context ();
0300a2e
   old_chain = make_cleanup_free_dwarf_expr_context (ctx);
0300a2e
+
0300a2e
+  make_cleanup (select_frame_cleanup, deprecated_safe_get_selected_frame ());
0300a2e
+  if (frame != NULL)
0300a2e
+    select_frame (frame);
0300a2e
+
0300a2e
   value_chain = make_cleanup_value_free_to_mark (value_mark ());
0300a2e
 
0300a2e
   ctx->gdbarch = get_objfile_arch (objfile);
32f92b2
Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
2f7f533
===================================================================
2f7f533
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
32f92b2
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90	2015-05-31 16:14:05.844545344 +0200
191ccfb
@@ -0,0 +1,24 @@
191ccfb
+! Copyright 2010 Free Software Foundation, Inc.
191ccfb
+!
191ccfb
+! This program is free software; you can redistribute it and/or modify
191ccfb
+! it under the terms of the GNU General Public License as published by
191ccfb
+! the Free Software Foundation; either version 2 of the License, or
191ccfb
+! (at your option) any later version.
191ccfb
+!
191ccfb
+! This program is distributed in the hope that it will be useful,
191ccfb
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
191ccfb
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
191ccfb
+! GNU General Public License for more details.
191ccfb
+!
191ccfb
+! You should have received a copy of the GNU General Public License
191ccfb
+! along with this program; if not, write to the Free Software
191ccfb
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
191ccfb
+!
191ccfb
+! Ihis file is the Fortran source file for dynamic.exp.
191ccfb
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
191ccfb
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
191ccfb
+
191ccfb
+subroutine bar
191ccfb
+  real :: dummy
191ccfb
+  dummy = 1
191ccfb
+end subroutine bar
32f92b2
Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
2f7f533
===================================================================
2f7f533
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
32f92b2
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp	2015-05-31 16:14:05.845545351 +0200
191ccfb
@@ -0,0 +1,39 @@
191ccfb
+# Copyright 2010 Free Software Foundation, Inc.
191ccfb
+
191ccfb
+# This program is free software; you can redistribute it and/or modify
191ccfb
+# it under the terms of the GNU General Public License as published by
191ccfb
+# the Free Software Foundation; either version 2 of the License, or
191ccfb
+# (at your option) any later version.
191ccfb
+# 
191ccfb
+# This program is distributed in the hope that it will be useful,
191ccfb
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
191ccfb
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
191ccfb
+# GNU General Public License for more details.
191ccfb
+# 
191ccfb
+# You should have received a copy of the GNU General Public License
191ccfb
+# along with this program; if not, write to the Free Software
191ccfb
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
191ccfb
+
191ccfb
+set testfile "dynamic-other-frame"
191ccfb
+set srcfile1 ${testfile}.f90
191ccfb
+set srcfile2 ${testfile}-stub.f90
191ccfb
+set objfile2 [standard_output_file ${testfile}-stub.o]
191ccfb
+set executable ${testfile}
191ccfb
+set binfile [standard_output_file ${executable}]
191ccfb
+
191ccfb
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f90}] != ""
191ccfb
+     || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f90}] != "" } {
191ccfb
+    untested "Couldn't compile ${srcfile1} or ${srcfile2}"
191ccfb
+    return -1
191ccfb
+}
191ccfb
+
191ccfb
+clean_restart ${executable}
191ccfb
+
191ccfb
+gdb_test_no_output "set print frame-arguments all"
191ccfb
+
191ccfb
+if ![runto bar_] then {
191ccfb
+    perror "couldn't run to bar_"
191ccfb
+    continue
191ccfb
+}
191ccfb
+
191ccfb
+gdb_test "bt" {foo \(string='hello'.*}
32f92b2
Index: gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
2f7f533
===================================================================
2f7f533
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
32f92b2
+++ gdb-7.9.50.20150520/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90	2015-05-31 16:14:05.845545351 +0200
191ccfb
@@ -0,0 +1,36 @@
191ccfb
+! Copyright 2010 Free Software Foundation, Inc.
191ccfb
+!
191ccfb
+! This program is free software; you can redistribute it and/or modify
191ccfb
+! it under the terms of the GNU General Public License as published by
191ccfb
+! the Free Software Foundation; either version 2 of the License, or
191ccfb
+! (at your option) any later version.
191ccfb
+!
191ccfb
+! This program is distributed in the hope that it will be useful,
191ccfb
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
191ccfb
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
191ccfb
+! GNU General Public License for more details.
191ccfb
+!
191ccfb
+! You should have received a copy of the GNU General Public License
191ccfb
+! along with this program; if not, write to the Free Software
191ccfb
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
191ccfb
+!
191ccfb
+! Ihis file is the Fortran source file for dynamic.exp.
191ccfb
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
191ccfb
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
191ccfb
+
191ccfb
+subroutine foo (string)
191ccfb
+  interface
191ccfb
+    subroutine bar
191ccfb
+    end subroutine
191ccfb
+  end interface
191ccfb
+  character string*(*)
191ccfb
+  call bar                                ! stop-here
191ccfb
+end subroutine foo
191ccfb
+program test
191ccfb
+  interface
191ccfb
+    subroutine foo (string)
191ccfb
+    character string*(*)
191ccfb
+    end subroutine
191ccfb
+  end interface
191ccfb
+  call foo ('hello')
191ccfb
+end