rizin/librz/bp/bp_plugin.c
Dean 59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00

69 lines
1.6 KiB
C

// SPDX-FileCopyrightText: 2009-2015 pancake <pancake@nopcode.org>
// SPDX-License-Identifier: LGPL-3.0-only
#include <rz_bp.h>
RZ_API int rz_bp_plugin_del(RzBreakpoint *bp, const char *name) {
RzListIter *iter;
RzBreakpointPlugin *h;
if (name && *name) {
rz_list_foreach (bp->plugins, iter, h) {
if (!strcmp(h->name, name)) {
if (bp->cur == h) {
bp->cur = NULL;
}
rz_list_delete(bp->plugins, iter);
bp->nbps--;
return true;
}
}
}
return false;
}
RZ_API bool rz_bp_plugin_add(RzBreakpoint *bp, RZ_BORROW RZ_NONNULL RzBreakpointPlugin *plugin) {
rz_return_val_if_fail(bp && plugin, false);
RzListIter *iter;
RzBreakpointPlugin *h;
/* avoid dupped plugins */
rz_list_foreach (bp->plugins, iter, h) {
if (!strcmp(h->name, plugin->name)) {
return false;
}
}
RzBreakpointPlugin *dup = RZ_NEW(RzBreakpointPlugin);
if (!dup) {
return false;
}
memcpy(dup, plugin, sizeof(RzBreakpointPlugin));
bp->nbps++;
rz_list_append(bp->plugins, dup);
return true;
}
/**
* Switch to the registered breakpoint plugin called \p name
*/
RZ_API int rz_bp_use(RZ_NONNULL RzBreakpoint *bp, RZ_NONNULL const char *name) {
rz_return_val_if_fail(bp && name, false);
RzListIter *iter;
RzBreakpointPlugin *h;
rz_list_foreach (bp->plugins, iter, h) {
if (!strcmp(h->name, name)) {
bp->cur = h;
return true;
}
}
return false;
}
// TODO: deprecate
RZ_API void rz_bp_plugin_list(RzBreakpoint *bp) {
RzListIter *iter;
RzBreakpointPlugin *b;
rz_list_foreach (bp->plugins, iter, b) {
bp->cb_printf("bp %c %s\n",
(bp->cur && !strcmp(bp->cur->name, b->name)) ? '*' : '-',
b->name);
}
}