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: [RFA] Emit a warning for ineffective set VAR = EXP command


  As pascal language maintainer
I fully support this RFA.

  When debugging mixed language executable I quite often
forget that I passed from a C compiled function to
a pascal compiled one and you the C version
resulting in the same kind of troubles
as Tristan does.



Pierre Muller
GDB pascal language maintainer



> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tristan Gingold
> Envoyé?: vendredi 27 avril 2012 15:29
> À?: gdb-patches@sourceware.org ml
> Objet?: [RFA] Emit a warning for ineffective set VAR = EXP command
> 
> Hi,
> 
> 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.
> 
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index d441dfe..79e38f2 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -1080,6 +1080,12 @@ set_command (char *exp, int from_tty)
>    struct cleanup *old_chain =
>      make_cleanup (free_current_contents, &expr);
> 
> +  if (expr->nelts >= 1
> +      && expr->elts[0].opcode != BINOP_ASSIGN
> +      && expr->elts[0].opcode != BINOP_ASSIGN_MODIFY
> +      && expr->elts[0].opcode != BINOP_COMMA)
> +    warning (_("Expression is not an assignment (and might have no
> effect)"));
> +
>    evaluate_expression (expr);
>    do_cleanups (old_chain);
>  }


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