From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60139 invoked by alias); 13 Oct 2016 14:07:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 56417 invoked by uid 89); 13 Oct 2016 14:07:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:4868 X-HELO: mail-pa0-f66.google.com Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Oct 2016 14:07:20 +0000 Received: by mail-pa0-f66.google.com with SMTP id qn10so4845625pac.2 for ; Thu, 13 Oct 2016 07:07:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=sr5tPwloWB/pWGhca/DlZBdysTcCj3EcV6SnKWVlT1c=; b=i9PpbEWSqIuOBmZut2s6JOien1USvaXUe6dNLIDcS82KdUZPkubG9UmD+OQ5BDunog EZADqccQJ3yYrtkGF7cIYKpS1qmmucei4/A4JtfwYUUxBbSJcYkryN4tLbEwSbQpY5yh Ijc3aBBEU+3WIK97G7U6nXywpLA+xJwbV7ejku9PfnLDlVN19RoLIVvI7FT+7DlkDbVL aG7jXmougqk0Fb37o9tk8O493efaJERVD6XKO8eY/Hq4OcJUNXiENE1LC5XFZH/5U4pX o20I3L8tUoq+TAgYI2VBBXOmk3b7k/rifmissW7lVe0ZYai2ynrASyrGaWfb+Vae8mEg brJw== X-Gm-Message-State: AA6/9RlYROGA4dUwRswq5jJd08nB3/bFx8T0QugPuk8R0xK4ASounzZ8gWlNxcYpH6ZpGw== X-Received: by 10.66.141.39 with SMTP id rl7mr8668848pab.121.1476367638722; Thu, 13 Oct 2016 07:07:18 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id l187sm20148089pfc.0.2016.10.13.07.07.16 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 13 Oct 2016 07:07:18 -0700 (PDT) From: Yao Qi To: Bernhard Heckel Cc: qiyaoltc@gmail.com, brobecker@adacore.com, gdb-patches@sourceware.org Subject: Re: [PATCH V4 5/6] Resolve dynamic target types of pointers. References: <1473230295-809-1-git-send-email-bernhard.heckel@intel.com> <1473230295-809-6-git-send-email-bernhard.heckel@intel.com> Date: Thu, 13 Oct 2016 14:07:00 -0000 In-Reply-To: <1473230295-809-6-git-send-email-bernhard.heckel@intel.com> (Bernhard Heckel's message of "Wed, 7 Sep 2016 08:38:14 +0200") Message-ID: <86k2dc8hri.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00366.txt.bz2 Bernhard Heckel 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 *st= ream, > else > { > /* normal case */ > + if (TYPE_CODE (type) =3D=3D TYPE_CODE_PTR > + && 1 =3D=3D is_dynamic_type (type)) Use is_dynamic_type return value as bool. > + { > + CORE_ADDR addr; > + if (NULL !=3D TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type))) > + addr =3D value_address (val); > + else > + addr =3D value_as_address (val); > + > + /* We resolve the target-type only when the > + pointer is associated. */ > + if ((addr !=3D 0) > + && (0 =3D=3D 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" "=3D \\(PTR TO -> \\( $logical \\)\\) 0x0" "print = logp, not associated" > +gdb_test "print *logp" "Cannot access memory at address 0x0" "print *log= p, not associated" > +gdb_test "print comp" "=3D \\(PTR TO -> \\( $complex \\)\\) 0x0" "print = comp, not associated" > +gdb_test "print *comp" "Cannot access memory at address 0x0" "print *com= p, not associated" > +gdb_test "print charp" "=3D \\(PTR TO -> \\( character\\*1 \\)\\) 0x0" "= print charp, not associated" > +gdb_test "print *charp" "Cannot access memory at address 0x0" "print *ch= arp, not associated" > +gdb_test "print charap" "=3D \\(PTR TO -> \\( character\\*3 \\)\\) 0x0" = "print charap, not associated" > +gdb_test "print *charap" "Cannot access memory at address 0x0" "print *c= harap, not associated" > +gdb_test "print intp" "=3D \\(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 " =3D \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) \r\n$g= db_prompt $" { > + pass $test > + } > + -re " =3D \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" "=3D \\(PTR TO -> \\( $real \\)\\) 0x0" "print re= alp, not associated" > +gdb_test "print *realp" "Cannot access memory at address 0x0" "print *re= alp, not associated" They are too long. > +gdb_test "print \$my_var =3D intp" "=3D \\(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" "=3D " > + > + > +gdb_breakpoint [gdb_get_line_number "After value assignment"] > +gdb_continue_to_breakpoint "After value assignment" > +gdb_test "print logp" "=3D \\(PTR TO -> \\( $logical \\)\\) $hex\( <.*>\= )?" > +gdb_test "print *logp" "=3D \\.TRUE\\." > +gdb_test "print comp" "=3D \\(PTR TO -> \\( $complex \\)\\) $hex\( <.*>\= )?" > +gdb_test "print *comp" "=3D \\(1,2\\)" > +gdb_test "print charp" "=3D \\(PTR TO -> \\( character\\*1 \\)\\) $hex\(= <.*>\)?" > +gdb_test "print *charp" "=3D 'a'" > +gdb_test "print charap" "=3D \\(PTR TO -> \\( character\\*3 \\)\\) $hex\= ( <.*>\)?" > +gdb_test "print *charap" "=3D 'abc'" > +gdb_test "print intp" "=3D \\(PTR TO -> \\( $int \\)\\) $hex\( <.*>\)?" > +gdb_test "print *intp" "=3D 10" > +set test_name "print intap, associated" > +gdb_test_multiple "print intap" $test_name { > + -re "=3D \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt= $" { > + pass $test_name > + } > + -re "=3D \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb= _prompt $" { > + gdb_test "print *intap" "=3D \\(\\( 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 "=3D \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" { > + pass $test_name > + } > + -re "=3D \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_p= rompt $" { > + gdb_test "print *intvlap" "=3D \\(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 u= i_file *stream, > return 0; > } >=20=20 > - 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); --=20 Yao (=E9=BD=90=E5=B0=A7)