2015-06-22 10:23:38 +00:00
|
|
|
/* radare - LGPL - Copyright 2009-2015 - pancake */
|
2009-09-13 22:37:28 +00:00
|
|
|
|
|
|
|
#include <r_bp.h>
|
|
|
|
|
2015-06-22 10:23:38 +00:00
|
|
|
R_API int r_bp_plugin_del(RBreakpoint *bp, const char *name) {
|
2017-04-06 13:59:19 +00:00
|
|
|
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;
|
2017-04-06 13:59:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-14 00:08:31 +00:00
|
|
|
return false;
|
2009-09-13 22:37:28 +00:00
|
|
|
}
|
|
|
|
|
2010-06-29 23:13:09 +00:00
|
|
|
R_API int r_bp_plugin_add(RBreakpoint *bp, RBreakpointPlugin *foo) {
|
|
|
|
RListIter *iter;
|
|
|
|
RBreakpointPlugin *h;
|
2016-09-19 12:44:47 +00:00
|
|
|
if (!bp) {
|
2010-06-29 23:13:09 +00:00
|
|
|
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;
|
2009-09-13 22:37:28 +00:00
|
|
|
}
|
|
|
|
/* avoid dupped plugins */
|
2010-06-29 23:13:09 +00:00
|
|
|
r_list_foreach (bp->bps, iter, h) {
|
2017-04-06 13:59:19 +00:00
|
|
|
if (!strcmp (h->name, foo->name)) {
|
2015-09-14 00:08:31 +00:00
|
|
|
return false;
|
2017-04-06 13:59:19 +00:00
|
|
|
}
|
2009-09-13 22:37:28 +00:00
|
|
|
}
|
|
|
|
bp->nbps++;
|
2010-06-29 23:13:09 +00:00
|
|
|
r_list_append (bp->plugins, foo);
|
2015-09-14 00:08:31 +00:00
|
|
|
return true;
|
2009-09-13 22:37:28 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 10:23:38 +00:00
|
|
|
R_API int r_bp_use(RBreakpoint *bp, const char *name, int bits) {
|
2010-06-29 23:13:09 +00:00
|
|
|
RListIter *iter;
|
2015-06-22 10:23:38 +00:00
|
|
|
bp->bits = bits;
|
2010-06-29 23:13:09 +00:00
|
|
|
RBreakpointPlugin *h;
|
|
|
|
r_list_foreach (bp->plugins, iter, h) {
|
2010-03-02 23:13:22 +00:00
|
|
|
if (!strcmp (h->name, name)) {
|
2009-09-13 22:37:28 +00:00
|
|
|
bp->cur = h;
|
2015-09-14 00:08:31 +00:00
|
|
|
return true;
|
2009-09-13 22:37:28 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-14 00:08:31 +00:00
|
|
|
return false;
|
2009-09-13 22:37:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: deprecate
|
2010-06-29 23:13:09 +00:00
|
|
|
R_API void r_bp_plugin_list(RBreakpoint *bp) {
|
|
|
|
RListIter *iter;
|
|
|
|
RBreakpointPlugin *b;
|
|
|
|
r_list_foreach (bp->plugins, iter, b) {
|
2017-04-06 13:59:19 +00:00
|
|
|
bp->cb_printf ("bp %c %s\n",
|
|
|
|
(bp->cur && !strcmp (bp->cur->name, b->name))? '*': '-',
|
2009-09-13 22:37:28 +00:00
|
|
|
b->name);
|
|
|
|
}
|
|
|
|
}
|