Esempio n. 1
0
void
delete_breakpoint(struct process *proc, void *addr)
{
	debug(DEBUG_FUNCTION, "delete_breakpoint(pid=%d, addr=%p)", proc->pid, addr);

	struct process *leader = proc->leader;
	assert(leader != NULL);

	struct breakpoint *sbp = dict_find_entry(leader->breakpoints, addr);
	assert(sbp != NULL);
	/* This should only happen on out-of-memory conditions. */
	if (sbp == NULL)
		return;

	if (breakpoint_turn_off(sbp, proc) < 0) {
		fprintf(stderr, "Couldn't turn off the breakpoint %s@%p\n",
			breakpoint_name(sbp), sbp->addr);
		return;
	}
	if (sbp->enabled == 0) {
		proc_remove_breakpoint(leader, sbp);
		breakpoint_destroy(sbp);
		free(sbp);
	}
}
Esempio n. 2
0
void
proc_remove_breakpoint(struct Process *proc, struct breakpoint *bp)
{
	debug(DEBUG_FUNCTION, "proc_remove_breakpoint(pid=%d, %s@%p)",
	      proc->pid, breakpoint_name(bp), bp->addr);
	check_leader(proc);
	struct breakpoint *removed = dict_remove(proc->breakpoints, bp->addr);
	assert(removed == bp);
}
Esempio n. 3
0
int
proc_add_breakpoint(struct Process *proc, struct breakpoint *bp)
{
	debug(DEBUG_FUNCTION, "proc_add_breakpoint(pid=%d, %s@%p)",
	      proc->pid, breakpoint_name(bp), bp->addr);
	check_leader(proc);

	/* XXX We might merge bp->libsym instead of the following
	 * assert, but that's not necessary right now.  Read the
	 * comment in breakpoint_for_symbol.  */
	assert(dict_find_entry(proc->breakpoints, bp->addr) == NULL);

	if (dict_enter(proc->breakpoints, bp->addr, bp) < 0) {
		fprintf(stderr,
			"couldn't enter breakpoint %s@%p to dictionary: %s\n",
			breakpoint_name(bp), bp->addr, strerror(errno));
		return -1;
	}

	return 0;
}