From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96904 invoked by alias); 24 Feb 2017 15:34:15 -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 96895 invoked by uid 89); 24 Feb 2017 15:34:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-wm0-f67.google.com Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 15:34:13 +0000 Received: by mail-wm0-f67.google.com with SMTP id r18so3527971wmd.3 for ; Fri, 24 Feb 2017 07:34:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=omrOpnnv4SD7SAujOW4BJOzKlzoq6tJ4ZnZEp1hYwGU=; b=BZzoMQfp8x8hY4+FUtBb5jvvT3hMzd9eACEdn8ietmmEiYG6hesPCd3enEKEVDHRBT qcC5H5IZipCF/9Hh5/yyWC6BI67NgeN5DMH5yl0G/RcCPSGNDMIX/BD3XFHc1PPjmSVA yyDsG9/NZ4ILm/Bil1q+aN9q902qhAwKc42XbEmjjhtcE8BD/9YWG7HouS5kVe27jF4X Q1qWjutj1cg121t2j5t+i5c0yyaeqjoKuy6d9mppoGLJvrYQcGuer20Etv6aGXXSATVE 2vKl7+6/RVA/wKDftELaz+UPjsjb9edtHKd1FUtpcevHksYp1Pmr5+TPd9JTk3BUtbHb td+A== X-Gm-Message-State: AMke39lPcqOP/gCiysYMUDLv32FiDxOO+ul5Iompwq4I2wwbh8vQFy7Xni0KNPxqYB2LOg== X-Received: by 10.28.139.74 with SMTP id n71mr3414254wmd.139.1487950451315; Fri, 24 Feb 2017 07:34:11 -0800 (PST) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id x69sm2761342wma.15.2017.02.24.07.34.10 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 24 Feb 2017 07:34:10 -0800 (PST) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 2/2] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index References: <86a89cc2u6.fsf@gmail.com> <1487870642-29926-1-git-send-email-palves@redhat.com> <1487870642-29926-3-git-send-email-palves@redhat.com> Date: Fri, 24 Feb 2017 15:34:00 -0000 In-Reply-To: <1487870642-29926-3-git-send-email-palves@redhat.com> (Pedro Alves's message of "Thu, 23 Feb 2017 17:24:02 +0000") Message-ID: <86poi77gd0.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: 2017-02/txt/msg00681.txt.bz2 Pedro Alves writes: > - /* Find the symtab for SRCFILE (this loads it if it was not yet read > - in). */ > - s =3D lookup_symtab (srcfile); > - if (s =3D=3D NULL) > + /* Go through symtabs for SRCFILE and check the externs and statics > + for symbols which match. */ > + iterate_over_symtabs (srcfile, [&] (symtab *s) > { > - /* Maybe they typed the file with leading directories, while the > - symbol tables record only its basename. */ > - const char *tail =3D lbasename (srcfile); > - > - if (tail > srcfile) > - s =3D lookup_symtab (tail); > - } > - > - /* If we have no symtab for that file, return an empty list. */ > - if (s =3D=3D NULL) > - return (return_val); In the original code, lookup_symtab is called twice, and if we inline lookup_symtab here, the change in this patch is more readable. Let us inline lookup_symtab first, the code becomes, s =3D NULL; iterate_over_symtabs (srcfile, [&] (symtab *symtab) { s =3D symtab; add_symtab_completions (SYMTAB_COMPUNIT (s), sym_text, sym_text_len, text, word, TYPE_CODE_UNDEF); return true; }); if (s =3D=3D NULL) { /* Maybe they typed the file with leading directories, while the symbol tables record only its basename. */ const char *tail =3D lbasename (srcfile); if (tail > srcfile) iterate_over_symtabs (tail, [&] (symtab *symtab) { s =3D symtab; add_symtab_completions (SYMTAB_COMPUNIT (s), sym_text, sym_text_len, text, word, TYPE_CODE_UNDEF); return true; }); } then, as you described in commit log, we have to iterate all symtabs rather than stop on the first matched symtab. We need to replace "return true;" with "return false;" above. Presumably, this replacement will fix the fails in completion.exp. Then, it turns out that the whole block "if (s =3D=3D NULL) {...}" is removed by this patch. I'll dig deep to see this block is still needed or not. --=20 Yao (=E9=BD=90=E5=B0=A7)