aboutsummaryrefslogtreecommitdiff
path: root/gdb/language.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-11-24 23:30:04 +0000
committerPedro Alves <palves@redhat.com>2017-11-24 23:30:04 +0000
commit0662b6a7c1b3b04a4ca31a09af703c91c7aa9646 (patch)
treef4d2777ed27434ce96a3130325e36fd6dcc29b6f /gdb/language.c
parent276da9b31bd6e3eb8d1dd814c867266f59f29093 (diff)
downloadgdb-0662b6a7c1b3b04a4ca31a09af703c91c7aa9646.zip
gdb-0662b6a7c1b3b04a4ca31a09af703c91c7aa9646.tar.gz
gdb-0662b6a7c1b3b04a4ca31a09af703c91c7aa9646.tar.bz2
Make strcmp_iw NOT ignore whitespace in the middle of tokens
currently "b func tion" manages to set a breakpoint at "function" ! All these years I had never noticed this, but now that the linespec completer actually works, this easily happens by accident, with: "b func t<tab>" expecting to get "thread", but getting instead: "b func tion" ... Also, this: "b rettypefunc<int>" manages to set a breakpoint on "rettype func<int>()". These things happen due to strcmp_iw "magic". Fix it by teaching strcmp_iw about when can it skip whitespace. This required handling user-defined operators, and scope operators, complicating the code a bit, unfortunately. I added unit tests for all the corner cases I stumbled on, as I was developing this, and then in the end wrote a testsuite testcase covering many of the same things and more (to be added later). gdb/ChangeLog: 2017-11-24 Pedro Alves <palves@redhat.com> * cp-support.c (cp_symbol_name_matches_1): New, factored out from cp_fq_symbol_name_matches. Pass language_cplus to strncmp_with_mode. (cp_fq_symbol_name_matches): Call cp_symbol_name_matches_1. (selftests::test_cp_symbol_name_cmp): New. (_initialize_cp_support): Register "cp_symbol_name_matches" selftests. * language.c (default_symbol_name_matcher): Pass language_minimal to strncmp_iw_with_mode. * utils.c: Include "cp-support.h" and <algorithm>. (valid_identifier_name_char, cp_skip_operator_token, skip_ws) (cp_is_operator): New functions. (strncmp_iw_with_mode): Use them. Add language parameter. Don't skip whitespace in the symbol name when the lookup name doesn't have spaces, and vice versa. (strncmp_iw, strcmp_iw): Pass language to strncmp_iw_with_mode. * utils.h (strncmp_iw_with_mode): Add language parameter.
Diffstat (limited to 'gdb/language.c')
-rw-r--r--gdb/language.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/language.c b/gdb/language.c
index 76047c7..2a1419c 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -713,7 +713,7 @@ default_symbol_name_matcher (const char *symbol_search_name,
: strncmp_iw_mode::MATCH_PARAMS);
if (strncmp_iw_with_mode (symbol_search_name, name.c_str (), name.size (),
- mode) == 0)
+ mode, language_minimal) == 0)
{
if (match != NULL)
match->set_match (symbol_search_name);