From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26789 invoked by alias); 8 May 2012 06:06:21 -0000 Received: (qmail 26767 invoked by uid 22791); 8 May 2012 06:06:18 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 May 2012 06:05:55 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SRdYY-0002v7-D1 from Maciej_Rozycki@mentor.com ; Mon, 07 May 2012 23:05:54 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 7 May 2012 23:05:44 -0700 Received: from [172.30.1.173] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.1.289.1; Tue, 8 May 2012 07:05:52 +0100 Date: Tue, 08 May 2012 06:06:00 -0000 From: "Maciej W. Rozycki" To: Tristan Gingold CC: "gdb-patches@sourceware.org ml" Subject: Re: [RFA] Emit a warning for ineffective set VAR = EXP command In-Reply-To: Message-ID: References: <8781499A-A489-42D0-80B1-75136331DBDB@adacore.com> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" 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-05/txt/msg00210.txt.bz2 On Mon, 7 May 2012, Tristan Gingold wrote: > > This warns about "set variable $j++" presumably -- should the warning be > > disabled for pre/post increments/decrements? > > I am not opposed to disable warnings for pre/post inc/dec. > But this usage is dubious (the help explicitly mentions VAR=EXP !) > > Opinion ? I think this is a bit too pedantic, there's no doubt these operators imply an assignment in C. I think the help text is clear enough with: "Evaluate expression EXP and assign result to variable VAR, using assignment syntax appropriate for the current language (VAR = EXP or VAR := EXP for example)." -- it quotes examples but these are by no means exhaustive and one can imply any assignment valid according to the language selected is going to be accepted. And there's quite a bunch of assignment operators defined for C. Note that this help text does not mention "VAR <<= EXP" either and there's no doubt this is a valid assignment in C too. If you're concerned about this then perhaps the offline manual could be more elaborate. I think one of our principles is to make debugging fast and efficient rather than picky about the input style and with that in mind we should accept any reasonable input from the user, sometimes even where it is not perfectly valid for the given language, e.g. you can ask GDB like this: (gdb) p/x (char[4])somevar to print SOMEVAR (e.g. an INT) as a 4-element character array even though this is really not something the C compiler would normally accept. I recall seeing this principle written down somewhere, but cannot track it down right now. I use such constructs all the time, especially when referring to CPU registers and I think it would be an unnecessary burden if rather than: (gdb) set $a0++ I had to write: (gdb) set $a0 += 1 or maybe even: (gdb) set $a0 = $a0 + 1 That's IMHO an unnecessary waste of time, keyboard, etc. (note that += is actually explicitly mentioned in the manual). Maciej