From patchwork Wed Feb 22 14:50:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 19337 Received: (qmail 30318 invoked by alias); 22 Feb 2017 14:50:42 -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 30249 invoked by uid 89); 22 Feb 2017 14:50:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Feb 2017 14:50:39 +0000 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4A49C0094EA for ; Wed, 22 Feb 2017 14:50:39 +0000 (UTC) Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FB1397D26 for ; Wed, 22 Feb 2017 14:50:38 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 3/3] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Date: Wed, 22 Feb 2017 14:50:33 +0000 Message-Id: <1487775033-32699-4-git-send-email-palves@redhat.com> In-Reply-To: <1487775033-32699-1-git-send-email-palves@redhat.com> References: <1487775033-32699-1-git-send-email-palves@redhat.com> This patch fixes: -FAIL: gdb.base/completion.exp: tab complete break break.c:ma (timeout) -FAIL: gdb.base/completion.exp: complete break break.c:ma +PASS: gdb.base/completion.exp: tab complete break break.c:ma +PASS: gdb.base/completion.exp: delete breakpoint for tab complete break break.c:ma +PASS: gdb.base/completion.exp: complete break break.c:ma When run with --target_board=dwarf4-gdb-index. The issue here is that make_file_symbol_completion_list_1, used when completing a symbol restricted to a given source file, uses lookup_symtab to look up the symtab with the given name, and search for matching symbols inside. This assumes that there's only one symtab for the given source file. This is an incorrect assumption with (for example) -fdebug-types-section, where we'll have an extra extra symtab containing the types. lookup_symtab finds that symtab, and inside that symtab there are no functions... gdb/ChangeLog: yyyy-mm-dd Pedro Alves * symtab.c (make_file_symbol_completion_list_1): Iterate over symtabs matching all symtabs with SRCFILE as file name instead of only considering the first hit, with lookup_symtab. --- gdb/symtab.c | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index 346d5d2..66fa530 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5391,10 +5391,6 @@ static VEC (char_ptr) * make_file_symbol_completion_list_1 (const char *text, const char *word, const char *srcfile) { - struct symbol *sym; - struct symtab *s; - struct block *b; - struct block_iterator iter; /* The symbol we are completing on. Points in same buffer as text. */ const char *sym_text; /* Length of sym_text. */ @@ -5445,37 +5441,15 @@ make_file_symbol_completion_list_1 (const char *text, const char *word, sym_text_len = strlen (sym_text); - /* Find the symtab for SRCFILE (this loads it if it was not yet read - in). */ - s = lookup_symtab (srcfile); - if (s == NULL) + /* Go through symtabs for SRCFILE and check the externs and statics + for symbols which match. */ + iterate_over_symtabs (srcfile, [&] (struct symtab *symtab) { - /* Maybe they typed the file with leading directories, while the - symbol tables record only its basename. */ - const char *tail = lbasename (srcfile); - - if (tail > srcfile) - s = lookup_symtab (tail); - } - - /* If we have no symtab for that file, return an empty list. */ - if (s == NULL) - return (return_val); - - /* Go through this symtab and check the externs and statics for - symbols which match. */ - - b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), GLOBAL_BLOCK); - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word); - } - - b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), STATIC_BLOCK); - ALL_BLOCK_SYMBOLS (b, iter, sym) - { - COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word); - } + add_symtab_completions (symtab->compunit_symtab, + sym_text, sym_text_len, + text, word, TYPE_CODE_UNDEF); + return false; + }); return (return_val); }