From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47730 invoked by alias); 8 Aug 2017 20:55:29 -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 47716 invoked by uid 89); 8 Aug 2017 20:55:28 -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=tolerate, completing 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; Tue, 08 Aug 2017 20:55:27 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC90178ED0 for ; Tue, 8 Aug 2017 20:55:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CC90178ED0 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=keiths@redhat.com Received: from valrhona.uglyboxes.com (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 904616889C; Tue, 8 Aug 2017 20:55:25 +0000 (UTC) Subject: Re: [PATCH 28/40] lookup_name_info::make_ignore_params To: Pedro Alves , gdb-patches@sourceware.org References: <1496406158-12663-1-git-send-email-palves@redhat.com> <1496406158-12663-29-git-send-email-palves@redhat.com> From: Keith Seitz Message-ID: <74eadbb2-06b1-cad9-1214-6757e662f4b3@redhat.com> Date: Tue, 08 Aug 2017 20:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1496406158-12663-29-git-send-email-palves@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00156.txt.bz2 On 06/02/2017 05:22 AM, Pedro Alves wrote: > gdb/ChangeLog: > yyyy-mm-dd Pedro Alves > > * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add > unittests/lookup_name_info-selftests.c. > (SUBDIR_UNITTESTS_OBS): Add lookup_name_info-selftests.o. > * cp-support.c: Include "selftest.h". > (cp_remove_params_1): Rename from cp_remove_params. Add > 'require_param's parameter, and handle it. ^^ typo > (cp_remove_params): Reimplement. > (cp_remove_params_if_any): New. > (selftests::quote): New. > (selftests::check_remove_params): New. > (selftests::test_cp_remove_params): New. > (_initialize_cp_support): Install > selftests::test_cp_remove_params. > * cp-support.h (cp_remove_params_if_any): Declare. > * dwarf2read.c :Include "selftest.h". > (dw2_expand_symtabs_matching_symbol): Use > lookup_name_info::make_ignore_params. > (selftests::dw2_expand_symtabs_matching::mock_mapped_index) > (selftests::dw2_expand_symtabs_matching::string_or_null) > (selftests::dw2_expand_symtabs_matching::check_match) > (selftests::dw2_expand_symtabs_matching::test_symbols) > (selftests::dw2_expand_symtabs_matching::run_test): New. > (_initialize_dwarf2_read): Register > selftests::dw2_expand_symtabs_matching::run_test. > * psymtab.c (psym_expand_symtabs_matching): Use > lookup_name_info::make_ignore_params. > * symtab.c (demangle_for_lookup_info::demangle_for_lookup_info): > If the lookup name wants to ignore parameters, strip them. > (compare_symbol_name): Remove sym_text/sym_text_len parameters and > code handling '('. > (completion_list_add_name): Don't pass down sym_text/sym_text_len. > (default_collect_symbol_completion_matches_break_on): Don't try to > strip parameters. > * symtab.h (lookup_name_info::lookup_name_info): Add > 'ignore_parameters' parameter. > (lookup_name_info::ignore_parameters) > (lookup_name_info::make_ignore_params): New methods. > (lookup_name_info::m_ignore_parameters): New field. (class lookup_name_info) : ? (class lookup_name_into) : ? (class lookup_name_info) : ? > * unittests/lookup_name_info-selftests.c: New file. > * dwarf2read.c : > (selftests::dw2_expand_symtabs_matching::mock_mapped_index) > (selftests::dw2_expand_symtabs_matching::string_or_null) > (selftests::dw2_expand_symtabs_matching::check_match) > (selftests::dw2_expand_symtabs_matching::test_symbols) > (selftests::dw2_expand_symtabs_matching::run_test): New. > (_initialize_dwarf2_read): Register > selftests::dw2_expand_symtabs_matching::run_test. Just some trivial things that I noticed (inline). > diff --git a/gdb/cp-support.c b/gdb/cp-support.c > index 0095c6d..064a45b 100644 > --- a/gdb/cp-support.c > +++ b/gdb/cp-support.c > @@ -833,12 +834,14 @@ cp_func_name (const char *full_name) > return ret; > } > > -/* DEMANGLED_NAME is the name of a function, including parameters and > - (optionally) a return type. Return the name of the function without > - parameters or return type, or NULL if we can not parse the name. */ > +/* Helper for cp_remove_params. DEMANGLED_NAME is the name of a > + function, including parameters and (optionally) a return type. > + Return the name of the function without parameters or return type, > + or NULL if we can not parse the name. If COMPLETION_MODE is true, > + then tolerate a non-existing or unbalanced parameter list. */ s/COMPLETION_MODE/REQUIRE_PARAMS/ ? > -gdb::unique_xmalloc_ptr > -cp_remove_params (const char *demangled_name) > +static gdb::unique_xmalloc_ptr > +cp_remove_params_1 (const char *demangled_name, bool require_params) > { > bool done = false; > struct demangle_component *ret_comp; > @@ -874,10 +877,60 @@ cp_remove_params (const char *demangled_name) [snip] > +/* DEMANGLED_NAME is the name of a function, (optionally) including > + parameters and (optionally) a return type. Return the name of the > + function without parameters or return type, or NULL if we can not > + parse the name. If COMPLETION_MODE is true, then tolerate a > + non-existing or unbalanced parameter list. */ > + Shouldn't this comment be in cp-support.h? > +gdb::unique_xmalloc_ptr > +cp_remove_params_if_any (const char *qualified, bool completion_mode) > +{ > + /* Trying to remove parameters from the empty string fails. If > + we're completing / matching everything, avoid returning NULL [snip] > + /* Shouldn't this parse? Looks like a bug in > + cp_demangled_name_to_comp. */ Is there a bugzilla (or some other tracking) for this? > +#if 0 > + CHECK ("A::foo::func(int)", > + "A::foo::func"); > +#else > + CHECK_INCOMPL ("A::foo::func(int)", > + "A::foo"); > +#endif > + > + CHECK_INCOMPL ("A::foo + "A::foo"); > + > +#undef CHECK > +#undef CHECK_INCOMPL > +} > + > +} // namespace selftests > + > +#endif /* GDB_SELF_CHECK */ > + > /* Don't allow just "maintenance cplus". */ > > static void > diff --git a/gdb/cp-support.h b/gdb/cp-support.h > index dd42415..1cef3f7 100644 > --- a/gdb/cp-support.h > +++ b/gdb/cp-support.h > @@ -97,6 +97,9 @@ extern char *cp_func_name (const char *full_name); > > extern gdb::unique_xmalloc_ptr cp_remove_params (const char *qualified); > > +extern gdb::unique_xmalloc_ptr cp_remove_params_if_any > + (const char *qualified, bool completion_mode); [Add comment from cp-support.c?] > + > extern struct symbol **make_symbol_overload_list (const char *, > const char *); > > diff --git a/gdb/symtab.h b/gdb/symtab.h > index 4c8b1f6..a452804 100644 > --- a/gdb/symtab.h > +++ b/gdb/symtab.h > @@ -176,6 +178,16 @@ class lookup_name_info final > symbol_name_match_type match_type () const { return m_match_type; } > bool completion_mode () const { return m_completion_mode; } > const std::string &name () const { return m_name; } > + const bool ignore_parameters () const { return m_ignore_parameters; } > + > + /* Return a version of this lookup name that is usable with > + comparisons against symbols have have no parameter info, such as ^^^^^^^^^ typo > + psymbols and GDB index symbols. */ > + lookup_name_info make_ignore_params () const > + { > + return lookup_name_info (m_name, m_match_type, m_completion_mode, > + true /* ignore params */); > + } > > /* Get the search name hash for searches in language LANG. */ > unsigned int search_name_hash (language lang) const Keith