This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Bernhard Heckel <bernhard dot heckel at intel dot com>
- Cc: qiyaoltc at gmail dot com, brobecker at adacore dot com, gdb-patches at sourceware dot org
- Date: Thu, 13 Oct 2016 15:07:13 +0100
- Subject: Re: [PATCH V4 5/6] Resolve dynamic target types of pointers.
- Authentication-results: sourceware.org; auth=none
- References: <1473230295-809-1-git-send-email-bernhard.heckel@intel.com> <1473230295-809-6-git-send-email-bernhard.heckel@intel.com>
Bernhard Heckel <bernhard.heckel@intel.com> writes:
> diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
> index 2cb418d..120163f 100644
> --- a/gdb/c-valprint.c
> +++ b/gdb/c-valprint.c
> @@ -645,6 +645,28 @@ c_value_print (struct value *val, struct ui_file *stream,
> else
> {
> /* normal case */
> + if (TYPE_CODE (type) == TYPE_CODE_PTR
> + && 1 == is_dynamic_type (type))
Use is_dynamic_type return value as bool.
> + {
> + CORE_ADDR addr;
> + if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
> + addr = value_address (val);
> + else
> + addr = value_as_address (val);
> +
> + /* We resolve the target-type only when the
> + pointer is associated. */
> + if ((addr != 0)
> + && (0 == type_not_associated (type)))
!type_not_associated (type)
> +
> +
> +gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
> +gdb_continue_to_breakpoint "Before pointer assignment"
> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) 0x0" "print logp, not associated"
> +gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) 0x0" "print comp, not associated"
> +gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "print charp, not associated"
> +gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" "print charap, not associated"
> +gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0" "print intp, not associated"
> +gdb_test "print *intp" "Cannot access memory at address 0x0" "print
> *intp, not associated"
These lines are too long.
> +set test "print intap, not associated"
> +gdb_test_multiple "print intap" $test {
> + -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
> + pass $test
> + }
> + -re " = <not associated>\r\n$gdb_prompt $" {
> + pass $test
> + }
> +}
Why do we need to different regex here? Need to handle the differences
of different compilers? IMO, the former looks reasonable to me.
> +gdb_test "print realp" "= \\(PTR TO -> \\( $real \\)\\) 0x0" "print realp, not associated"
> +gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
They are too long.
> +gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int \\)\\) 0x0"
> +
> +
> +gdb_breakpoint [gdb_get_line_number "Before value assignment"]
> +gdb_continue_to_breakpoint "Before value assignment"
> +gdb_test "print *(twop)%ivla2" "= <not allocated>"
> +
> +
> +gdb_breakpoint [gdb_get_line_number "After value assignment"]
> +gdb_continue_to_breakpoint "After value assignment"
> +gdb_test "print logp" "= \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *logp" "= \\.TRUE\\."
> +gdb_test "print comp" "= \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *comp" "= \\(1,2\\)"
> +gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1 \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *charp" "= 'a'"
> +gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3 \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *charap" "= 'abc'"
> +gdb_test "print intp" "= \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?"
> +gdb_test "print *intp" "= 10"
> +set test_name "print intap, associated"
> +gdb_test_multiple "print intap" $test_name {
> + -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
> + pass $test_name
> + }
> + -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
> + gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
> + pass $test_name
> + }
> +}
Again, different outputs due to different compilers? The latter looks
reasonable to me.
> +set test_name "print intvlap, associated"
> +gdb_test_multiple "print intvlap" $test_name {
> + -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
> + pass $test_name
> + }
> + -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
> + gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
> + pass $test_name
> + }
> +}
Likewise.
> diff --git a/gdb/valprint.c b/gdb/valprint.c
> index 6896da2..f592278 100644
> --- a/gdb/valprint.c
> +++ b/gdb/valprint.c
> @@ -1141,12 +1141,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
> return 0;
> }
>
> - if (type_not_associated (value_type (val)))
> - {
> - val_print_not_associated (stream);
> - return 0;
> - }
> -
Could you explain why do you remove this?
> if (type_not_allocated (value_type (val)))
> {
> val_print_not_allocated (stream);
--
Yao (齐尧)