Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: Tom Tromey <tromey@redhat.com>,
	Joel Brobecker <brobecker@adacore.com>,
	 	Michael Snyder <msnyder@vmware.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] let record_resume fail immediately on error
Date: Thu, 26 Nov 2009 06:40:00 -0000	[thread overview]
Message-ID: <daef60380911252239t3cca40c5md94526d67085dcdd@mail.gmail.com> (raw)
In-Reply-To: <m3ws1exz97.fsf@fleche.redhat.com>

Hi guys,

What about following change:
Change record_message to record_message (struct regcache *regcache,
enum target_signal signal)

static int
record_message_wrapper_safe(struct regcache *regcache,
		   enum target_signal signal)
{
  struct record_message_args args;

  args.regcache = regcache;
  args.signal = signal;
  return catch_errors (record_message_wrapper, &args, NULL, RETURN_MASK_ALL);
}

static int
record_message_wrapper (void *args)
{
  return record_message (args->regcache, args->signal);
}

record_resume will call record_message.
record_wait will call record_message_wrapper_safe

Do you think it's OK?

Thanks,
Hui


On Thu, Nov 26, 2009 at 01:58, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>
>>> I don't like use TRY_CATCH or catch_errors directly.
>
> Joel> I confess that I don't like catch_errors, because of the need to
> Joel> artificially create a container type that contains all the function
> Joel> parameters.
>
> In this code, we already have the container type and untyped trampoline
> function.
>
> The problem I have with it is that there are direct calls to the untyped
> trampoline function.
>
> I think the general approach for using catch_errors in gdb ought to be:
>
> * Have a properly-typed function that does all the work.
> * If you need catch_errors, introduce a new type to hold the actual
>  arguments, and write an untyped trampoline function.  Then, *only*
>  call this trampoline function via catch_errors.
> * ... However, prefer TRY_CATCH in most cases, because it does not
>  require a new type and is generally safer (though not completely
>  safe).
>
> And FWIW, I think this rule is generally followed in practice.
>
> My reason for the above is that it is generally best to write a
> type-safe program and let the compiler diagnose errors.  We can't do
> this for catch_errors, due to limitations in C, but we can at least
> limit the damage.
>
>
> Also, this patch introduces an argument indicating whether or not to
> catch.  This is bad, because it is confusing, but also particularly bad
> in this case because the actual argument is always a constant.
>
> Tom
>


  reply	other threads:[~2009-11-26  6:40 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-08  4:03 Michael Snyder
2009-09-08  5:00 ` Hui Zhu
2009-09-08  6:59 ` Joel Brobecker
2009-09-08  7:23   ` Hui Zhu
2009-09-08  7:25     ` Hui Zhu
2009-09-08  7:53       ` Hui Zhu
2009-09-08 16:57         ` Michael Snyder
2009-09-09  2:05           ` Hui Zhu
2009-09-12  2:40             ` Hui Zhu
2009-09-24  3:10             ` Hui Zhu
2009-09-26 18:35               ` Michael Snyder
2009-09-27  2:51                 ` Hui Zhu
2009-09-28  9:27                 ` Hui Zhu
2009-09-28 18:12                   ` Joel Brobecker
2009-09-29  2:33                     ` Hui Zhu
2009-09-29 21:29                       ` Joel Brobecker
2009-09-29 23:57                         ` Hui Zhu
2009-10-14  2:10                           ` Joel Brobecker
2009-10-14  2:28                             ` Hui Zhu
2009-10-14  2:42                               ` Joel Brobecker
2009-10-15  4:38                                 ` Hui Zhu
2009-10-15  4:58                                   ` Joel Brobecker
2009-10-15  7:17                                     ` Hui Zhu
2009-10-15 16:23                                       ` Joel Brobecker
2009-10-15 17:18                                         ` Michael Snyder
2009-10-16  3:37                                           ` Hui Zhu
2009-10-20  3:17                                             ` Hui Zhu
2009-10-23  7:29                                               ` Hui Zhu
2009-11-03  2:17                                                 ` Hui Zhu
2009-11-03 18:57                                                   ` Michael Snyder
2009-11-04  5:15                                                     ` Hui Zhu
2009-11-10  7:02                                                       ` Hui Zhu
2009-11-10 22:05                                                         ` Tom Tromey
2009-11-11  0:55                                                           ` Hui Zhu
2009-11-24  6:16                                                             ` Hui Zhu
2009-11-24 17:14                                                               ` Tom Tromey
2009-11-25  2:00                                                                 ` Hui Zhu
2009-11-25 16:25                                                                   ` Joel Brobecker
2009-11-25 17:59                                                                     ` Tom Tromey
2009-11-26  6:40                                                                       ` Hui Zhu [this message]
2009-11-28  0:29                                                                         ` Hui Zhu
2009-12-01 22:27                                                                         ` Tom Tromey
2009-12-02  3:23                                                                           ` Hui Zhu
2009-12-07 15:01                                                                             ` Hui Zhu
2009-12-12  8:41                                                                             ` Hui Zhu
2009-12-21 20:45                                                                               ` Tom Tromey
2009-12-22  3:18                                                                                 ` Hui Zhu
2009-09-08 16:54       ` Michael Snyder
2009-09-08 16:52     ` Michael Snyder
2009-09-08 16:50   ` Michael Snyder
2009-09-08 17:05     ` Joel Brobecker

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=daef60380911252239t3cca40c5md94526d67085dcdd@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@vmware.com \
    --cc=tromey@redhat.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