Display Fortran strings in backtraces
Commit Message
Hi,
for Fortran it fixes displaying normal strings also in frames/backtraces:
(gdb) frame
#0 f (s=..., _s=3) at ./gdb.fortran/fortran-frame-string.f90:24
->
#0 f (s='foo', _s=3) at ./gdb.fortran/fortran-frame-string.f90:24
The patch is simple and I do not see why it should not be this way.
For C/C++ TYPE_CODE_STRING is not used. I am not aware of Pascal but that
language is currently not really much supported in GDB anyway.
This was a part of my archer/jankratochvil/vla branch but it is not a part of
the Intel VLA patchset as it in fact is completely unrelated to "VLA".
No regressions on {x86_64,x86_64-m32,i686}-fedora22pre-linux-gnu.
Thanks,
Jan
gdb/
2014-07-28 Jan Kratochvil <jan.kratochvil@redhat.com>
* valprint.c (val_print_scalar_type_p): For TYPE_CODE_STRING return 0.
gdb/testsuite/
2014-07-28 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.fortran/fortran-frame-string.exp: New file.
* gdb.fortran/fortran-frame-string.f90: New file.
Comments
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> 2014-07-28 Jan Kratochvil <jan.kratochvil@redhat.com>
Jan> * valprint.c (val_print_scalar_type_p): For TYPE_CODE_STRING return 0.
It looks fine to me, but I think it can affect Ada, so Joel ought to
weigh in.
Tom
> gdb/
> 2014-07-28 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * valprint.c (val_print_scalar_type_p): For TYPE_CODE_STRING return 0.
>
> gdb/testsuite/
> 2014-07-28 Jan Kratochvil <jan.kratochvil@redhat.com>
>
> * gdb.fortran/fortran-frame-string.exp: New file.
> * gdb.fortran/fortran-frame-string.f90: New file.
Sorry, Jan. That seems to be counter-intuitive; strings are not
scalars... The intent of the setting is to avoid having super-long
parameter values drowning the list parameters. Strings can be pretty
long, so I think the current behavior matches my current expectation.
On Tue, 29 Jul 2014 22:05:13 +0200, Joel Brobecker wrote:
> Sorry, Jan. That seems to be counter-intuitive; strings are not
> scalars... The intent of the setting is to avoid having super-long
> parameter values drowning the list parameters. Strings can be pretty
> long, so I think the current behavior matches my current expectation.
In such case normal C 'char *' parameters also should not be printed.
Length of fortran strings is limited exactly the same way like C 'char *'
strings are:
Breakpoint 2, f (s='foo01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010'..., _s=203) at ./gdb.fortran/fortran-frame-string.f90:24^M
(gdb) show print elements
Limit on string chars or array elements to print is 200.
What is the difference between Fortran strings and C 'char *' strings?
Thanks,
Jan
> What is the difference between Fortran strings and C 'char *' strings?
No difference indeed. And FWIW I don't think that "char *" should
be printed in this case either.
@@ -290,7 +290,6 @@ val_print_scalar_type_p (struct type *type)
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
case TYPE_CODE_SET:
- case TYPE_CODE_STRING:
return 0;
default:
return 1;
new file mode 100644
@@ -0,0 +1,32 @@
+# Copyright 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+standard_testfile .f90
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
+ return -1
+}
+
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
+}
+
+gdb_breakpoint [gdb_get_line_number "s = s"]
+gdb_continue_to_breakpoint "s = s"
+
+gdb_test "ptype s" {type = character\*3}
+gdb_test "p s" " = 'foo'"
+gdb_test "frame" { \(s='foo', .*}
new file mode 100644
@@ -0,0 +1,28 @@
+! Copyright 2014 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program; if not, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
+
+ subroutine f(s)
+ character*3 s
+ s = s
+ end
+
+ program main
+ call f ('foo')
+ end