From patchwork Sun Jul 16 00:08:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyi Zhou X-Patchwork-Id: 21632 Received: (qmail 16470 invoked by alias); 16 Jul 2017 00:09:32 -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 16442 invoked by uid 89); 16 Jul 2017 00:09:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=2017-07-16, H*RU:209.85.192.196, Hx-spam-relays-external:209.85.192.196, H*r:36.102.227 X-HELO: mail-pf0-f196.google.com Received: from mail-pf0-f196.google.com (HELO mail-pf0-f196.google.com) (209.85.192.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Jul 2017 00:09:29 +0000 Received: by mail-pf0-f196.google.com with SMTP id c24so15317409pfe.1 for ; Sat, 15 Jul 2017 17:09:29 -0700 (PDT) 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:date:message-id; bh=U5vK2DWjSzxWBLyFHu5ydZgoKHEToBr/JclaBo1rZRc=; b=YGvXGCxlJdVptSOMuP3cJ4dqt6jf5MrAImqwZQabRSDTQy2qxUQAXisKWr0W5YZs2U 2Kp6JOPh6sbfp0+4byiSi6DpbiD3knE+C4V2Llo5l3lj0KR6izGgvMr1/2/W0RaVzFA6 QBJyPeyIhhjcMBs0r4IkruWTqCTF+wpsUPdhUbbx5e4t5XTXRDwj4Nm95HdbPHt5JAvF XZxo3Zy3At5xRBvgy9e6ZOh/D+/GgOrClLvqYSSmN/mmIShAuThQOwLUIabLRO6yKksu FyZEmHsWrAgzze8Vk2WA8Rm7WwpInm8jg/6p6KBxx0MEY0/6Vzf1zB5ilCoXe1uSXw8a aoKw== X-Gm-Message-State: AIVw113A3+9ojPsQtbdjx0VwtUXlMj12k9/k7yOdRVG5/m1oMSanKpfQ 7cXGTymghOYE7JCh X-Received: by 10.84.137.1 with SMTP id 1mr22685181plm.75.1500163768159; Sat, 15 Jul 2017 17:09:28 -0700 (PDT) Received: from localhost.localdomain ([36.102.227.57]) by smtp.gmail.com with ESMTPSA id w70sm3755540pfd.15.2017.07.15.17.09.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Jul 2017 17:09:27 -0700 (PDT) From: Zhouyi Zhou To: gdb-patches@sourceware.org Cc: Zhouyi Zhou Subject: [PATCH v2 1/1] don't list typedef symbols in C++, d and ada Date: Sun, 16 Jul 2017 08:08:41 +0800 Message-Id: <1500163721-9343-1-git-send-email-zhouzhouyi@gmail.com> C++ "struct foo { ... }" also defines a typedef for "foo", in order to make command like "gdb) ptype (foo *)0" work, function symbol_matches_domain relaxes the check for domain check for cplus, d and ada. However the command "list foo" will invoke symbol_matches_domain, which results in odd result when execute command "list foo". For example, consider debugging following program. struct foo { int i; }; int foo(void); int main() { struct foo l; return foo(); } int foo() { return 0; } (gdb) list foo file: "example.c", line number: 1 file: "example.c", line number: 13 Following patch get rid of "non var" symbols in function find_function_symbols. Tested on x86-64 GNU/Linux. Signed-off-by: Zhouyi Zhou gdb/ChangeLog: 2017-07-16 Zhouyi Zhou * linespec.c (find_function_symbols): remove non-var symbols from the matching result. --- gdb/linespec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 4c076fe..fd74cde 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3223,6 +3223,8 @@ find_function_symbols (struct linespec_state *state, { struct collect_info info; VEC (const_char_ptr) *symbol_names = NULL; + int ix; + struct symbol *sym; struct cleanup *cleanup = make_cleanup (VEC_cleanup (const_char_ptr), &symbol_names); @@ -3240,7 +3242,17 @@ find_function_symbols (struct linespec_state *state, add_matching_symbols_to_info (name, &info, state->search_pspace); do_cleanups (cleanup); - + + for (ix = 0; VEC_iterate (symbolp, info.result.symbols, ix, sym); ++ix) + { + if (sym->domain != VAR_DOMAIN) + { + VEC_unordered_remove (symbolp, + info.result.symbols, ix); + --ix; + } + } + if (VEC_empty (symbolp, info.result.symbols)) { VEC_free (symbolp, info.result.symbols);