]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/ChangeLog
Make strcmp_iw NOT ignore whitespace in the middle of tokens
authorPedro Alves <palves@redhat.com>
Fri, 24 Nov 2017 23:30:04 +0000 (23:30 +0000)
committerPedro Alves <palves@redhat.com>
Fri, 24 Nov 2017 23:30:04 +0000 (23:30 +0000)
commit0662b6a7c1b3b04a4ca31a09af703c91c7aa9646
treef4d2777ed27434ce96a3130325e36fd6dcc29b6f
parent276da9b31bd6e3eb8d1dd814c867266f59f29093
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.
gdb/ChangeLog
gdb/cp-support.c
gdb/language.c
gdb/utils.c
gdb/utils.h