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

Go to the source code of this file.

Functions

static int __esil_step_over (RzDebug *dbg)
 
static int __esil_step (RzDebug *dbg)
 
static bool __esil_init (RzDebug *dbg, void **user)
 
static int __esil_continue (RzDebug *dbg, int pid, int tid, int sig)
 
static int __esil_continue_syscall (RzDebug *dbg, int pid, int num)
 
static RzDebugReasonType __esil_wait (RzDebug *dbg, int pid)
 
static int __esil_attach (RzDebug *dbg, int pid)
 
static int __esil_detach (RzDebug *dbg, int pid)
 
static char * __esil_reg_profile (RzDebug *dbg)
 
static int __esil_breakpoint (RzBreakpoint *bp, RzBreakpointItem *b, bool set)
 
static bool __esil_kill (RzDebug *dbg, int pid, int tid, int sig)
 
static int __esil_stop (RzDebug *dbg)
 
static int __reg_read (RzDebug *dbg, int type, ut8 *buf, int size)
 

Variables

RzDebugPlugin rz_debug_plugin_esil
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ __esil_attach()

static int __esil_attach ( RzDebug dbg,
int  pid 
)
static

Definition at line 70 of file debug_esil.c.

70  {
71  eprintf("OK attach\n");
72  return true;
73 #if 0
74  if (!is_io_esil (dbg))
75  return false;
76 #endif
77 #if 0
78  RzIOBdescbg *o;
79  o = dbg->iob.io->desc->data;
80 eprintf ("base = %llx\n", o->bfvm->base);
81 eprintf ("screen = %llx\n", o->bfvm->screen);
82 eprintf ("input = %llx\n", o->bfvm->input);
83 #endif
84  return true;
85 }
RzDebug * dbg
Definition: desil.c:30
#define eprintf(x, y...)
Definition: rlcc.c:7
BfvmCPU * bfvm
Definition: debug_bf.c:13
ut64 base
Definition: bfvm.h:25
ut64 input
Definition: bfvm.h:32
ut64 screen
Definition: bfvm.h:28
RzIOBind iob
Definition: rz_debug.h:293
RzIO * io
Definition: rz_io.h:232
void * data
Definition: rz_io.h:102
struct rz_io_desc_t * desc
Definition: rz_io.h:60

References bfvm_cpu_t::base, RzIOBdescbg::bfvm, rz_io_desc_t::data, dbg, rz_io_t::desc, eprintf, bfvm_cpu_t::input, rz_io_bind_t::io, rz_debug_t::iob, and bfvm_cpu_t::screen.

◆ __esil_breakpoint()

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

Definition at line 113 of file debug_esil.c.

113  {
114  // rz_io_system (dbg->iob.io, "db");
115  return false;
116 }

◆ __esil_continue()

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

Definition at line 55 of file debug_esil.c.

55  {
56  eprintf("TODO continue\n");
57  return true;
58 }

References eprintf.

◆ __esil_continue_syscall()

static int __esil_continue_syscall ( RzDebug dbg,
int  pid,
int  num 
)
static

Definition at line 60 of file debug_esil.c.

60  {
61  eprintf("TODO: esil continue until syscall\n");
62  return true;
63 }

References eprintf.

◆ __esil_detach()

static int __esil_detach ( RzDebug dbg,
int  pid 
)
static

Definition at line 87 of file debug_esil.c.

87  {
88  // reset vm?
89  return true;
90 }

◆ __esil_init()

static bool __esil_init ( RzDebug dbg,
void **  user 
)
static

Definition at line 48 of file debug_esil.c.

48  {
49  dbg->tid = dbg->pid = 1;
50  // aeim
51  // aei
52  return true;
53 }

References dbg, rz_debug_t::pid, and rz_debug_t::tid.

◆ __esil_kill()

static bool __esil_kill ( RzDebug dbg,
int  pid,
int  tid,
int  sig 
)
static

