Rizin
unix-like reverse engineering framework and cli tools
plugin.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2017 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_debug.h>
5 #include <config.h>
6 
8 
10  int i;
12  for (i = 0; i < RZ_ARRAY_SIZE(debug_static_plugins); i++) {
14  }
15 }
16 
17 RZ_API bool rz_debug_use(RzDebug *dbg, const char *str) {
18  rz_return_val_if_fail(dbg, false);
19  RzDebugPlugin *new_plugin = NULL;
20  if (str) {
23  rz_list_foreach (dbg->plugins, iter, h) {
24  if (h->name && !strcmp(str, h->name)) {
25  new_plugin = h;
26  break;
27  }
28  }
29  if (!new_plugin) {
30  return false;
31  }
32  }
33  if (new_plugin == dbg->cur) {
34  return true;
35  }
36  if (dbg->cur && dbg->cur->fini) {
38  }
39  dbg->cur = new_plugin;
40  dbg->plugin_data = NULL;
41  if (!dbg->cur) {
42  return true;
43  }
44  if (dbg->analysis && dbg->analysis->cur) {
46  }
48  dbg->bp->user = dbg;
49  if (dbg->cur->init) {
50  dbg->cur->init(dbg, &dbg->plugin_data);
51  }
53  return true;
54 }
55 
57  if (!dbg || !foo || !foo->name) {
58  return false;
59  }
61  memcpy(dp, foo, sizeof(RzDebugPlugin));
63  return true;
64 }
65 
66 RZ_API bool rz_debug_plugin_set_reg_profile(RzDebug *dbg, const char *profile) {
67  char *str = rz_file_slurp(profile, NULL);
68  if (!str) {
69  eprintf("rz_debug_plugin_set_reg_profile: Cannot find '%s'\n", profile);
70  return false;
71  }
72  if (dbg && dbg->cur && dbg->cur->set_reg_profile) {
73  return dbg->cur->set_reg_profile(dbg, str);
74  }
75  free(str);
76  return false;
77 }
lzma_index ** i
Definition: index.h:629
#define RZ_DEBUG_STATIC_PLUGINS
Definition: config.h:19
#define RZ_API
#define NULL
Definition: cris-opc.c:27
RzDebug * dbg
Definition: desil.c:30
RZ_API bool rz_debug_reg_profile_sync(RzDebug *dbg)
Definition: dreg.c:116
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API bool rz_debug_set_arch(RzDebug *dbg, const char *arch, int bits)
Definition: debug.c:465
static RzMain foo[]
Definition: main.c:11
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
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
RZ_API bool rz_debug_use(RzDebug *dbg, const char *str)
Definition: plugin.c:17
static RzDebugPlugin * debug_static_plugins[]
Definition: plugin.c:7
RZ_API void rz_debug_plugin_init(RzDebug *dbg)
Definition: plugin.c:9
RZ_API bool rz_debug_plugin_add(RzDebug *dbg, RzDebugPlugin *foo)
Definition: plugin.c:56
RZ_API bool rz_debug_plugin_set_reg_profile(RzDebug *dbg, const char *profile)
Definition: plugin.c:66
#define eprintf(x, y...)
Definition: rlcc.c:7
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
Definition: file.c:454
#define RZ_NEW(x)
Definition: rz_types.h:285
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define h(i)
Definition: sha256.c:48
struct rz_analysis_plugin_t * cur
Definition: rz_analysis.h:586
RzBreakpointCallback breakpoint
Definition: rz_bp.h:89
void * user
Definition: rz_bp.h:79
void(* fini)(RzDebug *debug, void *user)
Definition: rz_debug.h:368
RzBreakpointCallback breakpoint
Definition: rz_debug.h:390
int(* set_reg_profile)(RzDebug *dbg, const char *str)
Definition: rz_debug.h:395
bool(* init)(RzDebug *dbg, void **user)
Definition: rz_debug.h:367
struct rz_debug_plugin_t * cur
Definition: rz_debug.h:295
RzAnalysis * analysis
Definition: rz_debug.h:305
RzList * plugins
Definition: rz_debug.h:297
int bits
Definition: rz_debug.h:243
void * plugin_data
Definition: rz_debug.h:296
RzBreakpoint * bp
Definition: rz_debug.h:288
const char * name
Definition: rz_main.h:17