This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Handle var_uinteger/var_zuinteger and case var_integer/var_zinteger together.


Hi,

This patch broke "set remote hardware-breakpoint-limit -1" ("integer 4294967295 out of range"), which treats -1 as unlimited. The problem is the following lines:

>    case var_integer:
> +   case var_zinteger:
>      {
>        unsigned int val;


Since val is unsigned, -1 gets casted to UINT_MAX which subsequently fails:

>        else if (val >= INT_MAX)
>          error (_("integer %u out of range"), val);


I tried changing val to LONGEST, but that subsequently broke the "set listsize -1" test in the testsuite (or at least, it fails one of the test cases in testsuite/gdb.base/list.exp).

Actually, it's not clear to me what "set listsize -1" is supposed to do: in one place in the testsuite, it's supposed to be unlimited and "set listsize 0" is supposed to suppress printing, but in another place, "set listsize 0" is supposed to be unlimited. But running "set listsize -1", without my change, also leads to an error ("integer 4294967295 out of range"). The documentation does not make it clear either.

Yit
July 27, 2012


On Jul 18, 2012, at 2:51 PM, Yao Qi wrote:

> Hi,
> Similar to previous patch, this patch is also to handle case
> var_uinteger/var_zuinteger and case var_integer/var_zinteger together.
> This change removes some duplicated code, and applies range checking
> to the value of var_zuinteger and var_zinteger.
> 
> Note that my following patches will check the change of command
> option for some purpose, so better to handle these case statements
> as together we we can.
> 
> gdb:
> 
> 2012-07-18  Yao Qi  <yao@codesourcery.com>
> 
>    * cli/cli-setshow.c (do_setshow_command): Handle case 'var_uinteger'
>    and 'var_zuninteger' together.  Handle case 'var_integer' and
>    'var_zinteger' together.
> ---
> gdb/cli/cli-setshow.c |   16 ++++------------
> 1 files changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
> index 0f854e5..fabc4d7 100644
> --- a/gdb/cli/cli-setshow.c
> +++ b/gdb/cli/cli-setshow.c
> @@ -267,20 +267,22 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
>      }
>      break;
>    case var_uinteger:
> +   case var_zuinteger:
>      if (arg == NULL)
>        error_no_arg (_("integer to set it to."));
>      *(unsigned int *) c->var = parse_and_eval_long (arg);
> -     if (*(unsigned int *) c->var == 0)
> +     if (c->var_type == var_uinteger && *(unsigned int *) c->var == 0)
>        *(unsigned int *) c->var = UINT_MAX;
>      break;
>    case var_integer:
> +   case var_zinteger:
>      {
>        unsigned int val;
> 
>        if (arg == NULL)
>          error_no_arg (_("integer to set it to."));
>        val = parse_and_eval_long (arg);
> -       if (val == 0)
> +       if (val == 0 && c->var_type == var_integer)
>          *(int *) c->var = INT_MAX;
>        else if (val >= INT_MAX)
>          error (_("integer %u out of range"), val);
> @@ -288,16 +290,6 @@ do_setshow_command (char *arg, int from_tty, struct cmd_list_element *c)
>          *(int *) c->var = val;
>        break;
>      }
> -   case var_zinteger:
> -     if (arg == NULL)
> -       error_no_arg (_("integer to set it to."));
> -     *(int *) c->var = parse_and_eval_long (arg);
> -     break;
> -   case var_zuinteger:
> -     if (arg == NULL)
> -       error_no_arg (_("integer to set it to."));
> -     *(unsigned int *) c->var = parse_and_eval_long (arg);
> -     break;
>    case var_enum:
>      {
>        int i;
> -- 
> 1.7.7.6
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]