This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/3] Fortran: Handle associated property of pointer types.
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Bernhard Heckel <bernhard dot heckel at intel dot com>
- Cc: qiyaoltc at gmail dot com, eliz at gnu dot org, gdb-patches at sourceware dot org
- Date: Fri, 17 Jun 2016 12:28:31 +0100
- Subject: Re: [PATCH 1/3] Fortran: Handle associated property of pointer types.
- Authentication-results: sourceware.org; auth=none
- References: <1465220233-32286-1-git-send-email-bernhard dot heckel at intel dot com> <1465220233-32286-2-git-send-email-bernhard dot heckel at intel dot com>
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.
> 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,
> +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.
> +
> +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?
> +
> +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 \\)"
--
Yao (éå)