Updated copyright notices for most files.
[deliverable/binutils-gdb.git] / gdb / gdbserver / mem-break.c
index 20281af7cd35cedc5f2094a842ad80a615c2201c..8f5872f284bf7c684b93190e7c898c2bc7dac3f3 100644 (file)
@@ -1,5 +1,5 @@
 /* Memory breakpoint operations for the remote server for GDB.
 /* Memory breakpoint operations for the remote server for GDB.
-   Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
 
    Contributed by MontaVista Software.
 
 
    Contributed by MontaVista Software.
 
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,9 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "server.h"
 
 
 #include "server.h"
 
@@ -41,14 +39,16 @@ struct breakpoint
      in the *next chain somewhere).  */
   struct breakpoint *breakpoint_to_reinsert;
 
      in the *next chain somewhere).  */
   struct breakpoint *breakpoint_to_reinsert;
 
-  /* Function to call when we hit this breakpoint.  */
-  void (*handler) (CORE_ADDR);
+  /* Function to call when we hit this breakpoint.  If it returns 1,
+     the breakpoint will be deleted; 0, it will be reinserted for
+     another round.  */
+  int (*handler) (CORE_ADDR);
 };
 
 struct breakpoint *breakpoints;
 
 void
 };
 
 struct breakpoint *breakpoints;
 
 void
-set_breakpoint_at (CORE_ADDR where, void (*handler) (CORE_ADDR))
+set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR))
 {
   struct breakpoint *bp;
 
 {
   struct breakpoint *bp;
 
@@ -121,7 +121,7 @@ delete_breakpoint_at (CORE_ADDR addr)
     delete_breakpoint (bp);
 }
 
     delete_breakpoint (bp);
 }
 
-static void
+static int
 reinsert_breakpoint_handler (CORE_ADDR stop_pc)
 {
   struct breakpoint *stop_bp, *orig_bp;
 reinsert_breakpoint_handler (CORE_ADDR stop_pc)
 {
   struct breakpoint *stop_bp, *orig_bp;
@@ -137,7 +137,7 @@ reinsert_breakpoint_handler (CORE_ADDR stop_pc)
   (*the_target->write_memory) (orig_bp->pc, breakpoint_data,
                               breakpoint_len);
   orig_bp->reinserting = 0;
   (*the_target->write_memory) (orig_bp->pc, breakpoint_data,
                               breakpoint_len);
   orig_bp->reinserting = 0;
-  delete_breakpoint (stop_bp);
+  return 1;
 }
 
 void
 }
 
 void
@@ -145,12 +145,12 @@ reinsert_breakpoint_by_bp (CORE_ADDR stop_pc, CORE_ADDR stop_at)
 {
   struct breakpoint *bp, *orig_bp;
 
 {
   struct breakpoint *bp, *orig_bp;
 
-  set_breakpoint_at (stop_at, reinsert_breakpoint_handler);
-
   orig_bp = find_breakpoint_at (stop_pc);
   if (orig_bp == NULL)
     error ("Could not find original breakpoint in list.");
 
   orig_bp = find_breakpoint_at (stop_pc);
   if (orig_bp == NULL)
     error ("Could not find original breakpoint in list.");
 
+  set_breakpoint_at (stop_at, reinsert_breakpoint_handler);
+
   bp = find_breakpoint_at (stop_at);
   if (bp == NULL)
     error ("Could not find breakpoint in list (reinserting by breakpoint).");
   bp = find_breakpoint_at (stop_at);
   if (bp == NULL)
     error ("Could not find breakpoint in list (reinserting by breakpoint).");
@@ -205,8 +205,13 @@ check_breakpoints (CORE_ADDR stop_pc)
       return 0;
     }
 
       return 0;
     }
 
-  (*bp->handler) (bp->pc);
-  return 1;
+  if ((*bp->handler) (bp->pc))
+    {
+      delete_breakpoint (bp);
+      return 2;
+    }
+  else
+    return 1;
 }
 
 void
 }
 
 void
This page took 0.02705 seconds and 4 git commands to generate.