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

Go to the source code of this file.

Functions

static int hook_flag_read (RzAnalysisEsil *esil, const char *flag, ut64 *num)
 
static int hook_command (RzAnalysisEsil *esil, const char *op)
 
static int hook_mem_read (RzAnalysisEsil *esil, ut64 addr, ut8 *buf, int len)
 
static int hook_mem_write (RzAnalysisEsil *esil, ut64 addr, const ut8 *buf, int len)
 
static int hook_reg_read (RzAnalysisEsil *esil, const char *name, ut64 *res, int *size)
 
static int hook_reg_write (RzAnalysisEsil *esil, const char *name, ut64 *val)
 
static int hook_NOP_mem_write (RzAnalysisEsil *esil, ut64 addr, const ut8 *buf, int len)
 
RZ_API void rz_analysis_esil_mem_ro (RzAnalysisEsil *esil, int mem_readonly)
 
RZ_API void rz_analysis_esil_stats (RzAnalysisEsil *esil, int enable)
 

Function Documentation

◆ hook_command()

static int hook_command ( RzAnalysisEsil esil,
const char *  op 
)
static

Definition at line 11 of file esil_stats.c.

11  {
12  sdb_array_add(esil->stats, "ops.list", op, 0);
13  return 0;
14 }
RZ_API int sdb_array_add(Sdb *s, const char *key, const char *val, ut32 cas)
Definition: array.c:224
Definition: dis.c:32

References sdb_array_add(), and rz_analysis_esil_t::stats.

Referenced by rz_analysis_esil_stats().

◆ hook_flag_read()

static int hook_flag_read ( RzAnalysisEsil esil,
const char *  flag,
ut64 num 
)
static

Definition at line 6 of file esil_stats.c.

6  {
7  sdb_array_add(esil->stats, "flg.read", flag, 0);
8  return 0;
9 }

References sdb_array_add(), and rz_analysis_esil_t::stats.

Referenced by rz_analysis_esil_stats().

◆ hook_mem_read()

static int hook_mem_read ( RzAnalysisEsil esil,
ut64  addr,
ut8 buf,
int  len 
)
static

Definition at line 16 of file esil_stats.c.

16  {
17  sdb_array_add_num(esil->stats, "mem.read", addr, 0);
18  return 0;
19 }
RZ_API int sdb_array_add_num(Sdb *s, const char *key, ut64 val, ut32 cas)
Definition: array.c:211
static int addr
Definition: z80asm.c:58

References addr, sdb_array_add_num(), and rz_analysis_esil_t::stats.

Referenced by rz_analysis_esil_stats().

◆ hook_mem_write()

static int hook_mem_write ( RzAnalysisEsil esil,
ut64  addr,
const ut8 buf,
int  len 
)
static

Definition at line 21 of file esil_stats.c.

21  {
22  sdb_array_add_num(esil->stats, "mem.write", addr, 0);
23  return 0;
24 }

References addr, sdb_array_add_num(), and rz_analysis_esil_t::stats.

Referenced by ds_print_esil_analysis(), and rz_analysis_esil_stats().

◆ hook_NOP_mem_write()

static int hook_NOP_mem_write ( RzAnalysisEsil esil,
ut64  addr,
const ut8 buf,
int  len 
)
static

Definition at line 37 of file esil_stats.c.

37  {
38  RZ_LOG_DEBUG("esil: NOP write at 0x%08" PFMT64x "\n", addr);
39  return 1; // override
40 }
#define RZ_LOG_DEBUG(fmtstr,...)
Definition: rz_log.h:49
#define PFMT64x
Definition: rz_types.h:393

References addr, PFMT64x, and RZ_LOG_DEBUG.

Referenced by rz_analysis_esil_mem_ro().

◆ hook_reg_read()

static int hook_reg_read ( RzAnalysisEsil esil,
const char *  name,
ut64 res,
int size 
)
static

Definition at line 26 of file esil_stats.c.

