aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.h
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2018-02-23 10:07:29 -0800
committerKeith Seitz <keiths@redhat.com>2018-02-23 10:07:29 -0800
commitb1ecccc4cd06b922c2ea916f2902868de87f8a09 (patch)
tree24cc4fe619bd848a37e43a0e80256cfdd0d693a4 /gdb/utils.h
parentf79a0082509f184f852a7976dc254ce5368279fc (diff)
downloadbinutils-users/keiths/template-completion.zip
binutils-users/keiths/template-completion.tar.gz
binutils-users/keiths/template-completion.tar.bz2
Support template lookups in strncmp_iw_with_modeusers/keiths/template-completion
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>(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 <MULTIPLE> 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()<int> 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 <MULTIPLE> 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>(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/ChangeLog: * NEWS: Mention new template parameter support for locations/completion. * cp-support.c (cp_search_name_hash): Break on template parameter lists. (cp_symbol_name_matches_1): Tell strncmp_iw_with_mode to ignore template parameter lists. * utils.c (skip_template_parameter_list): New function. (strncmp_iw_with_mode): Support "ignoring" of template parameter lists. * utils.h (strncmp_iw_with_mode): Add new parameter `ignore_template_params'. gdb/doc/ChangeLog: * gdb.texinfo (Debugging C Plus Plus): Document setting breakpoints in templates. gdb/testsuite/ChangeLog: * gdb.cp/templates.cc (Foozle, operator<, operator<<): New. (main): Add uses of new functions/types. * gdb.cp/templates.exp: Add template parameter list tests. * gdb.linespec/cpcompletion.exp: Load data-structures.exp. (consume, maket, makearg, makefoo, test_makefoo_1, test_makefoo) (maketype, makem, test_makem_1, test_makem, template-class-with-method) (template-function-foo): New procedures. (template-ret-type): Split range completion to account for template names completing without template parameter list. Change "setting breakpoint without template parameter test" to pass. (test_driver): Call template-function-foo test procedure. * gdb.linespec/cpls-ops.exp (test_operator_ambiguous): Remove template restriction. Add new whitespace tests for template functions. * gdb.linespec/cpls.cc (foo, a, b, c, d, A, B, NA, NB): New template definitions. (template_function_foo): New function. (main): Call template_function_foo.
Diffstat (limited to 'gdb/utils.h')
-rw-r--r--gdb/utils.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/gdb/utils.h b/gdb/utils.h
index c1195f6..453ac59 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -57,11 +57,14 @@ enum class strncmp_iw_mode
MATCH_FOR_LCD is passed down so that the function can mark parts of
the symbol name as ignored for completion matching purposes (e.g.,
- to handle abi tags). */
+ to handle abi tags). If IGNORE_TEMPLATE_PARAMS is true, all template
+ parameter lists will be ignored when language is C++. */
+
extern 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 = NULL);
+ completion_match_for_lcd *match_for_lcd = NULL,
+ bool ignore_template_params = false);
/* Do a strncmp() type operation on STRING1 and STRING2, ignoring any
differences in whitespace. STRING2_LEN is STRING2's length.