mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-21 23:01:03 +00:00
* rasm2 -h does not list plugins (use -L)
* Fix div0 bug in r_bp_getbytes() * Show 'enabled' / 'disabled' attribute of breakpoints * Implement dbg_read and dbg_write callbacks for r_debug - Added r_debug_set_io() to setup the IO for r_debug * 'db' command can now add and remove breakpoints - Not yet written into memory. only managed
This commit is contained in:
parent
c6aa69fef1
commit
36771ea713
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;i<len;) {
|
||||
memcpy(buf+i, b->bytes, 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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user