*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / record.c
index e1a612102aafceea20b3fc3e91017338fbec3179..08ffb687e2e0502900e3cba2c12036d198e60f6f 100644 (file)
@@ -33,6 +33,7 @@
 #include "event-loop.h"
 #include "inf-loop.h"
 #include "gdb_bfd.h"
+#include "observer.h"
 
 #include <signal.h>
 
@@ -153,7 +154,7 @@ struct record_entry
 };
 
 /* This is the debug switch for process record.  */
-int record_debug = 0;
+unsigned int record_debug = 0;
 
 /* If true, query if PREC cannot record memory
    change of next instruction.  */
@@ -485,6 +486,20 @@ record_arch_list_add_reg (struct regcache *regcache, int regnum)
   return 0;
 }
 
+int
+record_read_memory (struct gdbarch *gdbarch,
+                   CORE_ADDR memaddr, gdb_byte *myaddr,
+                   ssize_t len)
+{
+  int ret = target_read_memory (memaddr, myaddr, len);
+
+  if (ret && record_debug)
+    printf_unfiltered (_("Process record: error reading memory "
+                        "at addr %s len = %ld.\n"),
+                      paddress (gdbarch, memaddr), (long) len);
+  return ret;
+}
+
 /* Record the value of a region of memory whose address is ADDR and
    length is LEN to record_arch_list.  */
 
@@ -497,20 +512,15 @@ record_arch_list_add_mem (CORE_ADDR addr, int len)
     fprintf_unfiltered (gdb_stdlog,
                        "Process record: add mem addr = %s len = %d to "
                        "record list.\n",
-                       paddress (target_gdbarch, addr), len);
+                       paddress (target_gdbarch (), addr), len);
 
   if (!addr)   /* FIXME: Why?  Some arch must permit it...  */
     return 0;
 
   rec = record_mem_alloc (addr, len);
 
-  if (target_read_memory (addr, record_get_loc (rec), len))
+  if (record_read_memory (target_gdbarch (), addr, record_get_loc (rec), len))
     {
-      if (record_debug)
-       fprintf_unfiltered (gdb_stdlog,
-                           "Process record: error reading memory at "
-                           "addr = %s len = %d.\n",
-                           paddress (target_gdbarch, addr), len);
       record_mem_release (rec);
       return -1;
     }
@@ -739,15 +749,9 @@ record_exec_insn (struct regcache *regcache, struct gdbarch *gdbarch,
                                   paddress (gdbarch, entry->u.mem.addr),
                                   entry->u.mem.len);
 
-            if (target_read_memory (entry->u.mem.addr, mem, entry->u.mem.len))
-              {
-                entry->u.mem.mem_entry_not_accessible = 1;
-                if (record_debug)
-                  warning (_("Process record: error reading memory at "
-                            "addr = %s len = %d."),
-                           paddress (gdbarch, entry->u.mem.addr),
-                           entry->u.mem.len);
-              }
+            if (record_read_memory (gdbarch,
+                                   entry->u.mem.addr, mem, entry->u.mem.len))
+             entry->u.mem.mem_entry_not_accessible = 1;
             else
               {
                 if (target_write_memory (entry->u.mem.addr, 
@@ -870,7 +874,7 @@ record_open_1 (char *name, int from_tty)
     error (_("Process record target can't debug inferior in non-stop mode "
             "(non-stop)."));
 
-  if (!gdbarch_process_record_p (target_gdbarch))
+  if (!gdbarch_process_record_p (target_gdbarch ()))
     error (_("Process record: the current architecture doesn't support "
             "record function."));
 
@@ -998,6 +1002,8 @@ record_open (char *name, int from_tty)
                                  NULL);
 
   record_init_record_breakpoints ();
+
+  observer_notify_record_changed (current_inferior (),  1);
 }
 
 /* "to_close" target method.  Close the process record target.  */
@@ -1680,7 +1686,7 @@ record_xfer_partial (struct target_ops *ops, enum target_object object,
          if (!query (_("Because GDB is in replay mode, writing to memory "
                        "will make the execution log unusable from this "
                        "point onward.  Write memory at address %s?"),
-                      paddress (target_gdbarch, offset)))
+                      paddress (target_gdbarch (), offset)))
            error (_("Process record canceled the operation."));
 
          /* Destroy the record from here forward.  */
@@ -2257,6 +2263,8 @@ cmd_record_stop (char *args, int from_tty)
       unpush_target (&record_ops);
       printf_unfiltered (_("Process record is stopped and all execution "
                            "logs are deleted.\n"));
+
+      observer_notify_record_changed (current_inferior (), 0);
     }
   else
     printf_unfiltered (_("Process record is not started.\n"));
@@ -2979,13 +2987,13 @@ _initialize_record (void)
   init_record_core_ops ();
   add_target (&record_core_ops);
 
-  add_setshow_zinteger_cmd ("record", no_class, &record_debug,
-                           _("Set debugging of record/replay feature."),
-                           _("Show debugging of record/replay feature."),
-                           _("When enabled, debugging output for "
-                             "record/replay feature is displayed."),
-                           NULL, show_record_debug, &setdebuglist,
-                           &showdebuglist);
+  add_setshow_zuinteger_cmd ("record", no_class, &record_debug,
+                            _("Set debugging of record/replay feature."),
+                            _("Show debugging of record/replay feature."),
+                            _("When enabled, debugging output for "
+                              "record/replay feature is displayed."),
+                            NULL, show_record_debug, &setdebuglist,
+                            &showdebuglist);
 
   c = add_prefix_cmd ("record", class_obscure, cmd_record_start,
                      _("Abbreviated form of \"target record\" command."),
This page took 0.130174 seconds and 4 git commands to generate.