/* 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.
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,
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"
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
-set_breakpoint_at (CORE_ADDR where, void (*handler) (CORE_ADDR))
+set_breakpoint_at (CORE_ADDR where, int (*handler) (CORE_ADDR))
{
struct breakpoint *bp;
delete_breakpoint (bp);
}
-static void
+static int
reinsert_breakpoint_handler (CORE_ADDR stop_pc)
{
struct breakpoint *stop_bp, *orig_bp;
(*the_target->write_memory) (orig_bp->pc, breakpoint_data,
breakpoint_len);
orig_bp->reinserting = 0;
- delete_breakpoint (stop_bp);
+ return 1;
}
void
{
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.");
+ 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).");
return 0;
}
- (*bp->handler) (bp->pc);
- return 1;
+ if ((*bp->handler) (bp->pc))
+ {
+ delete_breakpoint (bp);
+ return 2;
+ }
+ else
+ return 1;
}
void