Remove AT_SYMBOL
[deliverable/binutils-gdb.git] / gdb / record.c
index 9a4fbba6287437c41b870182e5d1b61a7f8ee2f6..7db15277eddaaa668746f80298abcb5b84deb05f 100644 (file)
@@ -1,6 +1,6 @@
 /* Process record and replay target for GDB, the GNU debugger.
 
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -896,6 +896,8 @@ record_open_1 (char *name, int from_tty)
   push_target (&record_ops);
 }
 
+static void record_init_record_breakpoints (void);
+
 /* "to_open" target method.  Open the process record target.  */
 
 static void
@@ -993,6 +995,8 @@ record_open (char *name, int from_tty)
   record_async_inferior_event_token
     = create_async_event_handler (record_async_inferior_event_handler,
                                  NULL);
+
+  record_init_record_breakpoints ();
 }
 
 /* "to_close" target method.  Close the process record target.  */
@@ -1718,24 +1722,97 @@ record_xfer_partial (struct target_ops *ops, enum target_object object,
                                          offset, len);
 }
 
-/* Behavior is conditional on RECORD_IS_REPLAY.
-   We will not actually insert or remove breakpoints when replaying,
-   nor when recording.  */
+/* This structure represents a breakpoint inserted while the record
+   target is active.  We use this to know when to install/remove
+   breakpoints in/from the target beneath.  For example, a breakpoint
+   may be inserted while recording, but removed when not replaying nor
+   recording.  In that case, the breakpoint had not been inserted on
+   the target beneath, so we should not try to remove it there.  */
+
+struct record_breakpoint
+{
+  /* The address and address space the breakpoint was set at.  */
+  struct address_space *address_space;
+  CORE_ADDR addr;
+
+  /* True when the breakpoint has been also installed in the target
+     beneath.  This will be false for breakpoints set during replay or
+     when recording.  */
+  int in_target_beneath;
+};
+
+typedef struct record_breakpoint *record_breakpoint_p;
+DEF_VEC_P(record_breakpoint_p);
+
+/* The list of breakpoints inserted while the record target is
+   active.  */
+VEC(record_breakpoint_p) *record_breakpoints = NULL;
+
+static void
+record_sync_record_breakpoints (struct bp_location *loc, void *data)
+{
+  if (loc->loc_type != bp_loc_software_breakpoint)
+      return;
+
+  if (loc->inserted)
+    {
+      struct record_breakpoint *bp = XNEW (struct record_breakpoint);
+
+      bp->addr = loc->target_info.placed_address;
+      bp->address_space = loc->target_info.placed_address_space;
+
+      bp->in_target_beneath = 1;
+
+      VEC_safe_push (record_breakpoint_p, record_breakpoints, bp);
+    }
+}
+
+/* Sync existing breakpoints to record_breakpoints.  */
+
+static void
+record_init_record_breakpoints (void)
+{
+  VEC_free (record_breakpoint_p, record_breakpoints);
+
+  iterate_over_bp_locations (record_sync_record_breakpoints);
+}
+
+/* Behavior is conditional on RECORD_IS_REPLAY.  We will not actually
+   insert or remove breakpoints in the real target when replaying, nor
+   when recording.  */
 
 static int
 record_insert_breakpoint (struct gdbarch *gdbarch,
                          struct bp_target_info *bp_tgt)
 {
+  struct record_breakpoint *bp;
+  int in_target_beneath = 0;
+
   if (!RECORD_IS_REPLAY)
     {
-      struct cleanup *old_cleanups = record_gdb_operation_disable_set ();
-      int ret = record_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
-
+      /* When recording, we currently always single-step, so we don't
+        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.  */
+      struct cleanup *old_cleanups;
+      int ret;
+
+      old_cleanups = record_gdb_operation_disable_set ();
+      ret = record_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
       do_cleanups (old_cleanups);
 
-      return ret;
+      if (ret != 0)
+       return ret;
+
+      in_target_beneath = 1;
     }
 
+  bp = XNEW (struct record_breakpoint);
+  bp->addr = bp_tgt->placed_address;
+  bp->address_space = bp_tgt->placed_address_space;
+  bp->in_target_beneath = in_target_beneath;
+  VEC_safe_push (record_breakpoint_p, record_breakpoints, bp);
   return 0;
 }
 
