mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 18:43:45 +00:00
Fix udis86 trailing spaces, add 'dw' command
This commit is contained in:
parent
70b037e154
commit
55bb8dc95e
@ -52,7 +52,6 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, ut64 len) {
|
||||
ud_set_input_buffer (&disasm_obj, buf, len);
|
||||
ud_set_pc (&disasm_obj, a->pc);
|
||||
ud_set_mode (&disasm_obj, a->bits);
|
||||
|
||||
/*
|
||||
disasm_obj.inp_fill = 10;
|
||||
disasm_obj.inp_curr = 0;
|
||||
|
@ -104,7 +104,7 @@ static void cmd_debug_pid(RCore *core, const char *input) {
|
||||
sig = ptr? atoi (ptr+1): 0;
|
||||
if (pid > 0) {
|
||||
eprintf ("Sending signal '%d' to pid '%d'\n", sig, pid);
|
||||
r_debug_kill (core->dbg, R_FALSE, sig);
|
||||
r_debug_kill (core->dbg, 0, R_FALSE, sig);
|
||||
} else eprintf ("cmd_debug_pid: Invalid arguments (%s)\n", input);
|
||||
break;
|
||||
case 'n':
|
||||
@ -992,6 +992,17 @@ static int cmd_debug(void *data, const char *input) {
|
||||
case 'o':
|
||||
r_core_file_reopen (core, input[1]? input+2: NULL, 0);
|
||||
break;
|
||||
case 'w':
|
||||
r_cons_break (static_debug_stop, core->dbg);
|
||||
for (;!r_cons_singleton ()->breaked;) {
|
||||
int pid = atoi (input+1);
|
||||
int opid = core->dbg->pid = pid;
|
||||
int res = r_debug_kill (core->dbg, pid, 0, 0);
|
||||
if (!res) break;
|
||||
r_sys_usleep (200);
|
||||
}
|
||||
r_cons_break_end();
|
||||
break;
|
||||
default:
|
||||
r_cons_printf ("Usage: d[sbhcrbo] [arg]\n"
|
||||
" dh [handler] list or set debugger handler\n"
|
||||
@ -1005,7 +1016,8 @@ static int cmd_debug(void *data, const char *input) {
|
||||
" db[?] breakpoints\n"
|
||||
" dbt display backtrace\n"
|
||||
" dt[?r] [tag] display instruction traces (dtr=reset)\n"
|
||||
" dm[?*] show memory maps\n");
|
||||
" dm[?*] show memory maps\n"
|
||||
" dw [pid] block prompt until pid dies\n");
|
||||
break;
|
||||
}
|
||||
if (follow>0) {
|
||||
|
@ -217,9 +217,10 @@ static int cmd_print(void *data, const char *input) {
|
||||
if (len>core->blocksize)
|
||||
r_core_block_size (core, len);
|
||||
if (l==0) l = len;
|
||||
for (i=j=0; i<bs && j<len; i+=ret,j++) {
|
||||
for (i=j=0; i<bs && i<len && j<len; i+=ret, j++) {
|
||||
r_asm_set_pc (core->assembler, core->offset+i);
|
||||
ret = r_asm_disassemble (core->assembler, &asmop, buf+i, core->blocksize-i);
|
||||
ret = r_asm_disassemble (core->assembler,
|
||||
&asmop, buf+i, core->blocksize-i);
|
||||
//r_cons_printf ("0x%08"PFMT64x" ", core->offset+i);
|
||||
if (ret<1) {
|
||||
ret = err = 1;
|
||||
@ -227,7 +228,8 @@ static int cmd_print(void *data, const char *input) {
|
||||
} else {
|
||||
if (decode) {
|
||||
char *tmpopstr, *opstr;
|
||||
r_anal_op (core->anal, &analop, core->offset+i, buf+i, core->blocksize-i);
|
||||
r_anal_op (core->anal, &analop, core->offset+i,
|
||||
buf+i, core->blocksize-i);
|
||||
tmpopstr = r_anal_op_to_string (core->anal, &analop);
|
||||
opstr = (tmpopstr)? tmpopstr: strdup (asmop.buf_asm);
|
||||
r_cons_printf ("%s\n", opstr);
|
||||
@ -324,7 +326,9 @@ static int cmd_print(void *data, const char *input) {
|
||||
ut8 *block = malloc (b->size+1);
|
||||
if (block) {
|
||||
r_core_read_at (core, b->addr, block, b->size);
|
||||
core->num->value = r_core_print_disasm (core->print, core, b->addr, block, b->size, 9999, 0, 1);
|
||||
core->num->value = r_core_print_disasm (
|
||||
core->print, core, b->addr, block,
|
||||
b->size, 9999, 0, 2);
|
||||
free (block);
|
||||
return 0;
|
||||
}
|
||||
@ -338,7 +342,9 @@ static int cmd_print(void *data, const char *input) {
|
||||
ut8 *block = malloc (f->size+1);
|
||||
if (block) {
|
||||
r_core_read_at (core, f->addr, block, f->size);
|
||||
core->num->value = r_core_print_disasm (core->print, core, f->addr, block, f->size, 9999, 0, 1);
|
||||
core->num->value = r_core_print_disasm (
|
||||
core->print, core, f->addr, block,
|
||||
f->size, 9999, 0, 2);
|
||||
free (block);
|
||||
return 0;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ R_API int r_core_file_reopen(RCore *core, const char *args, int perm) {
|
||||
if (!perm) perm = core->file->rwx;
|
||||
path = strdup (core->file->uri);
|
||||
if (r_config_get_i (core->config, "cfg.debug"))
|
||||
r_debug_kill (core->dbg, R_FALSE, 9); // KILL
|
||||
r_debug_kill (core->dbg, 0, R_FALSE, 9); // KILL
|
||||
file = r_core_file_open (core, path, perm, addr);
|
||||
if (file) {
|
||||
eprintf ("File %s reopened in %s mode\n", path,
|
||||
|
@ -436,7 +436,7 @@ R_API int r_debug_continue_syscall(struct r_debug_t *dbg, int sc) {
|
||||
}
|
||||
|
||||
// TODO: remove from here? this is code injection!
|
||||
R_API int r_debug_syscall(struct r_debug_t *dbg, int num) {
|
||||
R_API int r_debug_syscall(RDebug *dbg, int num) {
|
||||
int ret = R_FALSE;
|
||||
if (dbg->h->contsc) {
|
||||
ret = dbg->h->contsc (dbg, dbg->pid, num);
|
||||
@ -449,10 +449,10 @@ R_API int r_debug_syscall(struct r_debug_t *dbg, int num) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_debug_kill(struct r_debug_t *dbg, boolt thread, int sig) {
|
||||
R_API int r_debug_kill(RDebug *dbg, int pid, int tid, int sig) {
|
||||
int ret = R_FALSE;
|
||||
if (dbg->h && dbg->h->kill)
|
||||
ret = dbg->h->kill (dbg, thread, sig);
|
||||
ret = dbg->h->kill (dbg, pid, tid, sig);
|
||||
else eprintf ("Backend does not implements kill()\n");
|
||||
return ret;
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if __UNIX__
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#if DEBUGGER
|
||||
static int r_debug_native_continue(RDebug *dbg, int pid, int tid, int sig);
|
||||
@ -2089,7 +2092,7 @@ static RList *r_debug_native_frames(RDebug *dbg, ut64 at) {
|
||||
}
|
||||
|
||||
// TODO: implement own-defined signals
|
||||
static int r_debug_native_kill(RDebug *dbg, boolt thread, int sig) {
|
||||
static int r_debug_native_kill(RDebug *dbg, int pid, int tid, int sig) {
|
||||
#if __WINDOWS__
|
||||
// TODO: implement thread support signaling here
|
||||
eprintf ("TODO: r_debug_native_kill\n");
|
||||
@ -2107,20 +2110,23 @@ static int r_debug_native_kill(RDebug *dbg, boolt thread, int sig) {
|
||||
return R_FALSE;
|
||||
#else
|
||||
int ret = R_FALSE;
|
||||
if (thread) {
|
||||
#if 0
|
||||
if (thread) {
|
||||
// XXX this is linux>2.5 specific..ugly
|
||||
if (dbg->tid>0 && (ret = tgkill (dbg->pid, dbg->tid, sig))) {
|
||||
if (ret != -1)
|
||||
ret = R_TRUE;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (dbg->pid>0 && (ret = kill (dbg->pid, sig))) {
|
||||
if (ret != -1)
|
||||
ret = R_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (pid==0) pid = dbg->pid;
|
||||
if ((kill (pid, sig) != -1))
|
||||
ret = R_TRUE;
|
||||
if (errno == 1) // EPERM
|
||||
ret = -R_TRUE;
|
||||
#if 0
|
||||
// }
|
||||
#endif
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ typedef struct r_debug_plugin_t {
|
||||
int (*step_over)(RDebug *dbg);
|
||||
int (*cont)(RDebug *dbg, int pid, int tid, int sig);
|
||||
int (*wait)(RDebug *dbg, int pid);
|
||||
int (*kill)(RDebug *dbg, boolt thread, int sig);
|
||||
int (*kill)(RDebug *dbg, int pid, int tid, int sig);
|
||||
int (*contsc)(RDebug *dbg, int pid, int sc);
|
||||
RList* (*frames)(RDebug *dbg, ut64 at);
|
||||
RBreakpointCallback breakpoint;
|
||||
@ -233,7 +233,7 @@ R_API RDebug *r_debug_new(int hard);
|
||||
R_API RDebug *r_debug_free(RDebug *dbg);
|
||||
|
||||
/* send signals */
|
||||
R_API int r_debug_kill(RDebug *dbg, boolt thread, int sig);
|
||||
R_API int r_debug_kill(RDebug *dbg, int pid, int tid, int sig);
|
||||
// XXX: must be uint64 action
|
||||
R_API int r_debug_kill_setup(RDebug *dbg, int sig, int action);
|
||||
R_API int r_debug_step(RDebug *dbg, int steps);
|
||||
|
@ -220,7 +220,8 @@ extern void ud_translate_intel(struct ud* u)
|
||||
mkasm(u, "repne ");
|
||||
|
||||
/* print the instruction mnemonic */
|
||||
mkasm(u, "%s ", ud_lookup_mnemonic(u->mnemonic));
|
||||
mkasm(u, "%s%c", ud_lookup_mnemonic(u->mnemonic),
|
||||
(u->operand[0].type != UD_NONE)?' ':'\0');
|
||||
|
||||
/* operand 1 */
|
||||
if (u->operand[0].type != UD_NONE) {
|
||||
|
Loading…
Reference in New Issue
Block a user