Definition at line 118 of file debug_esil.c.

118  {
119  // TODO: ESIL reset
120  return true;
121 }

◆ __esil_reg_profile()

static char* __esil_reg_profile ( RzDebug dbg)
static

Definition at line 92 of file debug_esil.c.

92  {
93  if (!strcmp(dbg->arch, "bf")) {
94  return strdup(
95  "=PC pc\n"
96  "=SP esp\n"
97  "=BP ptr\n"
98  "=A0 rax\n"
99  "gpr rax .32 0 0\n"
100  "gpr pc .32 0 0\n"
101  "gpr ptr .32 4 0\n"
102  "gpr esp .32 8 0\n"
103  "gpr scr .32 12 0\n"
104  "gpr scri .32 16 0\n"
105  "gpr inp .32 20 0\n"
106  "gpr inpi .32 24 0\n"
107  "gpr mem .32 28 0\n"
108  "gpr memi .32 32 0\n");
109  }
111 }
RZ_API char * rz_analysis_get_reg_profile(RzAnalysis *analysis)
Definition: analysis.c:212
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RzAnalysis * analysis
Definition: rz_debug.h:305
char * arch
Definition: rz_debug.h:242

References rz_debug_t::analysis, rz_debug_t::arch, dbg, rz_analysis_get_reg_profile(), and strdup().

◆ __esil_step()

static int __esil_step ( RzDebug dbg)
static

XXX. hack to trick vaddr issue

Definition at line 22 of file debug_esil.c.

22  {
23  int oplen;
24  ut8 buf[64];
25  ut64 pc = 0LL; // getreg("pc")
26  RzAnalysisOp op = { 0 };
27 
29  pc = rz_debug_reg_get(dbg, "PC");
30  eprintf("PC = 0x%" PFMT64x "\n", pc);
32  // pc = 0x100001478;
33  // memset (buf, 0, sizeof (buf));
34  dbg->iob.read_at(dbg->iob.io, pc, buf, 64);
35  eprintf("READ 0x%08" PFMT64x " %02x %02x %02x\n", pc, buf[0], buf[1], buf[2]);
37  if (oplen > 0) {
38  if (*RZ_STRBUF_SAFEGET(&op.esil)) {
39  eprintf("ESIL: %s\n", RZ_STRBUF_SAFEGET(&op.esil));
41  }
42  }
44  eprintf("TODO: ESIL STEP\n");
45  return true;
46 }
RZ_API ut64 rz_debug_reg_get(RzDebug *dbg, const char *name)
Definition: dreg.c:99
RZ_API int rz_debug_reg_sync(RzDebug *dbg, int type, int write)
Definition: dreg.c:9
RZ_API bool rz_analysis_esil_parse(RzAnalysisEsil *esil, const char *str)
Definition: esil.c:2998
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
RZ_API bool rz_analysis_op_fini(RzAnalysisOp *op)
Definition: op.c:37
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
Definition: op.c:96
@ RZ_ANALYSIS_OP_MASK_ESIL
Definition: rz_analysis.h:441
@ RZ_REG_TYPE_GPR
Definition: rz_reg.h:21
#define RZ_STRBUF_SAFEGET(sb)
Definition: rz_strbuf.h:18
#define PFMT64x
Definition: rz_types.h:393
struct rz_analysis_esil_t * esil
Definition: rz_analysis.h:584
RzIOReadAt read_at
Definition: rz_io.h:240
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References rz_debug_t::analysis, dbg, eprintf, rz_analysis_t::esil, rz_io_bind_t::io, rz_debug_t::iob, pc, PFMT64x, rz_io_bind_t::read_at, rz_analysis_esil_parse(), rz_analysis_op(), rz_analysis_op_fini(), RZ_ANALYSIS_OP_MASK_ESIL, rz_debug_reg_get(), rz_debug_reg_sync(), RZ_REG_TYPE_GPR, RZ_STRBUF_SAFEGET, and ut64().

