diff options
| author | Pedro Alves <palves@redhat.com> | 2017-11-24 23:30:04 +0000 | 
|---|---|---|
| committer | Pedro Alves <palves@redhat.com> | 2017-11-24 23:30:04 +0000 | 
| commit | 0662b6a7c1b3b04a4ca31a09af703c91c7aa9646 (patch) | |
| tree | f4d2777ed27434ce96a3130325e36fd6dcc29b6f /gdb/python/python.c | |
| parent | 276da9b31bd6e3eb8d1dd814c867266f59f29093 (diff) | |
| download | binutils-0662b6a7c1b3b04a4ca31a09af703c91c7aa9646.zip binutils-0662b6a7c1b3b04a4ca31a09af703c91c7aa9646.tar.gz binutils-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/python/python.c')
0 files changed, 0 insertions, 0 deletions
