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 15/19] Implement completion limiting for scmcmd_add_completion.
Date: Sun, 23 Aug 2015 04:24:00 -0000	[thread overview]
Message-ID: <m34mjqhbu2.fsf@sspiff.org> (raw)
In-Reply-To: <20150806191959.32159.97237.stgit@valrhona.uglyboxes.com> (Keith	Seitz's message of "Thu, 06 Aug 2015 12:20:20 -0700")

Keith Seitz <keiths@redhat.com> writes:
> Differences in this revision:
>
> 1. Free string memory after passing to add_completion.
>
> ---
>
> This patch converts scmcmd_add_completion to use add_completion and
> adds some tests for this new behavior.
>
> gdb/ChangeLog
>
> 	* guile/scm-cmd.c (cmdscm_add_completion): Add completer_data
> 	argument.  All callers updated.
> 	Use add_completion.
> 	Free memory associated with `item'.
>
> gdb/testsuite/ChangeLog
>
> 	* gdb.guile/scm-cmd.exp: Add completion limiting tests.

LGTM.
Another case for using common test_completion_limit?

> ---
>  gdb/guile/scm-cmd.c                 |   11 ++++++-----
>  gdb/testsuite/gdb.guile/scm-cmd.exp |   24 ++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
> index 58c79c8..1544c2b 100644
> --- a/gdb/guile/scm-cmd.c
> +++ b/gdb/guile/scm-cmd.c
> @@ -348,7 +348,8 @@ cmdscm_bad_completion_result (const char *msg, SCM completion)
>     The result is a boolean indicating success.  */
>  
>  static int
> -cmdscm_add_completion (SCM completion, VEC (char_ptr) **result)
> +cmdscm_add_completion (SCM completion, struct completer_data *cdata,
> +		       VEC (char_ptr) **result)
>  {
>    char *item;
>    SCM except_scm;
> @@ -370,8 +371,8 @@ cmdscm_add_completion (SCM completion, VEC (char_ptr) **result)
>        return 0;
>      }
>  
> -  VEC_safe_push (char_ptr, *result, item);
> -
> +  (void) add_completion (cdata, result, item, NULL, NULL);
> +  xfree (item);
>    return 1;
>  }
>  
> @@ -418,7 +419,7 @@ cmdscm_completer (struct completer_data *cdata,
>  	{
>  	  SCM next = scm_car (list);
>  
> -	  if (!cmdscm_add_completion (next, &result))
> +	  if (!cmdscm_add_completion (next, cdata, &result))
>  	    {
>  	      VEC_free (char_ptr, result);
>  	      goto done;
> @@ -442,7 +443,7 @@ cmdscm_completer (struct completer_data *cdata,
>  	      goto done;
>  	    }
>  
> -	  if (!cmdscm_add_completion (next, &result))
> +	  if (!cmdscm_add_completion (next, cdata, &result))
>  	    {
>  	      VEC_free (char_ptr, result);
>  	      goto done;
> diff --git a/gdb/testsuite/gdb.guile/scm-cmd.exp b/gdb/testsuite/gdb.guile/scm-cmd.exp
> index 53c0fdf..ac721c3 100644
> --- a/gdb/testsuite/gdb.guile/scm-cmd.exp
> +++ b/gdb/testsuite/gdb.guile/scm-cmd.exp
> @@ -196,6 +196,30 @@ gdb_test "test-scheme-error-cmd ugh" \
>      "Error occurred in Scheme-implemented GDB command." \
>      "call scheme-error command"
>  
> +# Test completion limiting.
> +set max_completions 2
> +gdb_test_no_output "set max-completions $max_completions"
> +set end "\\\*\\\*\\\* List may be truncated, "
> +append end "max-completions reached\\\. \\\*\\\*\\\*"
> +set test "limit complete completer-as-function 42\."
> +gdb_test_multiple "complete completer-as-function 42\." $test {
> +    "complete completer-as-function 42\\\." { exp_continue }
> +    -re "completer-as-function 42\\\.\[1-3\]\r\n" {
> +	incr seen
> +	exp_continue
> +    }
> +    -re ".*$end\r\n$gdb_prompt $" {
> +	if {$seen == $max_completions} {
> +	    pass $test
> +	} else {
> +	    fail "$test ($seen/$max_completions)"
> +	}
> +    }
> +    -re ".*$gdb_prompt $" {
> +	fail "$test (unlimited)"
> +    }
> +}
> +
>  # If there is a problem with object management, this can often trigger it.
>  # It is useful to do this last, after we've created a bunch of command objects.
>  


  reply	other threads:[~2015-08-23  4:24 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 19/19] Remove the vector return result from the completion API Keith Seitz
2015-08-23 18:03   ` Doug Evans
2015-08-06 19:58 ` [PATCH v3 02/19] Remove completion_tracker_t from the public " Keith Seitz
2015-08-23  1:02   ` Doug Evans
2015-08-24 16:06     ` 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 06/19] Implement completion limiting for condition_completer Keith Seitz
2015-08-23  3:53   ` 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 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 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: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 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 07/19] Implement completion limiting for filename_completer Keith Seitz
2015-08-23  3:58   ` 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 [this message]
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=m34mjqhbu2.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