From patchwork Sat Jul 15 05:34:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyi Zhou X-Patchwork-Id: 21626 Received: (qmail 101597 invoked by alias); 15 Jul 2017 05:36:11 -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 100832 invoked by uid 89); 15 Jul 2017 05:35:11 -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= X-HELO: mail-pg0-f66.google.com Received: from mail-pg0-f66.google.com (HELO mail-pg0-f66.google.com) (74.125.83.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Jul 2017 05:35:09 +0000 Received: by mail-pg0-f66.google.com with SMTP id d193so12764600pgc.2 for ; Fri, 14 Jul 2017 22:35:08 -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=sXl+K0kdSt38ynB+nFwzMZ+yzmSWJI7YoQnbFExfWIw=; b=s6ud51JDgn0cediyykGYtbvr8IKZPiRPbSm52r67ZXdbAIWMlnX24hwal0VeqXZXvG MOOpIAc7Z3twMgpfR0NeQDDx5wYEYKwciQqSh+fLRvYCcF1SJXKZ3c3WWERvODsG4nj3 LofyM6Ka476VMqt9mQBq5VQ+dBUZWkcQGl77G2MRDiAZ1xIRuTJOFfmPd+xCVM27Q61N 2m8EyQevORm6ZcsX2p2vgAuXbHQpo1FuMq2YuMqHHZ+LOYzAUaHpnFg6tnfYtzFoUhYH rlHRS6zk53oTYtnktPTWZgNDJlNl0RGMfA4G3S01OGdQSqCt2pbOdErZntCJikLCbIix 3dxw== X-Gm-Message-State: AIVw113wKY1SZRAb5TmWFpwU/IrPEQN98w19AB4LcRHa4+xU8Tc81rW9 BQW+5AHMNnXFWX55 X-Received: by 10.84.195.131 with SMTP id j3mr19808708pld.147.1500096907327; Fri, 14 Jul 2017 22:35:07 -0700 (PDT) Received: from localhost.localdomain ([118.193.167.117]) by smtp.gmail.com with ESMTPSA id m79sm22699548pfk.35.2017.07.14.22.35.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 22:35:06 -0700 (PDT) From: Zhouyi Zhou To: gdb-patches@sourceware.org Cc: Zhouyi Zhou Subject: [PATCH 1/1] don't list typedef symbols in C++, d and ada Date: Sat, 15 Jul 2017 05:34:54 +0000 Message-Id: <1500096894-3947-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-15 Zhouyi Zhou * linespec.c (find_function_symbols): remove non-var symbols from the matching result. --- gdb/linespec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/linespec.c b/gdb/linespec.c index 4c076fe..4876a73 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,14 @@ 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); + } + if (VEC_empty (symbolp, info.result.symbols)) { VEC_free (symbolp, info.result.symbols);