Decl/def matching with templates without template parameters in the DW_AT_name

Simon Marchi
Mon Jan 16 21:18:40 GMT 2023

> The main thing I would want to avoid here is trying to put this extra
> name-construction into the indexer.  That will just slow it down -- but
> this is normally the most user-visible slow thing in gdb, and most CUs
> are of no interest anyway.
> The downside of this decision is that expansion may expand too many
> CUs.  So for example if there are a million instantiation of template X
> and the user types "break X<int>::method", gdb might expand every CU
> referencing X and then still only set one breakpoint.
> However if this is an issue I think the solution could be to be more
> selective at expansion time.  That is, let the user input "X<int>" match
> X, but then actually examine the DIE tree to decide if this match should
> result in an expansion.

This is my understanding of what you are saying.  Save the name without
the template part in the cooked index, but attach to it a data structure
that describes the template parameters.  When the user types, let's say,
"b my_class<int, 2>::my_method", "my_class<int, 2>" gets translated to
the name "my_class" plus a description of the concrete arguments (the
type argument "int" and the value argument 2).  Then, when checking if a
given CU should expanded, and we have a match for the "my_class" name,
we compare the data structures describing the parameters to the one
describing the arguments, see if it's really a match.  Does that sound

I'm just a bit worried that it might be difficult to implement this "is
there a match function", given the complex rules of C++ template
deduction.  But maybe it's not so bad, or we already have that logic


More information about the Gdb mailing list