Rizin
unix-like reverse engineering framework and cli tools
bp_plugin.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2015 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_bp.h>
5 
6 RZ_API int rz_bp_plugin_del(RzBreakpoint *bp, const char *name) {
9  if (name && *name) {
10  rz_list_foreach (bp->plugins, iter, h) {
11  if (!strcmp(h->name, name)) {
12  if (bp->cur == h) {
13  bp->cur = NULL;
14  }
16  bp->nbps--;
17  return true;
18  }
19  }
20  }
21  return false;
22 }
23 
25  rz_return_val_if_fail(bp && plugin, false);
28  /* avoid dupped plugins */
29  rz_list_foreach (bp->bps, iter, h) {
30  if (!strcmp(h->name, plugin->name)) {
31  return false;
32  }
33  }
35  if (!dup) {
36  return false;
37  }
38  memcpy(dup, plugin, sizeof(RzBreakpointPlugin));
39  bp->nbps++;
41  return true;
42 }
43 
48  rz_return_val_if_fail(bp && name, false);
51  rz_list_foreach (bp->plugins, iter, h) {
52  if (!strcmp(h->name, name)) {
53  bp->cur = h;
54  return true;
55  }
56  }
57  return false;
58 }
59 
60 // TODO: deprecate
64  rz_list_foreach (bp->plugins, iter, b) {
65  bp->cb_printf("bp %c %s\n",
66  (bp->cur && !strcmp(bp->cur->name, b->name)) ? '*' : '-',
67  b->name);
68  }
69 }
RZ_API void rz_bp_plugin_list(RzBreakpoint *bp)
Definition: bp_plugin.c:61
RZ_API int rz_bp_use(RZ_NONNULL RzBreakpoint *bp, RZ_NONNULL const char *name)
Definition: bp_plugin.c:47
RZ_API bool rz_bp_plugin_add(RzBreakpoint *bp, RZ_BORROW RZ_NONNULL RzBreakpointPlugin *plugin)
Definition: bp_plugin.c:24
RZ_API int rz_bp_plugin_del(RzBreakpoint *bp, const char *name)
Definition: bp_plugin.c:6
#define RZ_API
#define NULL
Definition: cris-opc.c:27
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
Definition: list.c:162
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode dup
Definition: sflib.h:68
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_NEW(x)
Definition: rz_types.h:285
#define RZ_BORROW
Definition: rz_types.h:63
#define b(i)
Definition: sha256.c:42
#define h(i)
Definition: sha256.c:48
Definition: z80asm.h:102
char * name
Definition: rz_bp.h:34
Definition: rz_bp.h:78
PrintfCallback cb_printf
Definition: rz_bp.h:88
int nbps
Definition: rz_bp.h:91
RzList * plugins
Definition: rz_bp.h:87
RzBreakpointPlugin * cur
Definition: rz_bp.h:85
RzList * bps
Definition: rz_bp.h:93