◆ __esil_step_over()

static int __esil_step_over ( RzDebug dbg)
static

Definition at line 17 of file debug_esil.c.

17  {
18  eprintf("TODO: ESIL STEP OVER\n");
19  return true;
20 }

References eprintf.

◆ __esil_stop()

static int __esil_stop ( RzDebug dbg)
static

Definition at line 123 of file debug_esil.c.

123  {
124  eprintf("ESIL: stop\n");
125  return true;
126 }

References eprintf.

◆ __esil_wait()

static RzDebugReasonType __esil_wait ( RzDebug dbg,
int  pid 
)
static

Definition at line 65 of file debug_esil.c.

65  {
66  /* do nothing */
67  return RZ_DEBUG_REASON_NONE;
68 }
@ RZ_DEBUG_REASON_NONE
Definition: rz_debug.h:91

References RZ_DEBUG_REASON_NONE.

◆ __reg_read()

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

Definition at line 128 of file debug_esil.c.

128  {
129  int sz;
130  /* do nothing */
132  memcpy(buf, bytes, RZ_MIN(size, sz));
133  free(bytes);
134  return size;
135 }
RZ_API ut8 * rz_reg_get_bytes(RzReg *reg, int type, int *size)
Definition: arena.c:8
static ut8 bytes[32]
Definition: asm_arc.c:23
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
int type
Definition: mipsasm.c:17
#define RZ_MIN(x, y)

References rz_debug_t::analysis, bytes, dbg, free(), memcpy(), rz_analysis_t::reg, RZ_MIN, rz_reg_get_bytes(), and type.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_DBG,
}
RzDebugPlugin rz_debug_plugin_esil
Definition: debug_esil.c:137
@ 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 158 of file debug_esil.c.

◆ rz_debug_plugin_esil

RzDebugPlugin rz_debug_plugin_esil
Initial value:
= {
.name = "esil",
.license = "LGPL3",
.arch = "any",
.init = __esil_init,
.step = __esil_step,
.step_over = __esil_step_over,
.cont = __esil_continue,
.attach = &__esil_attach,
.detach = &__esil_detach,
.wait = &__esil_wait,
.stop = __esil_stop,
.kill = __esil_kill,
.breakpoint = __esil_breakpoint,
.reg_profile = __esil_reg_profile,
.reg_read = __reg_read,
}
static bool __esil_init(RzDebug *dbg, void **user)
Definition: debug_esil.c:48
static int __esil_step_over(RzDebug *dbg)
Definition: debug_esil.c:17
static int __esil_breakpoint(RzBreakpoint *bp, RzBreakpointItem *b, bool set)
Definition: debug_esil.c:113
static RzDebugReasonType __esil_wait(RzDebug *dbg, int pid)
Definition: debug_esil.c:65
static int __reg_read(RzDebug *dbg, int type, ut8 *buf, int size)
Definition: debug_esil.c:128
static int __esil_detach(RzDebug *dbg, int pid)
Definition: debug_esil.c:87
static char * __esil_reg_profile(RzDebug *dbg)
Definition: debug_esil.c:92
static int __esil_continue(RzDebug *dbg, int pid, int tid, int sig)
Definition: debug_esil.c:55
static int __esil_step(RzDebug *dbg)
Definition: debug_esil.c:22
static int __esil_attach(RzDebug *dbg, int pid)
Definition: debug_esil.c:70
static bool __esil_kill(RzDebug *dbg, int pid, int tid, int sig)
Definition: debug_esil.c:118
static int __esil_continue_syscall(RzDebug *dbg, int pid, int num)
Definition: debug_esil.c:60
static int __esil_stop(RzDebug *dbg)
Definition: debug_esil.c:123
@ RZ_SYS_BITS_32
Definition: rz_sys.h:20
@ RZ_SYS_BITS_64
Definition: rz_sys.h:21

Definition at line 137 of file debug_esil.c.