Received: from eggs.gnu.org ([140.186.70.92]:47894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqJDY-00005o-2H for qemu-devel@nongnu.org; Mon, 08 Aug 2011 02:21:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QqJDW-00072V-RT for qemu-devel@nongnu.org; Mon, 08 Aug 2011 02:21:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QqJDW-00072P-Gv for qemu-devel@nongnu.org; Mon, 08 Aug 2011 02:21:38 -0400 From: Markus Armbruster References: <1312372647-6329-1-git-send-email-alevy@redhat.com> <4E3C1F76.30107@codemonkey.ws> <4E3C5BE2.8030500@codemonkey.ws> Date: Mon, 08 Aug 2011 08:21:33 +0200 In-Reply-To: (Blue Swirl's message of "Fri, 5 Aug 2011 21:23:04 +0000") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] monitor: HMP: fix consecutive integer expression parsing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Alon Levy , qemu-devel@nongnu.org Blue Swirl writes: > On Fri, Aug 5, 2011 at 9:08 PM, Anthony Liguori w= rote: >> On 08/05/2011 03:39 PM, Blue Swirl wrote: >>> >>> On Fri, Aug 5, 2011 at 4:51 PM, Anthony Liguori >>> =C2=A0wrote: >>>> >>>> On 08/03/2011 06:57 AM, Alon Levy wrote: >>>>> >>>>> Currently a command that takes two consecutive integer operations, li= ke >>>>> client_migrate_info, will be incorrectly parsed by the human monitor = if >>>>> the second expression begins with a minus ('-') or plus ('+') sign: >>>>> >>>>> client_migrate_info =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 >>>>> client_migrate_info spice localhost 5900 -1 >>>>> =3D> =C2=A0 =C2=A0port =3D 5899 =3D 5900 - 1 >>>>> =C2=A0 =C2=A0tls-port =3D -1 >>>>> But expected by the user to be: >>>>> =C2=A0 =C2=A0port =3D 5900 >>>>> =C2=A0 =C2=A0tls-port =3D -1 >>>>> >>>>> The fix is that for any required integer (ilM) expression followed by >>>>> another >>>>> integer expression (ilM) the first expression will be parsed by >>>>> expr_unary >>>>> instead of expr_sum. So you can still use arithmetic, but you have to >>>>> enclose >>>>> it in parenthesis: >>>>> >>>>> Command line | Old parsed result | With patch result >>>>> (1+1) 2 =C2=A0 =C2=A0 =C2=A0| 2, 2 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0| 2, 2 >>>>> 1 -1 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 0, -1 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | 1, -1 >>>>> The rest are bizarre but not any worse then before >>>>> 1+2+3 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 6, 5 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0| 1, 5 >>>>> (1+2)+3 =C2=A0 =C2=A0 =C2=A0| 3, 3 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0| 3, 3 >>>> >>>> I vote for just removing the expression parsing entirely. =C2=A0It's >>>> incredibly >>>> non-intuitive and I don't think anyone really uses it. >>>> >>>> Does anyone strongly object? >>> >>> I think the expressions would be useful with memory addresses, like >>> "xp/i $pc-4", but I usually start GDB in these cases. Can we disable >>> the expressions only for ports? >> >> Not sure what you mean by ports. =C2=A0You mean for anything but vc? =C2= =A0My goal in >> disabling the expressions would be to simplify the parsing by removing a= ll >> that messy code. > > Retain the parsing for only memory addresses, remove from other areas. Feasible, but we'd still be open to ambiguities around addresses, and we'd still be maintaining all that messy code. > Another way would be to require any expressions to be enclosed in > parentheses for all cases. Reduces the ambiguities, but some remain. Is (1 + 2) one argument (which can evaluate into the integer 3), or three arguments (which can evaluate into the strings/filenames/whatever "(1", "+" and "2)")? Depends on argument types, just like it does without parenthesis. > But I don't object to removing the code very much, as I said I use > GDB. Also the setjmp stuff is buggy. We have more important problems to solve than providing our users with yet another pocket calculator.