This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/3] Support template lookups in strncmp_iw_with_mode


Hi Keith,

Exciting!  Thanks for pushing through with this.

I've run the new tests locally and noticed a couple duplicated
test messages.  Please fix those:

      2 PASS: gdb.linespec/cpcompletion.exp: template-no-list: compare "b -function template_struct::template_overload_fn" completion list with bp location list: matches
      2 PASS: gdb.linespec/cpcompletion.exp: template-no-list: compare "b template_struct::template_overload_fn" completion list with bp location list: matches


I've experimented a little (though not much) with the new
feature, and I ran into something that looks a bit odd.
Let me explain.

Using gdb.linespec/cpcompletion, we see:

 (gdb) complete b template2_fn<int, int>(template2_ret_typ
 b template2_fn<int, int>(template2_ret_type<int>, int, int)
                                           ^^^^^^^^^^^^^^^^^

 (gdb) complete b template2_fn<int, int>(template2_ret_type
 b template2_fn<int, int>(template2_ret_type, int, int)
                                            ^^^^^^^^^^^

Notice how in the first case, we completed at the character
before "template2_ret_type", and in that case, we include
the template parameters in the match.  

However, if we complete right at the end of "template2_ret_type",
as in the second case, then we don't include the template arguments.

Actually, I see the same if we complete before the parameters
too:

 (gdb) complete b template2_f
 b template2_fn<int, int>(template2_ret_type<int>, int, int)
               ^^^^^^^^^^^
 (gdb) complete b template2_fn
 b template2_fn(template2_ret_type<int>, int, int)
               ^

Did you notice this?  I was not able to reproduce the same
behavior with completing ABI tabs.

Otherwise, skimming the patch, I didn't find anything
that made me pause.  It all seems to fit in the existing framework.
I'm glad that this turned out to be not that invasive.

Can you address the above issues, and repost?  I suspect we'll
get this over with in the next iteration.

One tiny nit below:

>  int
>  strncmp_iw_with_mode (const char *string1, const char *string2,
>  		      size_t string2_len, strncmp_iw_mode mode,
>  		      enum language language,
> -		      completion_match_for_lcd *match_for_lcd)
> +		      completion_match_for_lcd *match_for_lcd,
> +		      bool ignore_template_params)
>  {
>    const char *string1_start = string1;
>    const char *end_str2 = string2 + string2_len;
> @@ -2327,6 +2351,44 @@ strncmp_iw_with_mode (const char *string1, const char *string2,
>  	    string1++;
>  	}
>  
> +      /* Skip C++ template parameters in the symbol name if the lookup name
> +	 doesn't include them.  E.g.:
> +
> +	 Case 1: User is looking for all functions named "foo".
> +	 string1: foo <...> (...)
> +	 string2: foo
> +
> +	 Case 2: User is looking for all methods named "foo" in all template
> +	         class instantiations.
> +	 string1: Foo<...>::foo <...> (...)
> +	 string2: Foo::foo (...)
> +
> +         Case 3: User is looking for a specific overload of a template
> +	         function or method.

Space vs tabs mixup above.

> +	 string1: foo<...>
> +	 string2: foo(...)
> +
Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]