Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Sean Callanan <scallanan@apple.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: terminate-on-error patch
Date: Tue, 30 Aug 2005 02:37:00 -0000	[thread overview]
Message-ID: <20050830023454.GA16189@nevyn.them.org> (raw)
In-Reply-To: <E8A4191D-3030-409D-950F-B5CA9651FD1E@apple.com>

On Thu, Aug 11, 2005 at 12:49:23PM -0700, Sean Callanan wrote:
> In general, it is desirable to have at least optional handling of  
> errors by scripts rather than having the scripts simply terminate in  
> all cases. I have a simple patch that adds this functionality to the  
> GDB command line.
> 
> When the test-and-set variable "terminate-on-error" is on (default),  
> the behavior is the same as unmodified GDB. When it is off, a failed  
> command does not terminate a script; rather, the $_error convenience  
> variable is set to 1. Upon a successful command execution, the  
> variable is set to 0.

I'm not thrilled with the approach, but GDB's CLI is generally
un-thrilling at present, and Mark and Michael seem in favor.  So let's
do it.

Thanks for the documentation and tests.  The minimum additional we'd
need to merge the patch would be a ChangeLog entry and a pass with the
GNU coding standards in mind; I'll pick out the highlights.

If you could arrange to not have your patches mauled, butchered, and
devastated by the Apple mail client and its bizarre approach to line
wrapping, that'd be good too.

> + /* Longjmp-safe wrapper for "execute_command".  */
> + extern struct gdb_exception safe_execute_command (struct ui_out *,  
> char *, int);
> +

Mark noted that you're over the 80-column limit here, and possibly
elsewhere.

> + #include "wrapper.h"

If you add includes, you need to update the dependencies in the
Makefile.

> + /* Terminate scripts on errors, rather than setting _error = 1 */

Comments end with a period and two spaces, please.

> !
> !       if(terminate_on_error)
> !         {
> !           execute_command (new_line, 0);
> !         }
> !       else
> !         {
> !           struct gdb_exception rv;
> !           struct value* rv_val;
> !
> !           rv = safe_execute_command (uiout, new_line, 0);
> !           rv_val = value_from_longest (builtin_type_int, (rv.error ! 
> = NO_ERROR));
> !           set_internalvar (lookup_internalvar ("_error"), rv_val);
> !         }
> !
>         ret = cmd->control_type;
>         break;

Needless braces (the first set) should generally be omitted.  Space
before parenthesis in the if ().

> + void
> + _initialize_cli_script (void)
> + {
> +   add_setshow_boolean_cmd("terminate-on-error", class_support,  
> &terminate_on_error,
> +                           "Set termination of scripts on command  
> errors.",
> +                           "Show script termination on command  
> errors.",
> +                           "Controls how scripts respond to command  
> errors: by terminating or setting $_error to 1.",
> +                           NULL, NULL, &setlist, &showlist);
> + }

Overlong line I think?  Also, I believe these are supposed to be
translated strings nowadays.  There's plenty of examples lying around.
And space before parenthesis again.

You probably need a prototype for this function, or GCC will warn.

> + Some @value{GDBN} commands cannot complete successfully, and must  
> terminate.

I found this a little unclear; maybe an example?

> + #include <stdio.h>
> +
> + int main(int argc, char** argv)
> + {
> +     printf("Hello world!\n");
> + }

We're trying to put copyright notices on all new tests.

> + # Copyright 2001, 2003 Free Software Foundation, Inc.

That's not right...

> + # Please email any bugs, comments, and/or additions to this file to:
> + # bug-gdb@prep.ai.mit.edu
> + # use this to debug:
> + #
> + # log_user 1

And neither is this bit; please omit.

> + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}"  
> executable {debug}] != "" } {
> +      gdb_suppress_entire_file "Testcase compile failed, so all  
> tests in this file will automatically fail."
> + }

Please don't add new uses of gdb_suppress_entire_file.  IIRC just
"return -1" will do fine.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


      parent reply	other threads:[~2005-08-30  2:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-11 22:23 Sean Callanan
2005-08-22 18:33 ` Michael Snyder
2005-08-22 19:56   ` Mark Kettenis
2005-08-30  2:37 ` Daniel Jacobowitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050830023454.GA16189@nevyn.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=scallanan@apple.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox