Rizin
unix-like reverse engineering framework and cli tools
plugin.c File Reference
#include <rz_debug.h>
#include <config.h>

Go to the source code of this file.

Functions

RZ_API void rz_debug_plugin_init (RzDebug *dbg)
 
RZ_API bool rz_debug_use (RzDebug *dbg, const char *str)
 
RZ_API bool rz_debug_plugin_add (RzDebug *dbg, RzDebugPlugin *foo)
 
RZ_API bool rz_debug_plugin_set_reg_profile (RzDebug *dbg, const char *profile)
 

Variables

static RzDebugPlugindebug_static_plugins [] = { RZ_DEBUG_STATIC_PLUGINS }
 

Function Documentation

◆ rz_debug_plugin_add()

RZ_API bool rz_debug_plugin_add ( RzDebug dbg,
RzDebugPlugin foo 
)

Definition at line 56 of file plugin.c.

56  {
57  if (!dbg || !foo || !foo->name) {
58  return false;
59  }
61  memcpy(dp, foo, sizeof(RzDebugPlugin));
63  return true;
64 }
RzDebug * dbg
Definition: desil.c:30
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static RzMain foo[]
Definition: main.c:11
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
#define RZ_NEW(x)
Definition: rz_types.h:285
RzList * plugins
Definition: rz_debug.h:297
const char * name
Definition: rz_main.h:17

References dbg, foo, memcpy(), rz_main_t::name, rz_debug_t::plugins, rz_list_append(), and RZ_NEW.

Referenced by rz_debug_plugin_init().

◆ rz_debug_plugin_init()

RZ_API void rz_debug_plugin_init ( RzDebug dbg)

Definition at line 9 of file plugin.c.

9  {
10  int i;
12  for (i = 0; i < RZ_ARRAY_SIZE(debug_static_plugins); i++) {
14  }
15 }
lzma_index ** i
Definition: index.h:629
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
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
static RzDebugPlugin * debug_static_plugins[]
Definition: plugin.c:7
RZ_API bool rz_debug_plugin_add(RzDebug *dbg, RzDebugPlugin *foo)
Definition: plugin.c:56
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300

References dbg, debug_static_plugins, free(), i, rz_debug_t::plugins, RZ_ARRAY_SIZE, rz_debug_plugin_add(), and rz_list_newf().

Referenced by rz_debug_new().

◆ rz_debug_plugin_set_reg_profile()

RZ_API bool rz_debug_plugin_set_reg_profile ( RzDebug dbg,
const char *  profile 
)

Definition at line 66 of file plugin.c.

66  {
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 }
#define NULL
Definition: cris-opc.c:27
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
Definition: file.c:454
int(* set_reg_profile)(RzDebug *dbg, const char *str)
Definition: rz_debug.h:395
struct rz_debug_plugin_t * cur
Definition: rz_debug.h:295

References rz_debug_t::cur, dbg, eprintf, free(), NULL, rz_file_slurp(), rz_debug_plugin_t::set_reg_profile, and cmd_descs_generate::str.

◆ rz_debug_use()

RZ_API bool rz_debug_use ( RzDebug dbg,
const char *  str 
)

Definition at line 17 of file plugin.c.

17  {
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 }
RZ_API bool rz_debug_reg_profile_sync(RzDebug *dbg)
Definition: dreg.c:116
RZ_API bool rz_debug_set_arch(RzDebug *dbg, const char *arch, int bits)
Definition: debug.c:465
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#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
bool(* init)(RzDebug *dbg, void **user)
Definition: rz_debug.h:367
RzAnalysis * analysis
Definition: rz_debug.h:305
int bits
Definition: rz_debug.h:243
void * plugin_data
Definition: rz_debug.h:296
RzBreakpoint * bp
Definition: rz_debug.h:288

References rz_debug_t::analysis, rz_analysis_plugin_t::arch, rz_debug_t::bits, rz_debug_t::bp, rz_bp_t::breakpoint, rz_debug_plugin_t::breakpoint, rz_analysis_t::cur, rz_debug_t::cur, dbg, rz_debug_plugin_t::fini, h, rz_debug_plugin_t::init, NULL, rz_debug_t::plugin_data, rz_debug_t::plugins, rz_debug_reg_profile_sync(), rz_debug_set_arch(), rz_return_val_if_fail, cmd_descs_generate::str, and rz_bp_t::user.

Referenced by cb_cfgdebug(), cb_dbgbackend(), rz_core_file_open(), and rz_main_rizin().

Variable Documentation

◆ debug_static_plugins

RzDebugPlugin* debug_static_plugins[] = { RZ_DEBUG_STATIC_PLUGINS }
static

Definition at line 7 of file plugin.c.

Referenced by rz_debug_plugin_init().