/* The breakpoint's type. */
enum bkpt_type type;
+ /* Link to this breakpoint's raw breakpoint. This is always
+ non-NULL. */
+ struct raw_breakpoint *raw;
+};
+
+/* Breakpoint requested by GDB. */
+
+struct gdb_breakpoint
+{
+ struct breakpoint base;
+
/* Pointer to the condition list that should be evaluated on
the target or NULL if the breakpoint is unconditional or
if GDB doesn't want us to evaluate the conditionals on the
/* Point to the list of commands to run when this is hit. */
struct point_command_list *command_list;
+};
- /* Link to this breakpoint's raw breakpoint. This is always
- non-NULL. */
- struct raw_breakpoint *raw;
+/* Breakpoint used by GDBserver. */
+
+struct other_breakpoint
+{
+ struct breakpoint base;
/* Function to call when we hit this breakpoint. If it returns 1,
the breakpoint shall be deleted; 0 or if this callback is NULL,
int (*handler) (CORE_ADDR);
};
+/* Reinsert breakpoint. */
+
+struct reinsert_breakpoint
+{
+ struct breakpoint base;
+};
+
/* Return the breakpoint size from its kind. */
static int
}
}
+/* Return true if breakpoint TYPE is a GDB breakpoint. */
+
+static int
+is_gdb_breakpoint (enum bkpt_type type)
+{
+ return (type == gdb_breakpoint_Z0
+ || type == gdb_breakpoint_Z1
+ || type == gdb_breakpoint_Z2
+ || type == gdb_breakpoint_Z3
+ || type == gdb_breakpoint_Z4);
+}
+
int
any_persistent_commands (void)
{
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
{
- for (cl = bp->command_list; cl != NULL; cl = cl->next)
- if (cl->persistence)
- return 1;
+ if (is_gdb_breakpoint (bp->type))
+ {
+ struct gdb_breakpoint *gdb_bp = (struct gdb_breakpoint *) bp;
+
+ for (cl = gdb_bp->command_list; cl != NULL; cl = cl->next)
+ if (cl->persistence)
+ return 1;
+ }
}
return 0;
return NULL;
}
- bp = XCNEW (struct breakpoint);
- bp->type = type;
+ if (is_gdb_breakpoint (type))
+ {
+ struct gdb_breakpoint *gdb_bp = XCNEW (struct gdb_breakpoint);
+
+ bp = (struct breakpoint *) gdb_bp;
+ gdb_assert (handler == NULL);
+ }
+ else if (type == other_breakpoint)
+ {
+ struct other_breakpoint *other_bp = XCNEW (struct other_breakpoint);
+
+ other_bp->handler = handler;
+ bp = (struct breakpoint *) other_bp;
+ }
+ else if (type == reinsert_breakpoint)
+ {
+ struct reinsert_breakpoint *reinsert_bp
+ = XCNEW (struct reinsert_breakpoint);
+ bp = (struct breakpoint *) reinsert_bp;
+ }
+ else
+ gdb_assert_not_reached ("unhandled breakpoint type");
+
+ bp->type = type;
bp->raw = raw;
- bp->handler = handler;
bp->next = proc->breakpoints;
proc->breakpoints = bp;
address ADDR and return a pointer to its structure. If KIND is -1,
the breakpoint's kind is ignored. */
-static struct breakpoint *
+static struct gdb_breakpoint *
find_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind)
{
struct process_info *proc = current_process ();
for (bp = proc->breakpoints; bp != NULL; bp = bp->next)
if (bp->type == type && bp->raw->pc == addr
&& (kind == -1 || bp->raw->kind == kind))
- return bp;
+ return (gdb_breakpoint *) bp;
return NULL;
}
failure returns NULL and sets *ERR to either -1 for error, or 1 if
Z_TYPE breakpoints are not supported on this target. */
-static struct breakpoint *
+static struct gdb_breakpoint *
set_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int kind, int *err)
{
- struct breakpoint *bp;
+ struct gdb_breakpoint *bp;
enum bkpt_type type;
enum raw_bkpt_type raw_type;
if (bp != NULL)
{
- if (bp->raw->kind != kind)
+ if (bp->base.raw->kind != kind)
{
/* A different kind than previously seen. The previous
breakpoint must be gone then. */
- bp->raw->inserted = -1;
- delete_breakpoint (bp);
+ bp->base.raw->inserted = -1;
+ delete_breakpoint ((struct breakpoint *) bp);
bp = NULL;
}
else if (z_type == Z_PACKET_SW_BP)
raw_type = Z_packet_to_raw_bkpt_type (z_type);
type = Z_packet_to_bkpt_type (z_type);
- return set_breakpoint (type, raw_type, addr, kind, NULL, err);
+ return (struct gdb_breakpoint *) set_breakpoint (type, raw_type, addr,
+ kind, NULL, err);
}
static int
/* See mem-break.h. This is a wrapper for set_gdb_breakpoint_1 that
knows to prepare to access memory for Z0 breakpoints. */
-struct breakpoint *
+struct gdb_breakpoint *
set_gdb_breakpoint (char z_type, CORE_ADDR addr, int kind, int *err)
{
- struct breakpoint *bp;
+ struct gdb_breakpoint *bp;
if (!check_gdb_bp_preconditions (z_type, err))
return NULL;
static int
delete_gdb_breakpoint_1 (char z_type, CORE_ADDR addr, int kind)
{
- struct breakpoint *bp;
+ struct gdb_breakpoint *bp;
int err;
bp = find_gdb_breakpoint (z_type, addr, kind);
/* Before deleting the breakpoint, make sure to free its condition
and command lists. */
clear_breakpoint_conditions_and_commands (bp);
- err = delete_breakpoint (bp);
+ err = delete_breakpoint ((struct breakpoint *) bp);
if (err != 0)
return -1;
/* Clear all conditions associated with a breakpoint. */
static void
-clear_breakpoint_conditions (struct breakpoint *bp)
+clear_breakpoint_conditions (struct gdb_breakpoint *bp)
{
struct point_cond_list *cond;
/* Clear all commands associated with a breakpoint. */
static void
-clear_breakpoint_commands (struct breakpoint *bp)
+clear_breakpoint_commands (struct gdb_breakpoint *bp)
{
struct point_command_list *cmd;
}
void
-clear_breakpoint_conditions_and_commands (struct breakpoint *bp)
+clear_breakpoint_conditions_and_commands (struct gdb_breakpoint *bp)
{
clear_breakpoint_conditions (bp);
clear_breakpoint_commands (bp);
/* Add condition CONDITION to GDBserver's breakpoint BP. */
static void
-add_condition_to_breakpoint (struct breakpoint *bp,
+add_condition_to_breakpoint (struct gdb_breakpoint *bp,
struct agent_expr *condition)
{
struct point_cond_list *new_cond;
/* Add a target-side condition CONDITION to a breakpoint. */
int
-add_breakpoint_condition (struct breakpoint *bp, char **condition)
+add_breakpoint_condition (struct gdb_breakpoint *bp, char **condition)
{
char *actparm = *condition;
struct agent_expr *cond;
gdb_condition_true_at_breakpoint_z_type (char z_type, CORE_ADDR addr)
{
/* Fetch registers for the current inferior. */
- struct breakpoint *bp = find_gdb_breakpoint (z_type, addr, -1);
+ struct gdb_breakpoint *bp = find_gdb_breakpoint (z_type, addr, -1);
ULONGEST value = 0;
struct point_cond_list *cl;
int err = 0;
/* Add commands COMMANDS to GDBserver's breakpoint BP. */
static void
-add_commands_to_breakpoint (struct breakpoint *bp,
+add_commands_to_breakpoint (struct gdb_breakpoint *bp,
struct agent_expr *commands, int persist)
{
struct point_command_list *new_cmd;
/* Add a target-side command COMMAND to the breakpoint at ADDR. */
int
-add_breakpoint_commands (struct breakpoint *bp, char **command,
+add_breakpoint_commands (struct gdb_breakpoint *bp, char **command,
int persist)
{
char *actparm = *command;
static int
gdb_no_commands_at_breakpoint_z_type (char z_type, CORE_ADDR addr)
{
- struct breakpoint *bp = find_gdb_breakpoint (z_type, addr, -1);
+ struct gdb_breakpoint *bp = find_gdb_breakpoint (z_type, addr, -1);
if (bp == NULL)
return 1;
run_breakpoint_commands_z_type (char z_type, CORE_ADDR addr)
{
/* Fetch registers for the current inferior. */
- struct breakpoint *bp = find_gdb_breakpoint (z_type, addr, -1);
+ struct gdb_breakpoint *bp = find_gdb_breakpoint (z_type, addr, -1);
ULONGEST value = 0;
struct point_command_list *cl;
int err = 0;
return;
}
- if (bp->handler != NULL && (*bp->handler) (stop_pc))
+ if (bp->type == other_breakpoint)
{
- *bp_link = bp->next;
+ struct other_breakpoint *other_bp
+ = (struct other_breakpoint *) bp;
+
+ if (other_bp->handler != NULL && (*other_bp->handler) (stop_pc))
+ {
+ *bp_link = bp->next;
- release_breakpoint (proc, bp);
+ release_breakpoint (proc, bp);
- bp = *bp_link;
- continue;
+ bp = *bp_link;
+ continue;
+ }
}
}
{
struct breakpoint *dest;
struct raw_breakpoint *dest_raw;
- struct point_cond_list *current_cond;
- struct point_cond_list *new_cond;
- struct point_cond_list *cond_tail = NULL;
- struct point_command_list *current_cmd;
- struct point_command_list *new_cmd;
- struct point_command_list *cmd_tail = NULL;
/* Clone the raw breakpoint. */
dest_raw = XCNEW (struct raw_breakpoint);
dest_raw->inserted = src->raw->inserted;
/* Clone the high-level breakpoint. */
- dest = XCNEW (struct breakpoint);
- dest->type = src->type;
- dest->raw = dest_raw;
- dest->handler = src->handler;
-
- /* Clone the condition list. */
- for (current_cond = src->cond_list; current_cond != NULL;
- current_cond = current_cond->next)
+ if (is_gdb_breakpoint (src->type))
{
- new_cond = XCNEW (struct point_cond_list);
- new_cond->cond = clone_agent_expr (current_cond->cond);
- APPEND_TO_LIST (&dest->cond_list, new_cond, cond_tail);
+ struct gdb_breakpoint *gdb_dest = XCNEW (struct gdb_breakpoint);
+ struct point_cond_list *current_cond;
+ struct point_cond_list *new_cond;
+ struct point_cond_list *cond_tail = NULL;
+ struct point_command_list *current_cmd;
+ struct point_command_list *new_cmd;
+ struct point_command_list *cmd_tail = NULL;
+
+ /* Clone the condition list. */
+ for (current_cond = ((struct gdb_breakpoint *) src)->cond_list;
+ current_cond != NULL;
+ current_cond = current_cond->next)
+ {
+ new_cond = XCNEW (struct point_cond_list);
+ new_cond->cond = clone_agent_expr (current_cond->cond);
+ APPEND_TO_LIST (&gdb_dest->cond_list, new_cond, cond_tail);
+ }
+
+ /* Clone the command list. */
+ for (current_cmd = ((struct gdb_breakpoint *) src)->command_list;
+ current_cmd != NULL;
+ current_cmd = current_cmd->next)
+ {
+ new_cmd = XCNEW (struct point_command_list);
+ new_cmd->cmd = clone_agent_expr (current_cmd->cmd);
+ new_cmd->persistence = current_cmd->persistence;
+ APPEND_TO_LIST (&gdb_dest->command_list, new_cmd, cmd_tail);
+ }
+
+ dest = (struct breakpoint *) gdb_dest;
}
+ else if (src->type == other_breakpoint)
+ {
+ struct other_breakpoint *other_dest = XCNEW (struct other_breakpoint);
- /* Clone the command list. */
- for (current_cmd = src->command_list; current_cmd != NULL;
- current_cmd = current_cmd->next)
+ other_dest->handler = ((struct other_breakpoint *) src)->handler;
+ dest = (struct breakpoint *) other_dest;
+ }
+ else if (src->type == reinsert_breakpoint)
{
- new_cmd = XCNEW (struct point_command_list);
- new_cmd->cmd = clone_agent_expr (current_cmd->cmd);
- new_cmd->persistence = current_cmd->persistence;
- APPEND_TO_LIST (&dest->command_list, new_cmd, cmd_tail);
+ struct reinsert_breakpoint *reinsert_dest
+ = XCNEW (struct reinsert_breakpoint);
+
+ dest = (struct breakpoint *) reinsert_dest;
}
+ else
+ gdb_assert_not_reached ("unhandled breakpoint type");
+
+ dest->type = src->type;
+ dest->raw = dest_raw;
return dest;
}