Sources Bugzilla – Bug 10036
Wide-character support for Fortran is missing
Last modified: 2011-06-29 15:54:17 UTC
Fortran 2003 allows and Fortran 2008 mandates support for wide-character strings in Fortran compilers. Those are then of the type "ISO/IEC 10646-1:2000 UCS-4 character type". To my knowledge, GCC/gfortran 4.4/4.5 is the only Fortran compiler which supports wide strings so far. Example program (compile with "gfortran -fbackslash"; use "\u...." and "\U........" to enter Unicode characters). ------------------------------------- character(kind=4) :: c character(kind=4,len=5) :: str c = 4_'\u00AE' str = 4_'\u00AE\u01DD' open(6,encoding='utf-8') print *, c print *, str end ------------------------------------- Currently, gdb prints: (gdb) pt c type = character(kind=4) (1) (gdb) pt str type = character(kind=4) (5) (gdb) p str $1 = (92, 117, 48, 48, 65) (gdb) p c $2 = (92) (Support for entering, e.g., UTF-8 directly in the source code is planned but not yet implemented.) * * * The support in gdb should be relatively simple on top of the wide-char support for C, cf. http://sourceware.org/ml/gdb-patches/2009-01/msg00533.html (I'm not sure whether that is the latest patch, but it is in the CVS tree.)
Testing a patch.
CVSROOT: /cvs/src Module name: src Changes by: tromey@sourceware.org 2011-06-29 15:32:40 Modified files: gdb : ChangeLog c-lang.c dwarf2read.c f-lang.c f-typeprint.c f-valprint.c valprint.c valprint.h gdb/testsuite : ChangeLog Added files: gdb/testsuite/gdb.fortran: charset.exp charset.f90 Log message: gdb PR fortran/10036: * valprint.h (generic_emit_char, generic_printstr): Declare. * valprint.c (wchar_printable, append_string_as_wide) (print_wchar): Move from c-lang.c. (generic_emit_char): New function; mostly taken from c_emit_char. (generic_printstr): New function; mostly taken from c_printstr. * f-valprint.c (f_val_print) <TYPE_CODE_ARRAY>: Handle strings represented as arrays. <TYPE_CODE_CHAR>: Treat as TYPE_CODE_INT; recognize as character type. * f-typeprint.c (f_type_print_base) <TYPE_CODE_CHAR>: Treat identically to TYPE_CODE_INT. * f-lang.c (f_get_encoding): New function. (f_emit_char): Use generic_emit_char. (f_printchar): Replace comment. (f_printstr): Use generic_printstr. * dwarf2read.c (read_base_type) <DW_ATE_unsigned>: Handle Fortran "character" types specially. <DW_ATE_signed_char, DW_ATE_unsigned_char>: Make TYPE_CODE_CHAR for Fortran. * c-lang.c (wchar_printable, append_string_as_wide, print_wchar): Move to valprint.c (c_emit_char): Call generic_emit_char. (c_printstr): Call generic_printstr. gdb/testsuite * gdb.fortran/charset.exp: New file. * gdb.fortran/charset.f90: New file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13123&r2=1.13124 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/c-lang.c.diff?cvsroot=src&r1=1.93&r2=1.94 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.542&r2=1.543 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/f-lang.c.diff?cvsroot=src&r1=1.65&r2=1.66 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/f-typeprint.c.diff?cvsroot=src&r1=1.35&r2=1.36 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/f-valprint.c.diff?cvsroot=src&r1=1.66&r2=1.67 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valprint.c.diff?cvsroot=src&r1=1.111&r2=1.112 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/valprint.h.diff?cvsroot=src&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2757&r2=1.2758 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.fortran/charset.exp.diff?cvsroot=src&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.fortran/charset.f90.diff?cvsroot=src&r1=NONE&r2=1.1
Fix checked in.