From: pggodin on
On Apr 8, 2:48 am, glen herrmannsfeldt <g...(a)ugcs.caltech.edu> wrote:
> pggo...(a)gmail.com wrote:
> > When using gfortran and gdb 6.8 I cant' print acharacter*(*) string
> > in gdb that is passed in a fortran subroutine.
> > Doesn't anybody know a workaround for this.
>
> I don't have 6.8, but the version I have prints out arguments when
> a breakpoint is reached. It seems, though, that in mine it believe
> the argument is a pointer to int1.
>
> printf "%s",arg
>
> prints the value up to the next nullcharacter. (That is, as
> a C string.)
>
> -- glen

I should perhaps emphasize that I only have problems with arguments of
type character*(*). All other argument types: reals, integers and
character*(n) arguments (ie character strings of fixed length n where
n=integer) print out normally in the debugger.


Example of problem:

WHEN is an argument to a subroutine and typed as:

CHARACTER*(*) WHEN

when at a breakpoint inside the subroutine
p WHEN
$3 = (REF TO -> ( character(kind=1) (-1))) @0x7fff731cc010: ()

So it looks like it's reporting a string of length -1 and the contents
are the between the empty brackets at the end (ie null string)

Note : printf "%s",WHEN - reports Value can't be converted to
integer.

BTW: Glen what version of gdb are you using?

Thanks,
Phil



From: FX on
> p WHEN
> $3 = (REF TO -> ( character(kind=1) (-1))) @0x7fff731cc010: ()

Try "p (char *)0x7fff731cc010" or "printf "%s", 0x7fff731cc010".

--
FX
From: pggodin on
On Apr 8, 9:54 am, "FX" <coud...(a)alussinan.org> wrote:
> > p WHEN
> > $3 = (REF TO -> ( character(kind=1) (-1))) @0x7fff731cc010: ()
>
> Try "p (char *)0x7fff731cc010" or "printf "%s", 0x7fff731cc010".
>
> --
> FX

That worked!

Thanks for your help FX.

Phil