From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25196 invoked by alias); 27 Jul 2012 17:40:29 -0000 Received: (qmail 24994 invoked by uid 22791); 27 Jul 2012 17:40:26 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from server-nat-6.cs.umd.edu (HELO bacon.cs.umd.edu) (128.8.127.149) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Jul 2012 17:40:13 +0000 Received: from wireless-206-196-160-203.umd.edu (wireless-206-196-160-203.umd.edu [206.196.160.203]) (Authenticated sender: khooyp) by bacon.cs.umd.edu (Postfix) with ESMTPSA id 8CB7DB403DA; Fri, 27 Jul 2012 13:40:10 -0400 (EDT) Subject: Re: [PATCH] Handle var_uinteger/var_zuinteger and case var_integer/var_zinteger together. Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Khoo Yit Phang In-Reply-To: <1342637512-2018-1-git-send-email-yao@codesourcery.com> Date: Fri, 27 Jul 2012 17:40:00 -0000 Cc: Khoo Yit Phang , Content-Transfer-Encoding: quoted-printable Message-Id: <7A6A55B4-0293-4AD6-AB1F-B3169F8ADCC1@cs.umd.edu> References: <1342637512-2018-1-git-send-email-yao@codesourcery.com> To: Yao Qi X-CSD-MailScanner-ID: 8CB7DB403DA.A9484 X-CSD-MailScanner: Found to be clean X-CSD-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-50, required 5, autolearn=not spam, ALL_TRUSTED -50.00) X-CSD-MailScanner-From: khooyp@cs.umd.edu X-CSD-MailScanner-Watermark: 1344015611.17083@+l1AcOtH6UIRlwxWPPsY3A Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-07/txt/msg00702.txt.bz2 Hi, This patch broke "set remote hardware-breakpoint-limit -1" ("integer 429496= 7295 out of range"), which treats -1 as unlimited. The problem is the follo= wing 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 >=3D INT_MAX) > error (_("integer %u out of range"), val); I tried changing val to LONGEST, but that subsequently broke the "set lists= ize -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 listsiz= e 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 c= hange, also leads to an error ("integer 4294967295 out of range"). The docu= mentation 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. >=20 > 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. >=20 > gdb: >=20 > 2012-07-18 Yao Qi >=20 > * 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(-) >=20 > 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 =3D=3D NULL) > error_no_arg (_("integer to set it to.")); > *(unsigned int *) c->var =3D parse_and_eval_long (arg); > - if (*(unsigned int *) c->var =3D=3D 0) > + if (c->var_type =3D=3D var_uinteger && *(unsigned int *) c->var =3D= =3D 0) > *(unsigned int *) c->var =3D UINT_MAX; > break; > case var_integer: > + case var_zinteger: > { > unsigned int val; >=20 > if (arg =3D=3D NULL) > error_no_arg (_("integer to set it to.")); > val =3D parse_and_eval_long (arg); > - if (val =3D=3D 0) > + if (val =3D=3D 0 && c->var_type =3D=3D var_integer) > *(int *) c->var =3D INT_MAX; > else if (val >=3D 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 =3D val; > break; > } > - case var_zinteger: > - if (arg =3D=3D NULL) > - error_no_arg (_("integer to set it to.")); > - *(int *) c->var =3D parse_and_eval_long (arg); > - break; > - case var_zuinteger: > - if (arg =3D=3D NULL) > - error_no_arg (_("integer to set it to.")); > - *(unsigned int *) c->var =3D parse_and_eval_long (arg); > - break; > case var_enum: > { > int i; > --=20 > 1.7.7.6 >=20