diff --git a/libr/asm/t/rasm2.c b/libr/asm/t/rasm2.c index d285385d33..4517a01ea8 100644 --- a/libr/asm/t/rasm2.c +++ b/libr/asm/t/rasm2.c @@ -26,10 +26,8 @@ static int rasm_show_help() " -L list supported asm plugins\n" " -e Use big endian\n" " If '-l' value is greater than output length, output is padded with nops\n" - " If the last argument is '-' reads from stdin\n\n" - "Available plugins:\n"); - r_asm_list(&a); - + " If the last argument is '-' reads from stdin\n"); + //r_asm_list(&a); return R_TRUE; } diff --git a/libr/bp/bp.c b/libr/bp/bp.c index cd83f72597..ea442b458e 100644 --- a/libr/bp/bp.c +++ b/libr/bp/bp.c @@ -5,6 +5,7 @@ R_API int r_bp_init(struct r_bp_t *bp) { bp->nbps = 0; +printf("INIT!!\n"); bp->cur = NULL; INIT_LIST_HEAD(&bp->bps); return R_TRUE; @@ -62,7 +63,7 @@ R_API int r_bp_getbytes(struct r_bp_t *bp, u8 *buf, int len, int endian, int idx /* XXX: can be buggy huh : infinite loop is possible */ for(i=0;1;i++) { b = &bp->cur->bps[i%bp->cur->nbps]; - if (b->endian == endian && idx%i==0) { + if (b->endian == endian && idx%(i+1)==0) { for(i=0;ibytes, len); i += b->length; @@ -186,13 +187,14 @@ R_API int r_bp_list(struct r_bp_t *bp, int rad) eprintf("Breakpoint list:\n"); list_for_each(pos, &bp->bps) { b = list_entry(pos, struct r_bp_item_t, list); - printf("0x%08llx - 0x%08llx %d %c%c%c %s %s\n", + printf("0x%08llx - 0x%08llx %d %c%c%c %s %s %s\n", b->addr, b->addr+b->size, b->size, (b->rwx & R_BP_READ)?'r':'-', (b->rwx & R_BP_WRITE)?'w':'-', (b->rwx & R_BP_EXEC)?'x':'-', b->hw?"hw":"sw", - b->trace?"trace":"break"); + b->trace?"trace":"break", + b->enabled?"enabled":"disabled"); /* TODO: Show list of pids and trace points, conditionals */ } return 0; diff --git a/libr/core/core.c b/libr/core/core.c index d4493a1337..d38edcc912 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -58,6 +58,20 @@ static int myfgets(char *buf, int len) } /*-----------------------------------*/ +static int __dbg_read(void *user, int pid, u64 addr, u8 *buf, int len) +{ + struct r_core_t *core = (struct r_core_t *)user; + // TODO: pid not used + return r_core_read_at(core, addr, buf, len); +} + +static int __dbg_write(void *user, int pid, u64 addr, u8 *buf, int len) +{ + struct r_core_t *core = (struct r_core_t *)user; + // TODO: pid not used + return r_core_write_at(core, addr, buf, len); +} + R_API int r_core_init(struct r_core_t *core) { core->oobi = NULL; @@ -102,6 +116,7 @@ R_API int r_core_init(struct r_core_t *core) r_core_cmd_init(core); r_flag_init(&core->flags); r_debug_init(&core->dbg); + r_debug_set_io(&core->dbg,__dbg_read, __dbg_write, core); r_core_config_init(core); // XXX fix path here @@ -110,6 +125,7 @@ R_API int r_core_init(struct r_core_t *core) /* UH? */ r_asm_set(&core->assembler, "asm_"DEFAULT_ARCH); r_anal_set(&core->anal, "anal_"DEFAULT_ARCH); + r_bp_handle_set(&core->dbg.bp, "bp_"DEFAULT_ARCH); r_config_set(&core->config, "asm.arch", "x86"); r_config_set_i(&core->config, "asm.bits", 32); diff --git a/libr/debug/bp.c b/libr/debug/bp.c index 579a39d00a..c8e9548b8e 100644 --- a/libr/debug/bp.c +++ b/libr/debug/bp.c @@ -11,9 +11,9 @@ R_API int r_debug_bp_add(struct r_debug_t *dbg, u64 addr, int size) } /* read bytes affected */ u8 *buf = (u8 *)malloc(size); - dbg->read(dbg->pid, addr, buf, size); + dbg->read(dbg->user, dbg->pid, addr, buf, size); /* register breakpoint in r_bp */ - bp = r_bp_add_bp(&dbg->bp, buf, addr, size, 0, R_BP_EXEC); + bp = r_bp_add(&dbg->bp, buf, addr, size, 0, R_BP_EXEC); /* if already set, r_bp should return false */ free(buf); return bp!=NULL; @@ -21,7 +21,7 @@ R_API int r_debug_bp_add(struct r_debug_t *dbg, u64 addr, int size) R_API int r_debug_bp_del(struct r_debug_t *dbg, u64 addr) { - return r_bp_del_bp(&dbg->bp, addr); + return r_bp_del(&dbg->bp, addr); } /** diff --git a/libr/debug/debug.c b/libr/debug/debug.c index b4438359b5..8a1a0c4f93 100644 --- a/libr/debug/debug.c +++ b/libr/debug/debug.c @@ -13,6 +13,16 @@ R_API int r_debug_init(struct r_debug_t *dbg) return R_TRUE; } +R_API int r_debug_set_io(struct r_debug_t *dbg, + int (*_read)(void *user, int pid, u64 addr, u8 *buf, int len), + int (*_write)(void *user, int pid, u64 addr, u8 *buf, int len), + void *user) +{ + dbg->read = _read; + dbg->write = _write; + dbg->user = user; +} + R_API struct r_debug_t *r_debug_new() { struct r_debug_t *dbg; diff --git a/libr/include/r_debug.h b/libr/include/r_debug.h index 46499490c7..01f7b69aea 100644 --- a/libr/include/r_debug.h +++ b/libr/include/r_debug.h @@ -44,9 +44,10 @@ struct r_debug_t { int steps; /* counter of steps done */ struct r_reg_t reg; struct r_bp_t bp; + void *user; /* io */ - int (*read)(int pid, u64 addr, u8 *buf, int len); - int (*write)(int pid, u64 addr, u8 *buf, int len); + int (*read)(void *user, int pid, u64 addr, u8 *buf, int len); + int (*write)(void *user, int pid, u64 addr, u8 *buf, int len); struct r_debug_handle_t *h; struct list_head handlers; /* TODO @@ -78,6 +79,12 @@ int r_debug_handle_set(struct r_debug_t *dbg, const char *str); int r_debug_handle_init(struct r_debug_t *dbg); int r_debug_init(struct r_debug_t *dbg); +// TODO: +int r_debug_set_io(struct r_debug_t *dbg, + int (*read)(void *user, int pid, u64 addr, u8 *buf, int len), + int (*write)(void *user, int pid, u64 addr, u8 *buf, int len), + void *user); + /* send signals */ int r_debug_kill(struct r_debug_t *dbg, int pid, int sig); int r_debug_step(struct r_debug_t *dbg, int steps);