Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Daniel Knezevic <daniel.knezevic@htecgroup.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>, Pedro Alves <pedro@palves.net>,
	Simon Marchi <simark@simark.ca>
Subject: Re: [PATCH v3] gdb/symtab.c Fix completion of template class members
Date: Tue, 3 Mar 2026 10:19:51 -0800	[thread overview]
Message-ID: <44171ae9-cd60-4c6d-950d-30276cd489eb@redhat.com> (raw)
In-Reply-To: <20260303103633.256157-1-daniel.knezevic@htecgroup.com>

Hi,

On 3/3/26 2:36 AM, Daniel Knezevic wrote:
> This is v3 of:
> https://inbox.sourceware.org/gdb-patches/20251113095559.404539-1-daniel.knezevic@htecgroup.com/raw
> 
> Do not break the symbol if it contains '<' or '>' characters.
> 
> This patch fixes formatting of the code and adds more tests for testing
> completion of nested template classes.

Thank you for the quick update. I just have a few trivial nits. There is
no need to submit a v4 solely for these.

> diff --git a/gdb/testsuite/gdb.cp/cpcompletion.cc b/gdb/testsuite/gdb.cp/cpcompletion.cc
> index b85f168928c..defbd75ad34 100644
> --- a/gdb/testsuite/gdb.cp/cpcompletion.cc
> +++ b/gdb/testsuite/gdb.cp/cpcompletion.cc
> @@ -74,6 +74,28 @@ struct baz
>     S s;
>   };
>   
> +/* The Outer class is used to test completion of nested template classes*/

Please end the comment with a period and two spaces. [That follows our
coding style guidelines.]

> +template <typename T>
> +struct Outer
> +{
> +  T value;
> +
> +  template <typename U>
> +  struct Inner
> +  {
> +    U inner_value;
> +    T outer_ref;
> +  };
> +
> +  Inner<int> get_int_inner () const
 > +  {> +    Inner<int> i;
> +    i.inner_value = 0;
> +    i.outer_ref = value;
> +    return i;
> +  }
> +};
> +
>   int main ()
>   {
>     baz<int> obj (2.3, 0.1);
> @@ -84,5 +106,9 @@ int main ()
>     Foo foo1;
>     foo1.set_foo (42);		// Set breakpoint here.
>     a.get();			// Prevent compiler from throwing 'a' away.
> +  Outer<double> outer;
> +  outer.value = 4.2;
> +  auto inner = outer.get_int_inner();

Need a space between function/method name and parentheses.

> +  Outer<double>::Inner<long> long_inner;
>     return 0;
>   }
> diff --git a/gdb/testsuite/gdb.cp/cpcompletion.exp b/gdb/testsuite/gdb.cp/cpcompletion.exp
> index 1fb9a6bf01d..9ae17026f7d 100644
> --- a/gdb/testsuite/gdb.cp/cpcompletion.exp
> +++ b/gdb/testsuite/gdb.cp/cpcompletion.exp
> @@ -137,3 +137,39 @@ with_test_prefix "expression with namespace" {
>   }
>   
>   test_gdb_complete_unique "break baz(int" "break baz(int, double)"
> +
> +# Test completion with a template class.
> +test_gdb_complete_unique "p baz<int>::" "p baz<int>::baz<double>(int, double)"
> +
> +# Test completion of nested template classes
> +with_test_prefix "nested template classes" {
> +    # Unlike in linespecs, tab- and complete-command completion work a
> +    # bit differently when completing around the scope operator.  The
> +    # matches in the tab-completion case only show the part of the
> +    # symbol after the scope, since ':' is a word break character.
> +
> +    set tab_completion_list {
> +	"Inner<int>"
> +	"Inner<long>"
> +	"get_int_inner() const"
> +    }
> +    test_gdb_complete_tab_multiple "ptype Outer<double>:" ":" $tab_completion_list
> +    test_gdb_complete_tab_multiple "ptype Outer<double>::" "" $tab_completion_list
> +
> +    # OTOH, the complete command must show the whole command, with
> +    # qualified symbol displayed as entered by the user.
> +    set cmd_completion_list {
> +	"Outer<double>::Inner<int>"
> +	"Outer<double>::Inner<long>"
> +	"Outer<double>::get_int_inner() const"
> +    }
> +    test_gdb_complete_cmd_multiple "ptype " "Outer<double>:" $cmd_completion_list
> +    test_gdb_complete_cmd_multiple "ptype " "Outer<double>::" $cmd_completion_list
> +    test_gdb_complete_cmd_multiple "ptype " "Outer<double>::Inn" {
> +	"Outer<double>::Inner<int>"
> +	"Outer<double>::Inner<long>"
> +    }
> +
> +    # Add a disambiguating character and we get a unique completion.
> +    test_gdb_complete_unique "ptype Outer<double>::g" "ptype Outer<double>::get_int_inner() const"

This last line looks a bit long. Suggest adding '\' between the
two arguments, moving the second argument to the next line.

> +}

Otherwise, this LGTM.

Reviewed-By: Keith Seitz <keiths@redhat.com>

Thank you!
Keith


  reply	other threads:[~2026-03-03 18:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 10:36 Daniel Knezevic
2026-03-03 18:19 ` Keith Seitz [this message]
2026-04-20 12:03   ` Daniel Knezevic
2026-04-27 15:28     ` Keith Seitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44171ae9-cd60-4c6d-950d-30276cd489eb@redhat.com \
    --to=keiths@redhat.com \
    --cc=daniel.knezevic@htecgroup.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox