[RFA] Emit a warning for ineffective set VAR = EXP command

Maciej W. Rozycki macro@codesourcery.com
Fri May 4 19:02:00 GMT 2012


On Fri, 27 Apr 2012, Tristan Gingold wrote:

> the 'set VAR=EXP' command is a real trap for Ada (and maybe other 
> languages such as Pascal users), because the '=' is interpreted as 
> BINOP_EQUAL instead of BINOP_ASSIGN.  You often do not realize that the 
> current language is not C where you are using to command for registers 
> or convenience variables.
> 
> I simply propose to emit a warning if the expression is not an 
> assignment (or a comma expression).
> 
> No regressions on x86_64 GNU/Linux.
> 
> Ok for trunk ?
> 
> 2012-04-27  Tristan Gingold  <gingold@adacore.com>
> 
> 	* printcmd.c (set_command): Emit a warning if the expression is not
> 	an assignment.

 It does regress gdb.base/freebpcmd.exp apparently:

Breakpoint 1, main (argc=1, argv=0xbffff904) at .../gdb/testsuite/gdb.base/freebpcmd.c:27
27          printf (">>> %d\n", i); /* euphonium */
"odd "$79 = 39
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
warning: Expression is not an assignment (and might have no effect)
ERROR: internal buffer is full.
UNRESOLVED: gdb.base/freebpcmd.exp: run program with breakpoint commands

This warns about "set variable $j++" presumably -- should the warning be 
disabled for pre/post increments/decrements?

  Maciej



More information about the Gdb-patches mailing list