From patchwork Tue Apr 5 11:32:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 11631 Received: (qmail 71740 invoked by alias); 5 Apr 2016 11:32:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 71724 invoked by uid 89); 5 Apr 2016 11:32:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=abandon, 2067, 206, 7, HX-Received:10.98.15.145 X-HELO: mail-pf0-f194.google.com Received: from mail-pf0-f194.google.com (HELO mail-pf0-f194.google.com) (209.85.192.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 05 Apr 2016 11:32:36 +0000 Received: by mail-pf0-f194.google.com with SMTP id d184so1110443pfc.1 for ; Tue, 05 Apr 2016 04:32:36 -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=wieCdeFLEzDHqgjSvozkiu8gvnbNzYfEZ/3u+WDcOuE=; b=Y+pxFfhtc4+0dBRAgjYt4CpHW74gXes14sOluNO4yXWUrxpLNxoU76doTFY0OR4KeV VMcyPPYLkGFFChA1eRYZwJx734wCn9TK8VDyeJath89LeRFV5M6mXkfXWmhpKHfdAqV/ IreISPxVTh+2fsiUTz3ikw87+xatXXxwyykOw6m/rgKc5wjQBkDf4hsK0KWDV8fkcok1 r9Ho/AA3dL1pdF4jBTl5oLnC1vThmoidOFdr7eoRFndCQe3BMbT9xczHkBZGQ3fphXTg slanoJA2bZRAIbu2IfMTFraOX0hl6JDt1qvtaeE9yQymjJ83tqTCzcPpE9RldhKKKMGC JPjQ== X-Gm-Message-State: AD7BkJL37HH896l1IVW1+THEuGanJUStk/T9SudveAHI6YDJFhMlQOkK7UJwZk+CTAElcQ== X-Received: by 10.98.15.145 with SMTP id 17mr28329629pfp.19.1459855955155; Tue, 05 Apr 2016 04:32:35 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id z2sm32411530pfa.90.2016.04.05.04.32.31 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 05 Apr 2016 04:32:34 -0700 (PDT) From: Yao Qi To: Walfred Tedeschi Cc: palves@redhat.com, brobecker@adacore.com, gdb-patches@sourceware.org Subject: Re: [PATCH v1] Fix of default lookup for "this" symbol. References: <1457533925-22168-1-git-send-email-walfred.tedeschi@intel.com> Date: Tue, 05 Apr 2016 12:32:24 +0100 In-Reply-To: <1457533925-22168-1-git-send-email-walfred.tedeschi@intel.com> (Walfred Tedeschi's message of "Wed, 9 Mar 2016 15:32:05 +0100") Message-ID: <86egaknvef.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Walfred Tedeschi writes: > 2016-03-09 Walfred Tedeschi > > gdb/ChangeLog: > > * cp_lookup_bare_symbol (cp_lookup_bare_symbol): Add check for the * cp-namespace.c (cp_lookup_bare_symbol): > name_of_this in order to return a null symbol when looking up > for "this". > > > --- > gdb/cp-namespace.c | 7 ++++++ > gdb/testsuite/gdb.fortran/derived-type.exp | 35 ++++++++++++++++++++++++++++-- > gdb/testsuite/gdb.fortran/derived-type.f90 | 7 +++++- > 3 files changed, 46 insertions(+), 3 deletions(-) > > diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c > index 72002d6..b9d7dbe 100644 > --- a/gdb/cp-namespace.c > +++ b/gdb/cp-namespace.c > @@ -210,6 +210,13 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, > if (lang_this.symbol == NULL) > return null_block_symbol; > > + /* This whole routine is also the default path for several languages. > + In some languages "this" is not a special symbol, > + i.e. LA_NAME_OF_THIS is NULL. > + For those cases we should return a null_block_symbol. */ > + if (langdef != NULL && langdef->la_name_of_this == NULL) > + return null_block_symbol; > + The better fix would be pass "langdef" to lookup_language_this rather than language_def (language_cplus). The patch is like this: > type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol))); > /* If TYPE_NAME is NULL, abandon trying to find this symbol. > This can happen for lambda functions compiled with clang++, > diff --git a/gdb/testsuite/gdb.fortran/derived-type.exp b/gdb/testsuite/gdb.fortran/derived-type.exp > index f650352..acccf3b 100644 > --- a/gdb/testsuite/gdb.fortran/derived-type.exp > +++ b/gdb/testsuite/gdb.fortran/derived-type.exp > @@ -74,14 +74,45 @@ gdb_test_multiple $test $test { > gdb_test "print q%x%c" "\\$\[0-9\]+ = 1" > gdb_test "print q%x%d" "\\$\[0-9\]+ = 2\\.375" > > +set result_line "= \\( a = 3.125, x = \\( c = 1, d = 2\\.375 \\),\ > +b = 'abcdefg' \\)\r\n$gdb_prompt $" > + > +# Used in case compiler generates an array of characters. > +set result_line_2 " = \\( a = 3.125, x = \\( 1, 2\\.375 \\),\ > +b = \\('abcdefg'\\) \\)\r\n$gdb_prompt $" > + > set test "print q" > gdb_test_multiple $test $test { > - -re "\\$\[0-9\]+ = \\( a = 3.125, x = \\( c = 1, d = 2\\.375 \\), b = 'abcdefg' \\)\r\n$gdb_prompt $" { Your patch can't be applied cleanly, because the pattern in mainline is "\\$\[0-9\]+ = \\( 3.125, \\( 1, 2\\.375 \\), 'abcdefg' \\)\r\n$gdb_prompt $", it doesn't have " a =" or "x = " things. > + -re $result_line { > pass $test > } > - -re "\\$\[0-9\]+ = \\( a = 3.125, x = \\( 1, 2\\.375 \\), b = \\('abcdefg'\\) \\)\r\n$gdb_prompt $" { > + -re $result_line_2 { > # Compiler should produce string, not an array of characters. > setup_xfail "*-*-*" > fail $test > } > } > + --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -206,7 +206,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, struct block_symbol lang_this; struct type *type; - lang_this = lookup_language_this (language_def (language_cplus), block); + lang_this = lookup_language_this (langdef, block); if (lang_this.symbol == NULL) return null_block_symbol;