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] let record_resume fail immediately on error


Hi Michael and Tom,

I make a new prec-fix-error-handler.txt according to the Tom's idea in
http://sourceware.org/ml/gdb-patches/2009-11/msg00152.html

It add a new argument "catch" to do_record_message.  If catch is true,
it will call "record_message" with catch errors.  If not, it will call
"record_message" directly.

In "record_resume", it call do_record_message with "catch = 0".
In "record_wait", it call do_record_message with "catch = 1".

Please help me review it.

Thanks,
Hui

2009-11-10  Hui Zhu  <teawater@gmail.com>

	* record.c (do_record_message): Add new argument "catch".
	(record_resume_error): Deleted.
	(record_resume): Call do_record_message with catch is 1.
	(record_wait): Deleted record_resume_error.
	Set status when do_record_message need stop the inferior.

---
 record.c |   35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

--- a/record.c
+++ b/record.c
@@ -647,13 +647,17 @@ record_message (void *args)

 static int
 do_record_message (struct regcache *regcache,
-		   enum target_signal signal)
+		   enum target_signal signal, int catch)
 {
   struct record_message_args args;

   args.regcache = regcache;
   args.signal = signal;
-  return catch_errors (record_message, &args, NULL, RETURN_MASK_ALL);
+
+  if (catch)
+    return catch_errors (record_message, &args, NULL, RETURN_MASK_ALL);
+
+  return record_message (&args);
 }

 /* Set to 1 if record_store_registers and record_xfer_partial
@@ -954,7 +958,6 @@ record_close (int quitting)
 }

 static int record_resume_step = 0;
-static int record_resume_error;

 /* "to_resume" target method.  Resume the process record target.  */

@@ -966,15 +969,7 @@ record_resume (struct target_ops *ops, p

   if (!RECORD_IS_REPLAY)
     {
-      if (do_record_message (get_current_regcache (), signal))
-        {
-          record_resume_error = 0;
-        }
-      else
-        {
-          record_resume_error = 1;
-          return;
-        }
+      do_record_message (get_current_regcache (), signal, 0);
       record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
                                 signal);
     }
@@ -1038,14 +1033,6 @@ record_wait (struct target_ops *ops,

   if (!RECORD_IS_REPLAY && ops != &record_core_ops)
     {
-      if (record_resume_error)
-	{
-	  /* If record_resume get error, return directly.  */
-	  status->kind = TARGET_WAITKIND_STOPPED;
-	  status->value.sig = TARGET_SIGNAL_ABRT;
-	  return inferior_ptid;
-	}
-
       if (record_resume_step)
 	{
 	  /* This is a single step.  */
@@ -1090,8 +1077,12 @@ record_wait (struct target_ops *ops,
 		         stepping, therefore gdb will not stop.
 			 Therefore we will not return to gdb.
 		         Record the insn and resume.  */
-		      if (!do_record_message (regcache, TARGET_SIGNAL_0))
-			break;
+		      if (!do_record_message (regcache, TARGET_SIGNAL_0, 1))
+  			{
+                           status->kind = TARGET_WAITKIND_STOPPED;
+                           status->value.sig = TARGET_SIGNAL_0;
+                           break;
+  			}

 		      record_beneath_to_resume (record_beneath_to_resume_ops,
 						ptid, 1,


>
> OK. ?I will try to talk clear about it.
>
> I make do_record_message because in before, call a error in
> record_resume and record_wait will make inferior cannot keep running.
>
> Now, I found that call error in record_resume will not affect
> anything. ?So I change do_record_message to record_message in
> record_resume.
>
> But in record_wait, call error still make inferior cannot keep
> running, so I keep do_record_message.
>
> Thanks,
> Hui
>
>
> >
> >
> >> 2009-11-03 ?Hui Zhu ?<teawater@gmail.com>
> >>
> >> ? ? ? ?* record.c (record_resume_error): Deleted.
> >> ? ? ? ?(record_resume): Call record_message.
> >> ? ? ? ?(record_wait): Deleted record_resume_error.
> >> ? ? ? ?Set status when do_record_message need stop the inferior.
> >>
> >> ---
> >> ?record.c | ? 29 ++++++++++-------------------
> >> ?1 file changed, 10 insertions(+), 19 deletions(-)
> >>
> >> --- a/record.c
> >> +++ b/record.c
> >> @@ -954,7 +954,6 @@ record_close (int quitting)
> >> ?}
> >>
> >> ?static int record_resume_step = 0;
> >> -static int record_resume_error;
> >>
> >> ?/* "to_resume" target method. ?Resume the process record target. ?*/
> >>
> >> @@ -966,15 +965,11 @@ record_resume (struct target_ops *ops, p
> >>
> >> ? if (!RECORD_IS_REPLAY)
> >> ? ? {
> >> - ? ? ?if (do_record_message (get_current_regcache (), signal))
> >> - ? ? ? ?{
> >> - ? ? ? ? ?record_resume_error = 0;
> >> - ? ? ? ?}
> >> - ? ? ?else
> >> - ? ? ? ?{
> >> - ? ? ? ? ?record_resume_error = 1;
> >> - ? ? ? ? ?return;
> >> - ? ? ? ?}
> >> + ? ? ?struct record_message_args args;
> >> +
> >> + ? ? ?args.regcache = get_current_regcache ();
> >> + ? ? ?args.signal = signal;
> >> + ? ? ?record_message (&args);
> >> ? ? ? record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? signal);
> >> ? ? }
> >> @@ -1038,14 +1033,6 @@ record_wait (struct target_ops *ops,
> >>
> >> ? if (!RECORD_IS_REPLAY && ops != &record_core_ops)
> >> ? ? {
> >> - ? ? ?if (record_resume_error)
> >> - ? ? ? {
> >> - ? ? ? ? /* If record_resume get error, return directly. ?*/
> >> - ? ? ? ? status->kind = TARGET_WAITKIND_STOPPED;
> >> - ? ? ? ? status->value.sig = TARGET_SIGNAL_ABRT;
> >> - ? ? ? ? return inferior_ptid;
> >> - ? ? ? }
> >> -
> >> ? ? ? if (record_resume_step)
> >> ? ? ? ?{
> >> ? ? ? ? ?/* This is a single step. ?*/
> >> @@ -1091,7 +1078,11 @@ record_wait (struct target_ops *ops,
> >> ? ? ? ? ? ? ? ? ? ? ? ? Therefore we will not return to gdb.
> >> ? ? ? ? ? ? ? ? ? ? ? ? Record the insn and resume. ?*/
> >> ? ? ? ? ? ? ? ? ? ? ?if (!do_record_message (regcache, TARGET_SIGNAL_0))
> >> - ? ? ? ? ? ? ? ? ? ? ? break;
> >> + ? ? ? ? ? ? ? ? ? ? ? {
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? status->kind = TARGET_WAITKIND_STOPPED;
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? status->value.sig = TARGET_SIGNAL_0;
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? break;
> >> + ? ? ? ? ? ? ? ? ? ? ? }
> >>
> >> ? ? ? ? ? ? ? ? ? ? ?record_beneath_to_resume
> >> (record_beneath_to_resume_ops,
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ptid, 1,
> >
> >

Attachment: prec-fix-error-handler.txt
Description: Text document


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