radare2/libr/bp/bp_plugin.c

64 lines
1.3 KiB
C
Raw Normal View History

2015-06-22 10:23:38 +00:00
/* radare - LGPL - Copyright 2009-2015 - pancake */
#include <r_bp.h>
2015-06-22 10:23:38 +00:00
R_API int r_bp_plugin_del(RBreakpoint *bp, const char *name) {
RListIter *iter;
RBreakpointPlugin *h;
2017-04-18 17:06:34 +00:00
if (name && *name) {
r_list_foreach (bp->plugins, iter, h) {
if (!strcmp (h->name, name)) {
if (bp->cur == h) {
bp->cur = NULL;
}
r_list_delete (bp->plugins, iter);
bp->nbps--;
return true;
}
}
}
2015-09-14 00:08:31 +00:00
return false;
}
R_API int r_bp_plugin_add(RBreakpoint *bp, RBreakpointPlugin *foo) {
RListIter *iter;
RBreakpointPlugin *h;
if (!bp) {
eprintf ("Cannot add plugin because dbg->bp is null and/or plugin is null\n");
2015-09-14 00:08:31 +00:00
return false;
}
/* avoid dupped plugins */
r_list_foreach (bp->bps, iter, h) {
if (!strcmp (h->name, foo->name)) {
2015-09-14 00:08:31 +00:00
return false;
}
}
bp->nbps++;
r_list_append (bp->plugins, foo);
2015-09-14 00:08:31 +00:00
return true;
}
2015-06-22 10:23:38 +00:00
R_API int r_bp_use(RBreakpoint *bp, const char *name, int bits) {
RListIter *iter;
2015-06-22 10:23:38 +00:00
bp->bits = bits;
RBreakpointPlugin *h;
r_list_foreach (bp->plugins, iter, h) {
if (!strcmp (h->name, name)) {
bp->cur = h;
2015-09-14 00:08:31 +00:00
return true;
}
}
2015-09-14 00:08:31 +00:00
return false;
}
// TODO: deprecate
R_API void r_bp_plugin_list(RBreakpoint *bp) {
RListIter *iter;
RBreakpointPlugin *b;
r_list_foreach (bp->plugins, iter, b) {
bp->cb_printf ("bp %c %s\n",
(bp->cur && !strcmp (bp->cur->name, b->name))? '*': '-',
b->name);
}
}