Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <xdje42@gmail.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v3 02/19] Remove completion_tracker_t from the public completion API.
Date: Mon, 24 Aug 2015 16:06:00 -0000	[thread overview]
Message-ID: <m3fv38fz8o.fsf@sspiff.org> (raw)
In-Reply-To: <m3oahyizrm.fsf@sspiff.org> (Doug Evans's message of "Sat, 22 Aug	2015 18:01:33 -0700")

Doug Evans <xdje42@gmail.com> writes:
> Keith Seitz <keiths@redhat.com> writes:
>>...
>> gdb/ChangeLog
>>
>> 	PR gdb/17960
>> 	* completer.c (struct completer_data) <tracker>: Change type to
>> 	htab_t.
>> 	(enum maybe_add_completion_enum): Make private; moved from
>> 	completer.h.
>> 	[DEFAULT_MAX_COMPLETIONS]: Define.
>> 	(new_completion_tracker): Remove function.
>> 	(new_completer_data): New function.
>> 	(free_completion_tracker): Remove function.
>> 	(free_completer_data): New function.
>> 	(make_cleanup_free_completion_tracker): Remove function.
>> 	(maybe_add_completion): Make static.  Update comments.
>> 	Use completer_data instead of completion_tracker_t.
>> 	(completer_strdup): New function.
>> 	(add_completion): New function.
>> 	(complete_line, gdb_completion_word_break_characters): Use
>> 	completer_data instead of completion_tracker.
>> 	* completer.h (completion_tracker_t, new_completion_tracker)
>> 	(make_cleanup_free_completion_tracker, maybe_add_completion)
>> 	(enum maybe_add_completion): Remove declarations.
>> 	(enum add_completion_status): Define.
>> 	(add_completion): Declare.
>> 	* symtab.c (completion_tracker): Remove variable.
>> 	(completion_list_add_name): Use add_completion instead of
>> 	maybe_add_completion and partial copy.
>> 	(default_make_symbol_completion_list_break_on_1): Do not use
>> 	completion_tracker.
>>
>> gdb/testsuite/ChangeLog
>>
>> 	PR gdb/17960
>> 	* gdb.base/completion.exp: Add some basic tests for the
>> 	location completer, including a regression test for
>> 	the gdb/17960 assertion failure.
>>...
>> @@ -803,48 +824,41 @@ complete_line_internal (struct completer_data *cdata,
>>  
>>  /* See completer.h.  */
>>  
>> -int max_completions = 200;
>> +#define DEFAULT_MAX_COMPLETIONS 200
>> +int max_completions = DEFAULT_MAX_COMPLETIONS;
>>  
>> -/* See completer.h.  */
>> +/* Allocate a new completer data structure.  */
>>  
>> -completion_tracker_t
>> -new_completion_tracker (void)
>> +static struct completer_data *
>> +new_completer_data (int size)
>>  {
>> -  if (max_completions <= 0)
>> -    return NULL;
>> +  struct completer_data *cdata = XCNEW (struct completer_data);
>>  
>> -  return htab_create_alloc (max_completions,
>> -			    htab_hash_string, (htab_eq) streq,
>> -			    NULL, xcalloc, xfree);
>> +  cdata->tracker
>> +    = htab_create_alloc ((size < 0 ? DEFAULT_MAX_COMPLETIONS : size),
>> +			 htab_hash_string, (htab_eq) streq, NULL,
>
> ====
>...
> I'm also slightly ambivalent on creating the hash table if
> max_completions is disabled (<= 0), and leaning towards not creating it
> to avoid potential confusion.
> Let's do the latter (pending reading the rest of the patchset - maybe
> there's a good reason to always create it).

Coming back to this now that I've gone through the entire series.
I now understand why the hashtable is always created. :-)
-> because it's now the only repository of completions.
So that's ok.

As I read the code the question "What does htab_create_alloc do if I
pass it a size of zero?" comes to mind.
It'll just start with a table size of the first prime it uses.
So that's ok.

I then checked the callers of new_completer_data:

complete_line does this:

  if (max_completions == 0)
    return NULL;

but gdb_completion_word_break_characters doesn't have this check
so new_completer_data has to handle any value for max_completions.

I don't think there's a problem here
(IIUC gdb_completion_word_break_characters correctly).
At the least it would be good to specify in the function comment of
new_completer_data that any value for size (-ve, zero, +ve) is ok.


  reply	other threads:[~2015-08-24 16:06 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07  2:37 [PATCH v3 00/19] New completer API Keith Seitz
2015-08-06 19:18 ` [PATCH v3 09/19] Implement completion limiting for interpreter_completer Keith Seitz
2015-08-23  4:03   ` Doug Evans
2015-08-06 19:20 ` [PATCH v3 12/19] Implement completion limiting for sim_command_completer Keith Seitz
2015-08-23  4:11   ` Doug Evans
2015-08-06 19:58 ` [PATCH v3 04/19] Implement completion limiting for add_filename_to_list Keith Seitz
2015-08-23  1:07   ` Doug Evans
2015-08-06 19:58 ` [PATCH v3 02/19] Remove completion_tracker_t from the public completion API Keith Seitz
2015-08-23  1:02   ` Doug Evans
2015-08-24 16:06     ` Doug Evans [this message]
2015-08-06 19:58 ` [PATCH v3 19/19] Remove the vector return result from the " Keith Seitz
2015-08-23 18:03   ` Doug Evans
2015-08-06 19:58 ` [PATCH v3 18/19] Use the hashtable to accumulate completion results Keith Seitz
2015-08-23 17:53   ` Doug Evans
2015-08-06 19:58 ` [PATCH v3 06/19] Implement completion limiting for condition_completer Keith Seitz
2015-08-23  3:53   ` Doug Evans
2015-08-06 20:03 ` [PATCH v3 01/19] Add struct completer_data to the completion API Keith Seitz
2015-08-23  0:29   ` Doug Evans
2015-08-06 21:06 ` [PATCH v3 05/19] Implement completion limiting for ada_make_symbol_completion_list Keith Seitz
2015-08-23  3:47   ` Doug Evans
2015-08-06 21:06 ` [PATCH v3 17/19] Make the completion API completely opaque Keith Seitz
2015-08-23 15:14   ` Doug Evans
2015-08-06 22:03 ` [PATCH v3 07/19] Implement completion limiting for filename_completer Keith Seitz
2015-08-23  3:58   ` Doug Evans
2015-08-06 22:03 ` [PATCH v3 16/19] Implement completion limiting for tui_reggroup_completer Keith Seitz
2015-08-23  4:25   ` Doug Evans
2015-08-06 22:03 ` [PATCH v3 11/19] Implement completion limiting for reg_or_group_completer Keith Seitz
2015-08-23  4:09   ` Doug Evans
2015-08-06 22:03 ` [PATCH v3 08/19] Implement completion limiting for signal_completer Keith Seitz
2015-08-23  3:59   ` Doug Evans
2015-08-06 22:03 ` [PATCH v3 13/19] Implement completion limiting for complete_on_enum Keith Seitz
2015-08-23  4:19   ` Doug Evans
2015-08-06 22:12 ` [PATCH v3 14/19] Implement completion limiting in add_struct_fields Keith Seitz
2015-08-23  4:23   ` Doug Evans
2015-08-06 22:12 ` [PATCH v3 10/19] Implement completion limiting for cmdpy_completer Keith Seitz
2015-08-23  4:07   ` Doug Evans
2015-08-06 22:36 ` [PATCH v3 03/19] Implement completion-limiting for complete_on_cmdlist Keith Seitz
2015-08-23  1:05   ` Doug Evans
2015-08-07  2:37 ` [PATCH v3 15/19] Implement completion limiting for scmcmd_add_completion Keith Seitz
2015-08-23  4:24   ` Doug Evans
2015-08-07 22:57 ` [PATCH v3 00/19] New completer API Andrew Burgess
2015-08-08  0:04   ` Keith Seitz
2015-08-08  6:44     ` Andrew Burgess
2015-08-08 16:25       ` Keith Seitz
2015-08-22 22:25         ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3fv38fz8o.fsf@sspiff.org \
    --to=xdje42@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox