Re: [RFA] let record_resume fail immediately on error

Hui Zhu
2009-11-24T06:16:06Z

[-- Attachment #1: Type: text/plain, Size: 3393 bytes --]

Hi guys,

I update this patch follow cvs-head and do a small change about the testsuite.
Please help me review it.

Thanks,
Hui

2009-11-24 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.

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

* gdb.reverse/sigall-reverse.exp: Adjust.

---
record.c | 35 +++++++++++--------------------
testsuite/gdb.reverse/sigall-reverse.exp | 2 -
2 files changed, 14 insertions(+), 23 deletions(-)

--- a/record.c
+++ b/record.c
@@ -650,13 +650,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
@@ -983,7 +987,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. */

@@ -995,15 +998,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);
}
@@ -1067,14 +1062,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. */
@@ -1130,8 +1117,12 @@ record_wait (struct target_ops *ops,
{
/* This must be a single-step trap. Record the
insn and issue another step. */
- 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,
--- a/testsuite/gdb.reverse/sigall-reverse.exp
+++ b/testsuite/gdb.reverse/sigall-reverse.exp
@@ -262,7 +262,7 @@ gdb_test "continue" \
"get signal TERM"
gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"

-gdb_test "continue" "Program received .*" "continue to sigall exit" \
+gdb_test "continue" "\[process \[0-9\]+ .*" "continue to sigall exit" \
"The next instruction is syscall exit_group.* program...y. or n. " \
"yes"

[-- Attachment #2: prec-fix-error-handler.txt --]
[-- Type: text/plain, Size: 2891 bytes --]

---
record.c | 35 +++++++++++--------------------
testsuite/gdb.reverse/sigall-reverse.exp | 2 -
2 files changed, 14 insertions(+), 23 deletions(-)

--- a/record.c
+++ b/record.c
@@ -650,13 +650,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
@@ -983,7 +987,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. */

@@ -995,15 +998,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);
}
@@ -1067,14 +1062,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. */
@@ -1130,8 +1117,12 @@ record_wait (struct target_ops *ops,
{
/* This must be a single-step trap. Record the
insn and issue another step. */
- 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,
--- a/testsuite/gdb.reverse/sigall-reverse.exp
+++ b/testsuite/gdb.reverse/sigall-reverse.exp
@@ -262,7 +262,7 @@ gdb_test "continue" \
"get signal TERM"
gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"

-gdb_test "continue" "Program received .*" "continue to sigall exit" \
+gdb_test "continue" "\[process \[0-9\]+ .*" "continue to sigall exit" \
"The next instruction is syscall exit_group.* program...y. or n. " \
"yes"