/* Process record and replay target for GDB, the GNU debugger.
- Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GDB.
record the running message of inferior and set them to
record_arch_list, and add it to record_list. */
-struct record_message_args {
- struct regcache *regcache;
- enum target_signal signal;
-};
-
static int
-record_message (void *args)
+record_message (struct regcache *regcache, enum target_signal signal)
{
int ret;
- struct record_message_args *myargs = args;
- struct gdbarch *gdbarch = get_regcache_arch (myargs->regcache);
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct cleanup *old_cleanups = make_cleanup (record_arch_list_cleanups, 0);
record_arch_list_head = NULL;
if (record_list != &record_first) /* FIXME better way to check */
{
gdb_assert (record_list->type == record_end);
- record_list->u.end.sigval = myargs->signal;
+ record_list->u.end.sigval = signal;
}
- if (myargs->signal == TARGET_SIGNAL_0
+ if (signal == TARGET_SIGNAL_0
|| !gdbarch_process_record_signal_p (gdbarch))
ret = gdbarch_process_record (gdbarch,
- myargs->regcache,
- regcache_read_pc (myargs->regcache));
+ regcache,
+ regcache_read_pc (regcache));
else
ret = gdbarch_process_record_signal (gdbarch,
- myargs->regcache,
- myargs->signal);
+ regcache,
+ signal);
if (ret > 0)
error (_("Process record: inferior program stopped."));
return 1;
}
+struct record_message_args {
+ struct regcache *regcache;
+ enum target_signal signal;
+};
+
+static int
+record_message_wrapper (void *args)
+{
+ struct record_message_args *record_args = args;
+
+ return record_message (record_args->regcache, record_args->signal);
+}
+
static int
-do_record_message (struct regcache *regcache,
- enum target_signal signal)
+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, &args, NULL, RETURN_MASK_ALL);
+
+ return catch_errors (record_message_wrapper, &args, NULL, RETURN_MASK_ALL);
}
/* Set to 1 if record_store_registers and record_xfer_partial
error (_("Could not find 'to_insert_breakpoint' method on the target stack."));
if (!tmp_to_remove_breakpoint)
error (_("Could not find 'to_remove_breakpoint' method on the target stack."));
+ if (!tmp_to_stopped_by_watchpoint)
+ error (_("Could not find 'to_stopped_by_watchpoint' method on the target stack."));
+ if (!tmp_to_stopped_data_address)
+ error (_("Could not find 'to_stopped_data_address' method on the target stack."));
push_target (&record_ops);
}
tmp_to_xfer_partial = NULL;
tmp_to_insert_breakpoint = NULL;
tmp_to_remove_breakpoint = NULL;
+ tmp_to_stopped_by_watchpoint = NULL;
+ tmp_to_stopped_data_address = NULL;
/* Set the beneath function pointers. */
for (t = current_target.beneath; t != NULL; t = t->beneath)
}
static int record_resume_step = 0;
-static int record_resume_error;
/* "to_resume" target method. Resume the process record target. */
if (!RECORD_IS_REPLAY)
{
- if (do_record_message (get_current_regcache (), signal))
- {
- record_resume_error = 0;
- }
- else
- {
- record_resume_error = 1;
- return;
- }
+ record_message (get_current_regcache (), signal);
record_beneath_to_resume (record_beneath_to_resume_ops, ptid, 1,
signal);
}
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. */
&& status->value.sig == TARGET_SIGNAL_TRAP)
{
struct regcache *regcache;
+ struct address_space *aspace;
/* Yes -- this is likely our single-step finishing,
but check if there's any reason the core would be
registers_changed ();
regcache = get_current_regcache ();
tmp_pc = regcache_read_pc (regcache);
+ aspace = get_regcache_aspace (regcache);
if (target_stopped_by_watchpoint ())
{
/* Always interested in watchpoints. */
}
- else if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
- tmp_pc))
+ else if (breakpoint_inserted_here_p (aspace, tmp_pc))
{
/* There is a breakpoint here. Let the core
handle it. */
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- CORE_ADDR decr_pc_after_break
- = gdbarch_decr_pc_after_break (gdbarch);
- if (decr_pc_after_break)
- regcache_write_pc (regcache,
- tmp_pc + decr_pc_after_break);
+ if (software_breakpoint_inserted_here_p (aspace, tmp_pc))
+ {
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ CORE_ADDR decr_pc_after_break
+ = gdbarch_decr_pc_after_break (gdbarch);
+ if (decr_pc_after_break)
+ regcache_write_pc (regcache,
+ tmp_pc + decr_pc_after_break);
+ }
}
else
{
/* This must be a single-step trap. Record the
insn and issue another step. */
- if (!do_record_message (regcache, TARGET_SIGNAL_0))
- break;
+ if (!record_message_wrapper_safe (regcache,
+ TARGET_SIGNAL_0))
+ {
+ status->kind = TARGET_WAITKIND_STOPPED;
+ status->value.sig = TARGET_SIGNAL_0;
+ break;
+ }
record_beneath_to_resume (record_beneath_to_resume_ops,
ptid, 1,
{
struct regcache *regcache = get_current_regcache ();
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct address_space *aspace = get_regcache_aspace (regcache);
int continue_flag = 1;
int first_record_end = 1;
struct cleanup *old_cleanups = make_cleanup (record_wait_cleanups, 0);
if (execution_direction == EXEC_FORWARD)
{
tmp_pc = regcache_read_pc (regcache);
- if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
- tmp_pc))
+ if (breakpoint_inserted_here_p (aspace, tmp_pc))
{
+ int decr_pc_after_break = gdbarch_decr_pc_after_break (gdbarch);
+
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
"Process record: break at %s.\n",
paddress (gdbarch, tmp_pc));
- if (gdbarch_decr_pc_after_break (gdbarch)
- && !record_resume_step)
+
+ if (decr_pc_after_break
+ && !record_resume_step
+ && software_breakpoint_inserted_here_p (aspace, tmp_pc))
regcache_write_pc (regcache,
- tmp_pc +
- gdbarch_decr_pc_after_break (gdbarch));
+ tmp_pc + decr_pc_after_break);
goto replay_out;
}
}
/* check breakpoint */
tmp_pc = regcache_read_pc (regcache);
- if (breakpoint_inserted_here_p (get_regcache_aspace (regcache),
- tmp_pc))
+ if (breakpoint_inserted_here_p (aspace, tmp_pc))
{
+ int decr_pc_after_break
+ = gdbarch_decr_pc_after_break (gdbarch);
+
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
"Process record: break "
"at %s.\n",
paddress (gdbarch, tmp_pc));
- if (gdbarch_decr_pc_after_break (gdbarch)
+ if (decr_pc_after_break
&& execution_direction == EXEC_FORWARD
- && !record_resume_step)
+ && !record_resume_step
+ && software_breakpoint_inserted_here_p (aspace,
+ tmp_pc))
regcache_write_pc (regcache,
- tmp_pc +
- gdbarch_decr_pc_after_break (gdbarch));
+ tmp_pc + decr_pc_after_break);
continue_flag = 0;
}
if (record_hw_watchpoint)
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: hit hw watchpoint.\n");
+ fprintf_unfiltered (gdb_stdlog, "\
+Process record: hit hw watchpoint.\n");
continue_flag = 0;
}
/* Check target signal */
record_ops.to_insert_breakpoint = record_insert_breakpoint;
record_ops.to_remove_breakpoint = record_remove_breakpoint;
record_ops.to_stopped_by_watchpoint = record_stopped_by_watchpoint;
+ record_ops.to_stopped_data_address = record_stopped_data_address;
record_ops.to_can_execute_reverse = record_can_execute_reverse;
record_ops.to_stratum = record_stratum;
/* Add bookmark target methods. */
record_core_ops.to_insert_breakpoint = record_core_insert_breakpoint;
record_core_ops.to_remove_breakpoint = record_core_remove_breakpoint;
record_core_ops.to_stopped_by_watchpoint = record_stopped_by_watchpoint;
+ record_core_ops.to_stopped_data_address = record_stopped_data_address;
record_core_ops.to_can_execute_reverse = record_can_execute_reverse;
record_core_ops.to_has_execution = record_core_has_execution;
record_core_ops.to_stratum = record_stratum;
while (1)
{
int ret;
- uint8_t tmpu8;
+ uint8_t rectype;
uint32_t regnum, len, signal, count;
uint64_t addr;
/* We are finished when offset reaches osec_size. */
if (bfd_offset >= osec_size)
break;
- bfdcore_read (core_bfd, osec, &tmpu8, sizeof (tmpu8), &bfd_offset);
+ bfdcore_read (core_bfd, osec, &rectype, sizeof (rectype), &bfd_offset);
- switch (tmpu8)
+ switch (rectype)
{
case record_reg: /* reg */
/* Get register number to regnum. */