26  {
27  const char *key = (*name >= '0' && *name <= '9') ? "num.load" : "reg.read";
28  sdb_array_add(esil->stats, key, name, 0);
29  return 0;
30 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
Definition: z80asm.h:102

References key, sdb_array_add(), and rz_analysis_esil_t::stats.

Referenced by rz_analysis_esil_stats().

◆ hook_reg_write()

static int hook_reg_write ( RzAnalysisEsil esil,
const char *  name,
ut64 val 
)
static

Definition at line 32 of file esil_stats.c.

32  {
33  sdb_array_add(esil->stats, "reg.write", name, 0);
34  return 0;
35 }

References sdb_array_add(), and rz_analysis_esil_t::stats.

Referenced by rz_analysis_esil_stats().

◆ rz_analysis_esil_mem_ro()

RZ_API void rz_analysis_esil_mem_ro ( RzAnalysisEsil esil,
int  mem_readonly 
)

Definition at line 42 of file esil_stats.c.

42  {
43  if (mem_readonly) {
45  } else {
46  esil->cb.hook_mem_write = NULL;
47  }
48 }
#define NULL
Definition: cris-opc.c:27
static int hook_NOP_mem_write(RzAnalysisEsil *esil, ut64 addr, const ut8 *buf, int len)
Definition: esil_stats.c:37
int(* hook_mem_write)(ANALYSIS_ESIL *esil, ut64 addr, const ut8 *buf, int len)
Definition: rz_analysis.h:1034
RzAnalysisEsilCallbacks cb
Definition: rz_analysis.h:1078

References rz_analysis_esil_t::cb, rz_analysis_esil_callbacks_t::hook_mem_write, hook_NOP_mem_write(), and NULL.

Referenced by rz_analysis_esil_setup().

◆ rz_analysis_esil_stats()

RZ_API void rz_analysis_esil_stats ( RzAnalysisEsil esil,
int  enable 
)

Definition at line 50 of file esil_stats.c.

50  {
51  if (enable) {
52  if (esil->stats) {
53  sdb_reset(esil->stats);
54  } else {
55  esil->stats = sdb_new0();
56  }
57  // reset sdb->stats
64  } else {
65  esil->cb.hook_mem_write = NULL;
66  esil->cb.hook_flag_read = NULL;
67  esil->cb.hook_command = NULL;
68  sdb_free(esil->stats);
69  esil->stats = NULL;
70  }
71 }
static int hook_reg_read(RzAnalysisEsil *esil, const char *name, ut64 *res, int *size)
Definition: esil_stats.c:26
static int hook_mem_read(RzAnalysisEsil *esil, ut64 addr, ut8 *buf, int len)
Definition: esil_stats.c:16
static int hook_flag_read(RzAnalysisEsil *esil, const char *flag, ut64 *num)
Definition: esil_stats.c:6
static int hook_reg_write(RzAnalysisEsil *esil, const char *name, ut64 *val)
Definition: esil_stats.c:32
static int hook_mem_write(RzAnalysisEsil *esil, ut64 addr, const ut8 *buf, int len)
Definition: esil_stats.c:21
static int hook_command(RzAnalysisEsil *esil, const char *op)
Definition: esil_stats.c:11
RZ_API Sdb * sdb_new0(void)
Definition: sdb.c:43
RZ_API bool sdb_free(Sdb *s)
Definition: sdb.c:206
RZ_API void sdb_reset(Sdb *s)
Definition: sdb.c:433
int(* hook_mem_read)(ANALYSIS_ESIL *esil, ut64 addr, ut8 *buf, int len)
Definition: rz_analysis.h:1032
int(* hook_command)(ANALYSIS_ESIL *esil, const char *op)
Definition: rz_analysis.h:1031
int(* hook_reg_read)(ANALYSIS_ESIL *esil, const char *name, ut64 *res, int *size)
Definition: rz_analysis.h:1036
int(* hook_flag_read)(ANALYSIS_ESIL *esil, const char *flag, ut64 *num)
Definition: rz_analysis.h:1030
RzAnalysisEsilHookRegWriteCB hook_reg_write
Definition: rz_analysis.h:1038

References rz_analysis_esil_t::cb, hook_command(), rz_analysis_esil_callbacks_t::hook_command, hook_flag_read(), rz_analysis_esil_callbacks_t::hook_flag_read, hook_mem_read(), rz_analysis_esil_callbacks_t::hook_mem_read, hook_mem_write(), rz_analysis_esil_callbacks_t::hook_mem_write, hook_reg_read(), rz_analysis_esil_callbacks_t::hook_reg_read, hook_reg_write(), rz_analysis_esil_callbacks_t::hook_reg_write, NULL, sdb_free(), sdb_new0(), sdb_reset(), and rz_analysis_esil_t::stats.

Referenced by rz_analysis_esil_setup().