From: Keith Seitz <keiths@redhat.com>
To: Doug Evans <dje@google.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 00/18] Implement full completer limiting
Date: Wed, 29 Apr 2015 19:19:00 -0000 [thread overview]
Message-ID: <55412566.2020403@redhat.com> (raw)
In-Reply-To: <CADPb22Qk60UzUDfPbZRGekUHj0nsATyipcwvFJiegr7gkmnQgQ@mail.gmail.com>
On 04/19/2015 08:21 PM, Doug Evans wrote:
> I've gone over the entire patch set. A few things I like, but there's
> at least one thing I'm concerned about. Replicating the above switch
> in each completer: IWBN to avoid such duplication.
> We should still be able to remove the global state and fix 17960.
The original patch series (necessarily IMO) exposed this
memory-management issue, and a global maintainer approved the change.
Surely the approving maintainer realized that this code would propagate
to other completer functions eventually, no? [I certainly hope the
maintainer did not accept that the complete_line hack would be long-lived!]
I can certainly change the series to add a function which attempts to
hide this detail. For example:
/* Returns whether the maximum number of completions has been
reached/exceeded. */
int
add_completion (struct completer_data *cdata, const char *match)
{
char *match = xstrdup (name);
enum maybe_add_completion_enum add_status;
add_status = maybe_add_completion (cdata, match);
switch (add_status)
{
case MAYBE_ADD_COMPLETION_OK:
VEC_safe_push (char_ptr, cdata->results, match);
break;
case MAYBE_ADD_COMPLETION_OK_MAX_REACHED:
VEC_safe_push (char_ptr, cdata->results, match);
return 1;
case MAYBE_ADD_COMPLETION_MAX_REACHED:
xfree (match);
return 1;
case MAYBE_ADD_COMPLETION_DUPLICATE:
xfree (match);
break;
}
return 0;
}
Given that completions (like symbol reading/searching) are extremely
time-consuming, one of my design goals was to not introduce anything
that might slow down completion, including multiple allocations and copying.
Unfortunately with this goal in mind, the use of this proposed function
(alone) can only be pushed into four of the fourteen functions dealing
with completions.
The ten remaining functions would require an additional malloc/copy or
yet another API function, e.g.,
add_completion_1/add_completionA/add_completion_Ex [:-)] to deal with
this case. All this to simply forgo checking the return result of
maybe_add_completion. I don't see the benefit.
Developers already have to deal with memory management in exception
handling, which is more complex than simply checking the return result
of a function -- especially in (what I would perceive as) cut-n-paste
code like this.
Or perhaps you had another idea in mind?
In any case, let me know what you'd like me to do, and I'll get right at it.
Keith
next prev parent reply other threads:[~2015-04-29 18:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-13 19:23 Keith Seitz
2015-04-13 19:23 ` [PATCH 05/18] Implement completion limiting for ada_make_symbol_completion_list Keith Seitz
2015-04-13 19:23 ` [PATCH 08/18] Implement completion limiting for signal_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 11/18] Implement completion limiting for reg_or_group_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 03/18] Implement completion limiting for complete_on_cmdlist Keith Seitz
2015-04-13 19:23 ` [PATCH 01/18] Add struct completer_data to the completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 04/18] Implement completion limiting for add_filename_to_list Keith Seitz
2015-04-13 19:23 ` [PATCH 18/18] Remove the vector return result from the completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 06/18] Implement completion limiting for condition_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 16/18] Make the completion API completely opaque Keith Seitz
2015-04-13 19:23 ` [PATCH 09/18] Implement completion limiting for interpreter_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 14/18] Implement completion limiting in add_struct_fields Keith Seitz
2015-04-13 19:23 ` [PATCH 07/18] Implement completion limiting for filename_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 17/18] Use the hashtable to accumulate completion results Keith Seitz
2015-04-13 19:23 ` [PATCH 02/18] Remove completion_tracker_t from the public completion API Keith Seitz
2015-04-13 19:23 ` [PATCH 10/18] Implement completion limiting for cmdpy_completer Keith Seitz
2015-04-13 19:23 ` [PATCH 15/18] Implement completion limiting for scmcmd_add_completion Keith Seitz
2015-04-13 19:23 ` [PATCH 12/18] Implement completion limiting for sim_command_completer Keith Seitz
2015-04-14 15:28 ` Mike Frysinger
2015-05-05 15:03 ` Keith Seitz
2015-05-05 15:34 ` Mike Frysinger
2015-05-05 15:53 ` Keith Seitz
2015-04-13 19:23 ` [PATCH 13/18] Implement completion limiting for complete_on_enum Keith Seitz
2015-04-20 3:21 ` [PATCH 00/18] Implement full completer limiting Doug Evans
2015-04-29 19:19 ` Keith Seitz [this message]
2015-04-30 0:26 ` 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=55412566.2020403@redhat.com \
--to=keiths@redhat.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
/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