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

Go to the source code of this file.

Functions

static int __rap_step (RzDebug *dbg)
 
static int __rap_reg_read (RzDebug *dbg, int type, ut8 *buf, int size)
 
static int __rap_reg_write (RzDebug *dbg, int type, const ut8 *buf, int size)
 
static int __rap_continue (RzDebug *dbg, int pid, int tid, int sig)
 
static RzDebugReasonType __rap_wait (RzDebug *dbg, int pid)
 
static int __rap_attach (RzDebug *dbg, int pid)
 
static int __rap_detach (RzDebug *dbg, int pid)
 
static char * __rap_reg_profile (RzDebug *dbg)
 
static int __rap_breakpoint (RzBreakpoint *bp, RzBreakpointItem *b, bool set)
 

Variables

RzDebugPlugin rz_debug_plugin_rap
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ __rap_attach()

static int __rap_attach ( RzDebug dbg,
int  pid 
)
static

Definition at line 31 of file debug_rap.c.

31  {
32  // XXX TODO PID must be a socket here !!1
33  RzIODesc *d = dbg->iob.io->desc;
34  if (d && d->plugin && d->plugin->name) {
35  if (!strcmp("rap", d->plugin->name)) {
36  eprintf("SUCCESS: rap attach with inferior rap rio worked\n");
37  } else {
38  eprintf("ERROR: Underlying IO descriptor is not a rap one..\n");
39  }
40  }
41  return true;
42 }
RzDebug * dbg
Definition: desil.c:30
#define eprintf(x, y...)
Definition: rlcc.c:7
#define d(i)
Definition: sha256.c:44
RzIOBind iob
Definition: rz_debug.h:293
RzIO * io
Definition: rz_io.h:232
struct rz_io_desc_t * desc
Definition: rz_io.h:60

References d, dbg, rz_io_t::desc, eprintf, rz_io_bind_t::io, and rz_debug_t::iob.

◆ __rap_breakpoint()

static int __rap_breakpoint ( RzBreakpoint bp,
RzBreakpointItem b,
bool  set 
)
static

Definition at line 63 of file debug_rap.c.

63  {
64  // rz_io_system (dbg->iob.io, "db");
65  return false;
66 }

◆ __rap_continue()

static int __rap_continue ( RzDebug dbg,
int  pid,
int  tid,
int  sig 
)
static

Definition at line 21 of file debug_rap.c.

21  {
22  rz_io_system(dbg->iob.io, "dc");
23  return true;
24 }
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
Definition: io.c:411

References dbg, rz_io_bind_t::io, rz_debug_t::iob, and rz_io_system().

◆ __rap_detach()

static int __rap_detach ( RzDebug dbg,
int  pid 
)
static

Definition at line 44 of file debug_rap.c.

44  {
45  // XXX TODO PID must be a socket here !!1
46  // close (pid);
47  // XXX Maybe we should continue here?
48  return true;
49 }

◆ __rap_reg_profile()

static char* __rap_reg_profile ( RzDebug dbg)
static

Definition at line 51 of file debug_rap.c.

51  {
52  char *out, *tf = rz_file_temp("rap.XXXXXX");
53  int fd = rz_cons_pipe_open(tf, 1, 0);
54  rz_io_system(dbg->iob.io, "drp");
55  rz_cons_flush();
57  out = rz_file_slurp(tf, NULL);
58  rz_file_rm(tf);
59  free(tf);
60  return out;
61 }
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
RZ_API void rz_cons_pipe_close(int fd)
Definition: cpipe.c:53
RZ_API int rz_cons_pipe_open(const char *file, int fdn, int append)
Definition: cpipe.c:29
RZ_API void rz_cons_flush(void)
Definition: cons.c:959
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API char * rz_file_temp(const char *prefix)
Definition: file.c:1048
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
Definition: file.c:454
RZ_API bool rz_file_rm(const char *file)
Definition: file.c:865
static const z80_opcode fd[]
Definition: z80_tab.h:997

References dbg, fd, free(), rz_io_bind_t::io, rz_debug_t::iob, NULL, out, rz_cons_flush(), rz_cons_pipe_close(), rz_cons_pipe_open(), rz_file_rm(), rz_file_slurp(), rz_file_temp(), and rz_io_system().

◆ __rap_reg_read()

static int __rap_reg_read ( RzDebug dbg,
int  type,
ut8 buf,
int  size 
)
static

Definition at line 12 of file debug_rap.c.

12  {
13  rz_io_system(dbg->iob.io, "dr");
14  return 0;
15 }

References dbg, rz_io_bind_t::io, rz_debug_t::iob, and rz_io_system().

◆ __rap_reg_write()

static int __rap_reg_write ( RzDebug dbg,
int  type,
const ut8 buf,
int  size 
)
static

Definition at line 17 of file debug_rap.c.

17  {
18  return false; // XXX Error check
19 }

◆ __rap_step()

static int __rap_step ( RzDebug dbg)
static

Definition at line 7 of file debug_rap.c.

7  {
8  rz_io_system(dbg->iob.io, "ds");
9  return true;
10 }

References dbg, rz_io_bind_t::io, rz_debug_t::iob, and rz_io_system().

◆ __rap_wait()

static RzDebugReasonType __rap_wait ( RzDebug dbg,
int  pid 
)
static

Definition at line 26 of file debug_rap.c.

26  {
27  /* do nothing */
28  return RZ_DEBUG_REASON_NONE;
29 }
@ RZ_DEBUG_REASON_NONE
Definition: rz_debug.h:91

References RZ_DEBUG_REASON_NONE.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_DBG,
}
RzDebugPlugin rz_debug_plugin_rap
Definition: debug_rap.c:68
@ RZ_LIB_TYPE_DBG
Definition: rz_lib.h:70
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_debug.h:362

Definition at line 87 of file debug_rap.c.

◆ rz_debug_plugin_rap

RzDebugPlugin rz_debug_plugin_rap
Initial value:
= {
.name = "rap",
.license = "LGPL3",
.arch = "any",
.bits = RZ_SYS_BITS_32,
.step = __rap_step,
.cont = __rap_continue,
.attach = &__rap_attach,
.detach = &__rap_detach,
.wait = &__rap_wait,
.breakpoint = __rap_breakpoint,
.reg_read = &__rap_reg_read,
.reg_write = &__rap_reg_write,
.reg_profile = (void *)__rap_reg_profile,
}
static int __rap_attach(RzDebug *dbg, int pid)
Definition: debug_rap.c:31
static int __rap_continue(RzDebug *dbg, int pid, int tid, int sig)
Definition: debug_rap.c:21
static char * __rap_reg_profile(RzDebug *dbg)
Definition: debug_rap.c:51
static int __rap_reg_read(RzDebug *dbg, int type, ut8 *buf, int size)
Definition: debug_rap.c:12
static int __rap_reg_write(RzDebug *dbg, int type, const ut8 *buf, int size)
Definition: debug_rap.c:17
static int __rap_breakpoint(RzBreakpoint *bp, RzBreakpointItem *b, bool set)
Definition: debug_rap.c:63
static RzDebugReasonType __rap_wait(RzDebug *dbg, int pid)
Definition: debug_rap.c:26
static int __rap_step(RzDebug *dbg)
Definition: debug_rap.c:7
static int __rap_detach(RzDebug *dbg, int pid)
Definition: debug_rap.c:44
@ RZ_SYS_BITS_32
Definition: rz_sys.h:20

Definition at line 68 of file debug_rap.c.