2009-04-11 21:22:20 +00:00
|
|
|
#ifndef _INCLUDE_LIBR_BP_H_
|
|
|
|
#define _INCLUDE_LIBR_BP_H_
|
|
|
|
|
2009-04-12 22:46:44 +00:00
|
|
|
#include <r_types.h>
|
2009-09-14 00:37:28 +02:00
|
|
|
#include <r_io.h>
|
2009-04-11 21:22:20 +00:00
|
|
|
#include "list.h"
|
|
|
|
|
2009-04-12 22:46:44 +00:00
|
|
|
#define R_BP_MAXPIDS 10
|
|
|
|
|
2009-09-14 00:37:28 +02:00
|
|
|
|
|
|
|
#define R_BP_CONT_NORMAL 0
|
|
|
|
#define R_BP_CONT_NORMAL 0
|
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
typedef struct r_bp_arch_t {
|
2009-04-12 22:46:44 +00:00
|
|
|
int length;
|
|
|
|
int endian;
|
2009-07-08 13:49:55 +02:00
|
|
|
const ut8 *bytes;
|
2009-12-24 03:17:53 +01:00
|
|
|
} rBreakpointArch;
|
2009-04-12 22:46:44 +00:00
|
|
|
|
2009-09-14 00:37:28 +02:00
|
|
|
enum {
|
|
|
|
R_BP_TYPE_SW,
|
|
|
|
R_BP_TYPE_HW,
|
|
|
|
R_BP_TYPE_COND,
|
|
|
|
R_BP_TYPE_FAULT,
|
|
|
|
};
|
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
typedef struct r_bp_handle_t {
|
2009-04-12 22:46:44 +00:00
|
|
|
char *name;
|
|
|
|
char *arch;
|
2009-09-14 00:37:28 +02:00
|
|
|
int type; // R_BP_TYPE_SW
|
2009-04-12 22:46:44 +00:00
|
|
|
int nbps;
|
|
|
|
struct r_bp_arch_t *bps;
|
|
|
|
struct list_head list;
|
2009-12-24 03:17:53 +01:00
|
|
|
} rBreakpointHandler;
|
2009-04-12 22:46:44 +00:00
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
typedef struct r_bp_item_t {
|
2009-07-08 13:49:55 +02:00
|
|
|
ut64 addr;
|
2009-04-12 22:46:44 +00:00
|
|
|
int size;
|
|
|
|
int rwx;
|
|
|
|
int hw;
|
2009-04-11 21:22:20 +00:00
|
|
|
int trace;
|
2009-04-12 22:46:44 +00:00
|
|
|
int enabled;
|
2009-09-14 00:37:28 +02:00
|
|
|
int hits;
|
2009-07-08 13:49:55 +02:00
|
|
|
ut8 *obytes; /* original bytes */
|
|
|
|
ut8 *bbytes; /* breakpoint bytes */
|
2009-04-12 22:46:44 +00:00
|
|
|
int pids[R_BP_MAXPIDS];
|
|
|
|
struct list_head list;
|
2009-12-24 03:17:53 +01:00
|
|
|
} rBreakpointItem;
|
2009-04-12 22:46:44 +00:00
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
typedef struct r_bp_t {
|
2009-04-12 22:46:44 +00:00
|
|
|
int trace_all;
|
2009-07-08 13:49:55 +02:00
|
|
|
ut64 trace_bp;
|
2009-04-11 21:22:20 +00:00
|
|
|
int nbps;
|
2009-09-14 00:37:28 +02:00
|
|
|
int stepcont;
|
|
|
|
struct r_io_bind_t iob; // compile time dependency
|
2009-04-12 22:46:44 +00:00
|
|
|
struct r_bp_handle_t *cur;
|
2009-04-15 12:01:12 +02:00
|
|
|
struct list_head plugins;
|
2009-04-11 21:22:20 +00:00
|
|
|
struct list_head bps;
|
2009-12-24 03:17:53 +01:00
|
|
|
} rBreakpoint;
|
2009-04-11 21:22:20 +00:00
|
|
|
|
2009-04-12 22:46:44 +00:00
|
|
|
enum {
|
2010-01-04 01:25:52 +01:00
|
|
|
R_BP_PROT_READ = 1,
|
|
|
|
R_BP_PROT_WRITE = 2,
|
|
|
|
R_BP_PROT_EXEC = 4,
|
2009-04-12 22:46:44 +00:00
|
|
|
};
|
2009-04-11 21:22:20 +00:00
|
|
|
|
2009-12-24 03:17:53 +01:00
|
|
|
#ifdef R_API
|
2009-04-11 21:22:20 +00:00
|
|
|
R_API int r_bp_init(struct r_bp_t *bp);
|
|
|
|
R_API struct r_bp_t *r_bp_new();
|
|
|
|
R_API struct r_bp_t *r_bp_free(struct r_bp_t *bp);
|
2009-04-12 22:46:44 +00:00
|
|
|
|
2009-07-08 13:49:55 +02:00
|
|
|
R_API int r_bp_del(struct r_bp_t *bp, ut64 addr);
|
2009-04-12 22:46:44 +00:00
|
|
|
|
|
|
|
R_API int r_bp_handle_add(struct r_bp_t *bp, struct r_bp_handle_t *foo);
|
2009-09-20 02:16:14 +02:00
|
|
|
R_API int r_bp_use(struct r_bp_t *bp, const char *name);
|
2009-04-12 22:46:44 +00:00
|
|
|
R_API int r_bp_handle_del(struct r_bp_t *bp, const char *name);
|
2009-04-15 12:01:12 +02:00
|
|
|
R_API void r_bp_handle_list(struct r_bp_t *bp);
|
2009-04-12 22:46:44 +00:00
|
|
|
|
2009-07-08 13:49:55 +02:00
|
|
|
R_API int r_bp_in(struct r_bp_t *bp, ut64 addr, int rwx);
|
2009-04-11 21:22:20 +00:00
|
|
|
R_API int r_bp_list(struct r_bp_t *bp, int rad);
|
2009-09-14 00:37:28 +02:00
|
|
|
R_API int r_bp_get_bytes(struct r_bp_t *bp, ut8 *buf, int len, int endian, int idx);
|
2009-07-08 13:49:55 +02:00
|
|
|
R_API int r_bp_set_trace(struct r_bp_t *bp, ut64 addr, int set);
|
|
|
|
R_API int r_bp_set_trace_bp(struct r_bp_t *bp, ut64 addr, int set);
|
|
|
|
R_API struct r_bp_item_t *r_bp_enable(struct r_bp_t *bp, ut64 addr, int set);
|
2009-04-11 21:22:20 +00:00
|
|
|
|
2009-09-14 00:37:28 +02:00
|
|
|
R_API int r_bp_add_cond(struct r_bp_t *bp, const char *cond);
|
|
|
|
R_API int r_bp_del_cond(struct r_bp_t *bp, int idx);
|
|
|
|
R_API int r_bp_add_fault(struct r_bp_t *bp, ut64 addr, int size, int rwx);
|
|
|
|
|
|
|
|
R_API struct r_bp_item_t *r_bp_add_sw(struct r_bp_t *bp, ut64 addr, int size, int rwx);
|
|
|
|
R_API struct r_bp_item_t *r_bp_add_hw(struct r_bp_t *bp, ut64 addr, int size, int rwx);
|
2009-12-24 03:17:53 +01:00
|
|
|
R_API int r_bp_at_addr(struct r_bp_t *bp, ut64 addr, int rwx);
|
|
|
|
#endif
|
2009-09-14 00:37:28 +02:00
|
|
|
|
2009-04-13 22:47:02 +00:00
|
|
|
/* plugin pointers */
|
|
|
|
extern struct r_bp_handle_t r_bp_plugin_x86;
|
|
|
|
extern struct r_bp_handle_t r_bp_plugin_arm;
|
2009-12-24 03:17:53 +01:00
|
|
|
#if 0
|
2009-04-13 22:47:02 +00:00
|
|
|
extern struct r_bp_handle_t r_bp_plugin_powerpc;
|
|
|
|
extern struct r_bp_handle_t r_bp_plugin_mips;
|
|
|
|
extern struct r_bp_handle_t r_bp_plugin_sparc;
|
2009-12-24 03:17:53 +01:00
|
|
|
#endif
|
2009-04-13 22:47:02 +00:00
|
|
|
|
2009-04-11 21:22:20 +00:00
|
|
|
#endif
|