@@ -1745,17 +1822,35 @@ static int
 record_remove_breakpoint (struct gdbarch *gdbarch,
                          struct bp_target_info *bp_tgt)
 {
-  if (!RECORD_IS_REPLAY)
+  struct record_breakpoint *bp;
+  int ix;
+
+  for (ix = 0;
+       VEC_iterate (record_breakpoint_p, record_breakpoints, ix, bp);
+       ++ix)
     {
-      struct cleanup *old_cleanups = record_gdb_operation_disable_set ();
-      int ret = record_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
+      if (bp->addr == bp_tgt->placed_address
+         && bp->address_space == bp_tgt->placed_address_space)
+       {
+         if (bp->in_target_beneath)
+           {
+             struct cleanup *old_cleanups;
+             int ret;
 
-      do_cleanups (old_cleanups);
+             old_cleanups = record_gdb_operation_disable_set ();
+             ret = record_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
+             do_cleanups (old_cleanups);
+
+             if (ret != 0)
+               return ret;
+           }
 
-      return ret;
+         VEC_unordered_remove (record_breakpoint_p, record_breakpoints, ix);
+         return 0;
+       }
     }
 
-  return 0;
+  gdb_assert_not_reached ("removing unknown breakpoint");
 }
 
 /* "to_can_execute_reverse" method for process record target.  */
@@ -1817,16 +1912,10 @@ record_goto_bookmark (gdb_byte *bookmark, int from_tty)
   return;
 }
 
-static int record_async_mask_value = 1;
-
 static void
 record_async (void (*callback) (enum inferior_event_type event_type,
                                void *context), void *context)
 {
-  if (record_async_mask_value == 0)
-    internal_error (__FILE__, __LINE__,
-                   _("Calling record_async when async is masked"));
-
   /* If we're on top of a line target (e.g., linux-nat, remote), then
      set it to async mode as well.  Will be NULL if we're sitting on
      top of the core target, for "record restore".  */
@@ -1834,33 +1923,18 @@ record_async (void (*callback) (enum inferior_event_type event_type,
     record_beneath_to_async (callback, context);
 }
 
-static int
-record_async_mask (int new_mask)
-{
-  int curr_mask = record_async_mask_value;
-
-  record_async_mask_value = new_mask;
-  return curr_mask;
-}
-
 static int
 record_can_async_p (void)
 {
   /* We only enable async when the user specifically asks for it.  */
-  if (!target_async_permitted)
-    return 0;
-
-  return record_async_mask_value;
+  return target_async_permitted;
 }
 
 static int
 record_is_async_p (void)
 {
   /* We only enable async when the user specifically asks for it.  */
-  if (!target_async_permitted)
-    return 0;
-
-  return record_async_mask_value;
+  return target_async_permitted;
 }
 
 static enum exec_direction_kind
@@ -1899,7 +1973,6 @@ init_record_ops (void)
   record_ops.to_async = record_async;
   record_ops.to_can_async_p = record_can_async_p;
   record_ops.to_is_async_p = record_is_async_p;
-  record_ops.to_async_mask = record_async_mask;
   record_ops.to_execution_direction = record_execution_direction;
   record_ops.to_magic = OPS_MAGIC;
 }
@@ -2125,7 +2198,6 @@ init_record_core_ops (void)
   record_core_ops.to_async = record_async;
   record_core_ops.to_can_async_p = record_can_async_p;
   record_core_ops.to_is_async_p = record_is_async_p;
-  record_core_ops.to_async_mask = record_async_mask;
   record_core_ops.to_execution_direction = record_execution_direction;
   record_core_ops.to_magic = OPS_MAGIC;
 }
@@ -2885,6 +2957,9 @@ cmd_record_goto (char *arg, int from_tty)
   print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
 }
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_record;
+
 void
 _initialize_record (void)
 {
This page took 0.025561 seconds and 4 git commands to generate.