[PATCH 1/3] Fortran: Handle associated property of pointer types.

Bernhard Heckel bernhard.heckel@intel.com
Tue Jun 21 09:17:00 GMT 2016


On 17/06/2016 13:28, Yao Qi wrote:
> Bernhard Heckel <bernhard.heckel@intel.com> writes:
>
>> Some fortran compiler don't create the associated property but
>> set the pointers content to zero. In order to have a common
> Do you mean different compilers behave differently?  In the test case,
>
>    logical, pointer :: logp
>    nullify (logp)
>    logp => logv    ! Before pointer assignment
>
> what are these different behaviors with different compilers?  Isn't
> correct that compiler doesn't create the associated property when
> program stops on line "Before pointer associated"? because logp is not
> associated to any target.
Some compilers create the associated property some not. If not, we have 
always to check
the content of the pointer if it is null. The associated property is not 
created dynamically,
therefore it doesn't matter where we stop. Only the property value is 
different, depending
where we stop.
>> way to handle not associated pointers, the missing associated
>> property is added.
>>
>> Before:
>> (gdb) print *intp
>> Cannot access memory address 0x0
>>
>> After:
>> (gdb) print *intp
>> $1 = <not associated>
>>
> Do you mean "print intp" or "print *intp"?  in your patch below, I see
> this,
Same for ptype. Current & prev. implementation shortcut's further 
printing in case
the pointer is not associated.

>
>> +gdb_test "print intp" "= <not associated>" "print intp, not associated"
>> +
>> +gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
>> +gdb_continue_to_breakpoint "Before pointer assignment"
>> +gdb_test "print logp" "= <not associated>" "print logp, not associated"
>> +gdb_test "print comp" "= <not associated>" "print comp, not associated"
>> +gdb_test "print charp" "= <not associated>" "print charp, not associated"
>> +gdb_test "print charap" "= <not associated>" "print charap, not associated"
>> +gdb_test "print intp" "= <not associated>" "print intp, not associated"
>> +gdb_test "print intap" "= <not associated>" "print intap, not associated"
>> +gdb_test "print realp" "= <not associated>" "print realp, not associated"
>> +gdb_test "print \$my_var = intp" "= <not associated>"
> What is the output without your fix?  IMO, "print POINTER" prints the
> value of the pointer.  It doesn't matter whether the pointer is
> associated with a target or not.
For compilers creating the property, the output is like above.
For missing property, it is:

gdb_test "print logp" "= (PTR TO -> ( $logical )) 0x0"

Based on your input I would like to propose:
gdb_test "print logp" "= (PTR TO -> ( $logical )) <not associated>"

>
>> +
>> +gdb_breakpoint [gdb_get_line_number "After value assignment"]
>> +gdb_continue_to_breakpoint "After value assignment"
>> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"  "print logp, associated"
>> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"  "print comp, associated"
>> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?" "print charp, associated"
>> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?" "print charap, associated"
>> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"  "print intp, associated"
>> +gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) $hex\( <.*>\)?"  "print realp, associated"
>> +gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
>
>> +
>> +gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
>> +gdb_continue_to_breakpoint "Before pointer assignment"
>> +gdb_test "ptype logp" "= <not associated>" "ptype logp, not associated"
>> +gdb_test "ptype comp" "= <not associated>" "ptype comp, not associated"
>> +gdb_test "ptype charp" "= <not associated>" "ptype charp, not associated"
>> +gdb_test "ptype charap" "= <not associated>" "ptype charap, not associated"
>> +gdb_test "ptype intp" "= <not associated>" "ptype intp, not associated"
>> +gdb_test "ptype intap" "= <not associated>" "ptype intap, not associated"
>> +gdb_test "ptype realp" "= <not associated>" "ptype realp, not associated"
>> +
> The type of the pointer should be known regardless it is associated with
> target or not, because in the source we have,
>
> +  logical, pointer :: logp
> +  complex, pointer :: comp
> +  character, pointer:: charp
> +  character (len=3), pointer:: charap
> +  integer, pointer :: intp
> +  integer, pointer :: intap (:)
> +  real, pointer :: realp
>
> we can tell the type of logp is "logical, pointer", right?
Correct, this should be doable. The prev. & current implementation stops 
further printing
of pointers in case they are not associated. I will change this.
>
>> +
>> +gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
>> +gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
>> +gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
>> +gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
>> +gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
>> +gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


More information about the Gdb-patches mailing list