From 64a9760601d3d8761fcf0aae121e69ca0cae1a9c Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Thu, 24 Feb 2022 16:42:22 -0800 Subject: Support template lookups in strncmp_iw_with_mode This patch adds support for wild template parameter list matches, similar to how ABI tags or function overloads are now handled. With this patch, users will be able to "gloss over" the details of matching template parameter lists. This is accomplished by adding (yet more) logic to strncmp_iw_with_mode to skip parameter lists if none is explicitly given by the user. Here's a simple example using gdb.linespec/cpls-ops.exp: Before ------ (gdb) ptype test_op_call type = struct test_op_call { public: void operator()(void); void operator()(int); void operator()(long); void operator()(int *); } (gdb) b test_op_call::operator() Breakpoint 1 at 0x400583: test_op_call::operator(). (3 locations) (gdb) i b Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x400583 in test_op_call::operator()(int) at cpls-ops.cc:43 1.2 y 0x40058e in test_op_call::operator()() at cpls-ops.cc:47 1.3 y 0x40059e in test_op_call::operator()(long) at cpls-ops.cc:51 The breakpoint at test_op_call::operator() was never set. After ----- (gdb) b test_op_call::operator() Breakpoint 1 at 0x400583: test_op_call::operator(). (4 locations) (gdb) i b Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x400583 in test_op_call::operator()(int) at cpls-ops.cc:43 1.2 y 0x40058e in test_op_call::operator()() at cpls-ops.cc:47 1.3 y 0x40059e in test_op_call::operator()(long) at cpls-ops.cc:51 1.4 y 0x4008d0 in test_op_call::operator()(int*) at cpls-ops.cc:57 Similar to how scope lookups work, passing "-qualified" to the break command will cause a literal lookup of the symbol. In the example immediately above, this will cause GDB to only find the three non-template functions. --- gdb/doc/gdb.texinfo | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gdb/doc') diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index a68cf31..504eb66 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -16888,6 +16888,21 @@ also use the @value{GDBN} command-line word completion facilities to list the available choices, or to finish the type list for you. @xref{Completion,, Command Completion}, for details on how to do this. +@item @r{Breakpoints in template functions} + +Similar to how overloaded symbols are handled, @value{GDBN} will ignore +template parameter lists when it encounters a symbol which includes a +C@t{++} template. This permits setting breakpoints on families of template functions +or functions whose parameters include template types. + +The @kbd{-qualified} flag may be used to override this behavior, causing +@value{GDBN} to search for a specific function or type. + +The @value{GDBN} command-line word completion facility also understands +template parameters and may be used to list available choices or finish +template parameter lists for you. @xref{Completion,, Command Completion}, for +details on how to do this. + @item @r{Breakpoints in functions with ABI tags} The GNU C@t{++} compiler introduced the notion of ABI ``tags'', which -- cgit v1.1