Makefiles: Flatten and sort file lists
[deliverable/binutils-gdb.git] / gdb / record-full.c
index e2a36cf76a63577ff1f9f6e2472f6a8631e15a5f..803c5d4612ed58caac8f18c6f5002d52abc11e5e 100644 (file)
@@ -1,6 +1,6 @@
 /* Process record and replay target for GDB, the GNU debugger.
 
-   Copyright (C) 2013-2015 Free Software Foundation, Inc.
+   Copyright (C) 2013-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -535,26 +535,18 @@ record_full_arch_list_add_end (void)
 }
 
 static void
-record_full_check_insn_num (int set_terminal)
+record_full_check_insn_num (void)
 {
   if (record_full_insn_num == record_full_insn_max_num)
     {
       /* Ask user what to do.  */
       if (record_full_stop_at_limit)
        {
-         int q;
-
-         if (set_terminal)
-           target_terminal_ours ();
-         q = yquery (_("Do you want to auto delete previous execution "
+         if (!yquery (_("Do you want to auto delete previous execution "
                        "log entries when record/replay buffer becomes "
-                       "full (record full stop-at-limit)?"));
-         if (set_terminal)
-           target_terminal_inferior ();
-         if (q)
-           record_full_stop_at_limit = 0;
-         else
+                       "full (record full stop-at-limit)?")))
            error (_("Process record: stopped by user."));
+         record_full_stop_at_limit = 0;
        }
     }
 }
@@ -583,7 +575,7 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal)
   record_full_arch_list_tail = NULL;
 
   /* Check record_full_insn_num.  */
-  record_full_check_insn_num (1);
+  record_full_check_insn_num ();
 
   /* If gdb sends a signal value to target_resume,
      save it in the 'end' field of the previous instruction.
@@ -651,7 +643,8 @@ struct record_full_message_args {
 static int
 record_full_message_wrapper (void *args)
 {
-  struct record_full_message_args *record_full_args = args;
+  struct record_full_message_args *record_full_args
+    = (struct record_full_message_args *) args;
 
   return record_full_message (record_full_args->regcache,
                              record_full_args->signal);
@@ -666,7 +659,7 @@ record_full_message_wrapper_safe (struct regcache *regcache,
   args.regcache = regcache;
   args.signal = signal;
 
-  return catch_errors (record_full_message_wrapper, &args, NULL,
+  return catch_errors (record_full_message_wrapper, &args, "",
                       RETURN_MASK_ALL);
 }
 
@@ -725,7 +718,8 @@ record_full_exec_insn (struct regcache *regcache,
        /* Nothing to do if the entry is flagged not_accessible.  */
         if (!entry->u.mem.mem_entry_not_accessible)
           {
-            gdb_byte *mem = (gdb_byte *) alloca (entry->u.mem.len);
+            gdb_byte *mem = (gdb_byte *) xmalloc (entry->u.mem.len);
+            struct cleanup *cleanup = make_cleanup (xfree, mem);
 
             if (record_debug > 1)
               fprintf_unfiltered (gdb_stdlog,
@@ -770,6 +764,8 @@ record_full_exec_insn (struct regcache *regcache,
                      record_full_stop_reason = TARGET_STOPPED_BY_WATCHPOINT;
                  }
               }
+
+           do_cleanups (cleanup);
           }
       }
       break;
@@ -873,7 +869,7 @@ record_full_open (const char *name, int from_tty)
 
   record_full_init_record_breakpoints ();
 
-  observer_notify_record_changed (current_inferior (),  1);
+  observer_notify_record_changed (current_inferior (),  1, "full", NULL);
 }
 
 /* "to_close" target method.  Close the process record target.  */
@@ -980,17 +976,7 @@ record_full_resume (struct target_ops *ops, ptid_t ptid, int step,
                   record_full_resume_step = 1;
                 }
               else
-                {
-                  /* This is a continue.
-                     Try to insert a soft single step breakpoint.  */
-                  if (!gdbarch_software_single_step (gdbarch,
-                                                     get_current_frame ()))
-                    {
-                      /* This system don't want use soft single step.
-                         Use hard sigle step.  */
-                      step = 1;
-                    }
-                }
+               step = !insert_single_step_breakpoints (gdbarch);
             }
         }
 
@@ -1006,6 +992,15 @@ record_full_resume (struct target_ops *ops, ptid_t ptid, int step,
     target_async (1);
 }
 
+/* "to_commit_resume" method for process record target.  */
+
+static void
+record_full_commit_resume (struct target_ops *ops)
+{
+  if (!RECORD_FULL_IS_REPLAY)
+    ops->beneath->to_commit_resume (ops->beneath);
+}
+
 static int record_full_get_sig = 0;
 
 /* SIGINT signal handler, registered by "to_wait" method.  */
@@ -1163,9 +1158,9 @@ record_full_wait_1 (struct target_ops *ops,
                             If insert success, set step to 0.  */
                          set_executing (inferior_ptid, 0);
                          reinit_frame_cache ();
-                         if (gdbarch_software_single_step (gdbarch,
-                                                            get_current_frame ()))
-                           step = 0;
+
+                         step = !insert_single_step_breakpoints (gdbarch);
+
                          set_executing (inferior_ptid, 1);
                        }
 
