Rizin
unix-like reverse engineering framework and cli tools
debug_rap.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2011-2019 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_cons.h>
5 #include <rz_debug.h>
6 
7 static int __rap_step(RzDebug *dbg) {
8  rz_io_system(dbg->iob.io, "ds");
9  return true;
10 }
11 
12 static int __rap_reg_read(RzDebug *dbg, int type, ut8 *buf, int size) {
13  rz_io_system(dbg->iob.io, "dr");
14  return 0;
15 }
16 
17 static int __rap_reg_write(RzDebug *dbg, int type, const ut8 *buf, int size) {
18  return false; // XXX Error check
19 }
20 
21 static int __rap_continue(RzDebug *dbg, int pid, int tid, int sig) {
22  rz_io_system(dbg->iob.io, "dc");
23  return true;
24 }
25 
27  /* do nothing */
28  return RZ_DEBUG_REASON_NONE;
29 }
30 
31 static int __rap_attach(RzDebug *dbg, int pid) {
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 }
43 
44 static int __rap_detach(RzDebug *dbg, int pid) {
45  // XXX TODO PID must be a socket here !!1
46  // close (pid);
47  // XXX Maybe we should continue here?
48  return true;
49 }
50 
51 static char *__rap_reg_profile(RzDebug *dbg) {
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 }
62 
63 static int __rap_breakpoint(RzBreakpoint *bp, RzBreakpointItem *b, bool set) {
64  // rz_io_system (dbg->iob.io, "db");
65  return false;
66 }
67 
69  .name = "rap",
70  .license = "LGPL3",
71  .arch = "any",
72  .bits = RZ_SYS_BITS_32,
73  .step = __rap_step,
74  .cont = __rap_continue,
75  .attach = &__rap_attach,
76  .detach = &__rap_detach,
77  .wait = &__rap_wait,
78  .breakpoint = __rap_breakpoint,
79  .reg_read = &__rap_reg_read,
80  .reg_write = &__rap_reg_write,
81  .reg_profile = (void *)__rap_reg_profile,
82  //.bp_write = &__rap_bp_write,
83  //.bp_read = &__rap_bp_read,
84 };
85 
86 #ifndef RZ_PLUGIN_INCORE
89  .data = &rz_debug_plugin_rap,
91 };
92 #endif
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 RZ_API
#define NULL
Definition: cris-opc.c:27
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
RZ_API RzLibStruct rizin_plugin
Definition: debug_rap.c:87
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
RzDebugPlugin rz_debug_plugin_rap
Definition: debug_rap.c:68
static int __rap_detach(RzDebug *dbg, int pid)
Definition: debug_rap.c:44
RzDebug * dbg
Definition: desil.c:30
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
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 pid
Definition: sflib.h:64
int type
Definition: mipsasm.c:17
#define eprintf(x, y...)
Definition: rlcc.c:7
RzDebugReasonType
Definition: rz_debug.h:89
@ RZ_DEBUG_REASON_NONE
Definition: rz_debug.h:91
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
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
Definition: io.c:411
@ RZ_LIB_TYPE_DBG
Definition: rz_lib.h:70
@ RZ_SYS_BITS_32
Definition: rz_sys.h:20
#define RZ_VERSION
Definition: rz_version.h:8
#define d(i)
Definition: sha256.c:44
#define b(i)
Definition: sha256.c:42
Definition: rz_bp.h:78
const char * version
Definition: rz_debug.h:362
const char * name
Definition: rz_debug.h:359
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
static const z80_opcode fd[]
Definition: z80_tab.h:997