gdb/fortran/testsuite: print values and types of string variables
authorAndrew Burgess <aburgess@redhat.com>
Fri, 4 Nov 2022 14:51:11 +0000 (14:51 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 17 Nov 2022 10:26:26 +0000 (10:26 +0000)
commit1c01b23603766fbca4ed4dd12fdd710860e6038e
treedfa4778dab0c10102803a95d557241b0b7a3632e
parentf4ad82b3bcc4ae2cecba00177561ddfad49ccef2
gdb/fortran/testsuite: print values and types of string variables

While looking through the Fortran tests, I couldn't find a test of GDB
printing the value and type of a Fortran string defined using the
'character*SIZE' notation.

This works fine in GDB right now, but I thought it wouldn't hurt to
have a test for this, so this commit adds such a test.

The test also includes printing a string that includes some embedded
special characters: \n \r \t \000 - that's right, as Fortran strings
are stored as an address and length, it is fine to include an embedded
null, so this test includes an example of that.

Standard Fortran doesn't support backslash escape sequences within
strings, the special characters must be generated using the `achar`
function.  However, when GDB prints the strings we currently print
using the standard C like backslash sequences.

I'm not currently proposing to change that behaviour, the backslash
sequences are more compact than the standard Fortran way of doing
things, and are so widely used that I suspect most Fortran programmers
will understand them.
gdb/testsuite/gdb.fortran/string-types.exp [new file with mode: 0644]
gdb/testsuite/gdb.fortran/string-types.f90 [new file with mode: 0644]