@@ -1176,6 +1171,7 @@ record_full_wait_1 (struct target_ops *ops,
                                            "target beneath\n");
                      ops->beneath->to_resume (ops->beneath, ptid, step,
                                               GDB_SIGNAL_0);
+                     ops->beneath->to_commit_resume (ops->beneath);
                      continue;
                    }
                }
@@ -1416,7 +1412,7 @@ static void
 record_full_registers_change (struct regcache *regcache, int regnum)
 {
   /* Check record_full_insn_num.  */
-  record_full_check_insn_num (0);
+  record_full_check_insn_num ();
 
   record_full_arch_list_head = NULL;
   record_full_arch_list_tail = NULL;
@@ -1542,7 +1538,7 @@ record_full_xfer_partial (struct target_ops *ops, enum target_object object,
        }
 
       /* Check record_full_insn_num */
-      record_full_check_insn_num (0);
+      record_full_check_insn_num ();
 
       /* Record registers change to list as an instruction.  */
       record_full_arch_list_head = NULL;
@@ -1646,6 +1642,7 @@ record_full_insert_breakpoint (struct target_ops *ops,
 {
   struct record_full_breakpoint *bp;
   int in_target_beneath = 0;
+  int ix;
 
   if (!RECORD_FULL_IS_REPLAY)
     {
@@ -1653,7 +1650,7 @@ record_full_insert_breakpoint (struct target_ops *ops,
         really need to install regular breakpoints in the inferior.
         However, we do have to insert software single-step
         breakpoints, in case the target can't hardware step.  To keep
-        things single, we always insert.  */
+        things simple, we always insert.  */
       struct cleanup *old_cleanups;
       int ret;
 
@@ -1667,6 +1664,22 @@ record_full_insert_breakpoint (struct target_ops *ops,
       in_target_beneath = 1;
     }
 
+  /* Use the existing entries if found in order to avoid duplication
+     in record_full_breakpoints.  */
+
+  for (ix = 0;
+       VEC_iterate (record_full_breakpoint_p,
+                   record_full_breakpoints, ix, bp);
+       ++ix)
+    {
+      if (bp->addr == bp_tgt->placed_address
+         && bp->address_space == bp_tgt->placed_address_space)
+       {
+         gdb_assert (bp->in_target_beneath == in_target_beneath);
+         return 0;
+       }
+    }
+
   bp = XNEW (struct record_full_breakpoint);
   bp->addr = bp_tgt->placed_address;
   bp->address_space = bp_tgt->placed_address_space;
@@ -1680,7 +1693,8 @@ record_full_insert_breakpoint (struct target_ops *ops,
 static int
 record_full_remove_breakpoint (struct target_ops *ops,
                               struct gdbarch *gdbarch,
-                              struct bp_target_info *bp_tgt)
+                              struct bp_target_info *bp_tgt,
+                              enum remove_bp_reason reason)
 {
   struct record_full_breakpoint *bp;
   int ix;
@@ -1700,15 +1714,18 @@ record_full_remove_breakpoint (struct target_ops *ops,
 
              old_cleanups = record_full_gdb_operation_disable_set ();
              ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch,
-                                                       bp_tgt);
+                                                       bp_tgt, reason);
              do_cleanups (old_cleanups);
 
              if (ret != 0)
                return ret;
            }
 
-         VEC_unordered_remove (record_full_breakpoint_p,
-                               record_full_breakpoints, ix);
+         if (reason == REMOVE_BREAKPOINT)
+           {
+             VEC_unordered_remove (record_full_breakpoint_p,
+                                   record_full_breakpoints, ix);
+           }
          return 0;
        }
     }
@@ -1948,6 +1965,7 @@ init_record_full_ops (void)
   record_full_ops.to_close = record_full_close;
   record_full_ops.to_async = record_full_async;
   record_full_ops.to_resume = record_full_resume;
+  record_full_ops.to_commit_resume = record_full_commit_resume;
   record_full_ops.to_wait = record_full_wait;
   record_full_ops.to_disconnect = record_disconnect;
   record_full_ops.to_detach = record_detach;
@@ -2167,7 +2185,8 @@ record_full_core_insert_breakpoint (struct target_ops *ops,
 static int
 record_full_core_remove_breakpoint (struct target_ops *ops,
                                    struct gdbarch *gdbarch,
-                                   struct bp_target_info *bp_tgt)
+                                   struct bp_target_info *bp_tgt,
+                                   enum remove_bp_reason reason)
 {
   return 0;
 }
@@ -2521,7 +2540,7 @@ cmd_record_full_restore (char *args, int from_tty)
 static void
 record_full_save_cleanups (void *data)
 {
-  bfd *obfd = data;
+  bfd *obfd = (bfd *) data;
   char *pathname = xstrdup (bfd_get_filename (obfd));
 
   gdb_bfd_unref (obfd);
This page took 0.030656 seconds and 4 git commands to generate.