mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 22:36:27 +00:00
Fix #260 - "dr all" is broken
This commit is contained in:
parent
7af16bdd34
commit
47faadf31b
@ -524,7 +524,7 @@ static void cmd_debug_reg(RCore *core, const char *str) {
|
||||
if (arg && size==0) {
|
||||
*arg='\0';
|
||||
size = atoi (arg);
|
||||
} else size = core->dbg->bits;
|
||||
} else size = bits;
|
||||
type = r_reg_type_by_name (str+1);
|
||||
}
|
||||
if (type != R_REG_TYPE_LAST) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
|
||||
R_API void r_core_print_examine(RCore *core, const char *str) {
|
||||
char cmd[128];
|
||||
char cmd[128], *p;
|
||||
ut64 addr = core->offset;
|
||||
int size = (core->anal->bits/4);
|
||||
int count = atoi (str);
|
||||
if (count<1) count = 1;
|
||||
@ -16,31 +17,32 @@ Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
|
||||
case 'w': size = 4; break;
|
||||
case 'g': size = 8; break;
|
||||
}
|
||||
#if 0
|
||||
#endif
|
||||
if ((p=strchr (str, ' ')))
|
||||
addr = r_num_math (core->num, p+1);
|
||||
switch (*str) {
|
||||
case '?':
|
||||
eprintf (
|
||||
"Format is x/[num][format][size]\n"
|
||||
"Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n"
|
||||
"Num specifies the number of format elements to display\n"
|
||||
"Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n"
|
||||
" t(binary), f(float), a(address), i(instruction), c(char) and s(string),\n"
|
||||
" T(OSType), A(floating point values in hex).\n"
|
||||
"Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n"
|
||||
);
|
||||
break;
|
||||
case 's':
|
||||
snprintf (cmd, sizeof (cmd), "psb %d", count*size);
|
||||
snprintf (cmd, sizeof (cmd), "psb %d @ 0x%"PFMT64x, count*size, addr);
|
||||
r_core_cmd0 (core, cmd);
|
||||
break;
|
||||
case 'o':
|
||||
snprintf (cmd, sizeof (cmd), "pxo %d", count*size);
|
||||
snprintf (cmd, sizeof (cmd), "pxo %d @ 0x%"PFMT64x, count*size, addr);
|
||||
r_core_cmd0 (core, cmd);
|
||||
break;
|
||||
case 'f':
|
||||
case 'A': // XXX (float in hex wtf)
|
||||
{
|
||||
int i, n = 3;
|
||||
snprintf (cmd, sizeof (cmd), "pxo %d", count*size);
|
||||
snprintf (cmd, sizeof (cmd), "pxo %d @ 0x%"PFMT64x, count*size, addr);
|
||||
|
||||
strcpy (cmd, "pf ");
|
||||
for (i=0;i<count && n<sizeof (cmd);i++) {
|
||||
@ -52,11 +54,11 @@ Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).
|
||||
break;
|
||||
case 'a':
|
||||
case 'd':
|
||||
snprintf (cmd, sizeof (cmd), "pxw %d", count*size);
|
||||
snprintf (cmd, sizeof (cmd), "pxw %d @ 0x%"PFMT64x, count*size, addr);
|
||||
r_core_cmd0 (core, cmd);
|
||||
break;
|
||||
case 'i':
|
||||
snprintf (cmd, sizeof (cmd), "pid %d", count);
|
||||
snprintf (cmd, sizeof (cmd), "pid %d @ 0x%"PFMT64x, count, addr);
|
||||
r_core_cmd0 (core, cmd);
|
||||
break;
|
||||
}
|
||||
|
@ -811,6 +811,7 @@ r_config_set (cfg, "asm.arch", R_SYS_ARCH);
|
||||
r_config_set_cb (cfg, "scr.tee", "", config_teefile_callback);
|
||||
r_config_desc (cfg, "scr.tee", "Pipe console output to file if not empty");
|
||||
r_config_set_cb (cfg, "scr.prompt", "true", &config_scrprompt_callback);
|
||||
r_config_desc (cfg, "scr.prompt", "Show/hide user prompt (used by r2 -q)");
|
||||
r_config_set (cfg, "scr.pipecolor", "false");
|
||||
r_config_desc (cfg, "scr.pipecolor", "enable colors when using pipes if true");
|
||||
#if __WINDOWS__
|
||||
|
103
libr/debug/reg.c
103
libr/debug/reg.c
@ -30,16 +30,15 @@ R_API int r_debug_reg_sync(RDebug *dbg, int type, int write) {
|
||||
}
|
||||
|
||||
R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad) {
|
||||
ut64 diff;
|
||||
int cols, n = 0;
|
||||
RList *head; //struct list_head *pos, *head;
|
||||
int i, from, to, cols, n = 0;
|
||||
const char *fmt, *fmt2;
|
||||
RListIter *iter;
|
||||
RRegItem *item;
|
||||
const char *fmt, *fmt2;
|
||||
RList *head;
|
||||
ut64 diff;
|
||||
|
||||
if (!dbg || !dbg->reg)
|
||||
return R_FALSE;
|
||||
head = r_reg_get_list (dbg->reg, type);
|
||||
//if (dbg->h && dbg->h->bits & R_SYS_BITS_64) {
|
||||
if (dbg->bits & R_SYS_BITS_64) {
|
||||
fmt = "%s = 0x%016"PFMT64x"%s";
|
||||
@ -52,49 +51,61 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad) {
|
||||
}
|
||||
if (rad=='j')
|
||||
dbg->printf ("{");
|
||||
if (head)
|
||||
r_list_foreach (head, iter, item) {
|
||||
ut64 value;
|
||||
if (type != -1 && type != item->type)
|
||||
continue;
|
||||
if (size != 0 && size != item->size)
|
||||
continue;
|
||||
value = r_reg_get_value (dbg->reg, item);
|
||||
diff = (ut64)r_reg_cmp (dbg->reg, item);
|
||||
switch (rad) {
|
||||
case 'j':
|
||||
dbg->printf ("%s\"%s\":%"PFMT64d,
|
||||
n?",":"",item->name, value);
|
||||
break;
|
||||
case 1:
|
||||
case '*':
|
||||
dbg->printf ("f %s 1 0x%"PFMT64x"\n", item->name, value);
|
||||
break;
|
||||
case 'd':
|
||||
case 2:
|
||||
if (diff) // TODO: DO NOT COLORIZE ALWAYS ..do debug knows about console?? use inverse colors
|
||||
dbg->printf (Color_BWHITE); //INVERT); //Color_BWHITE);
|
||||
if (item->flags) {
|
||||
char *str = r_reg_get_bvalue (dbg->reg, item);
|
||||
dbg->printf ("%s = %s%s", item->name, str, ((n+1)%cols)?" ":"\n");
|
||||
free (str);
|
||||
} else dbg->printf (fmt2, item->name, value, ((n+1)%cols)?" ":"\n");
|
||||
if (diff) // TODO: use inverse colors
|
||||
//dbg->printf (Color_INVERT_RESET); //Color_RESET);
|
||||
dbg->printf (Color_RESET); //Color_RESET);
|
||||
break;
|
||||
case 3:
|
||||
if (diff) {
|
||||
char woot[32];
|
||||
snprintf (woot, sizeof (woot), " was 0x%08"PFMT64x"\n", diff);
|
||||
dbg->printf (fmt, item->name, value, woot);
|
||||
if (type == -1) {
|
||||
from = 0;
|
||||
to = R_REG_TYPE_LAST;
|
||||
} else {
|
||||
from = type;
|
||||
to = from +1;
|
||||
}
|
||||
for (i=from; i<to; i++) {
|
||||
head = r_reg_get_list (dbg->reg, i);
|
||||
if (!head) continue;
|
||||
r_list_foreach (head, iter, item) {
|
||||
ut64 value;
|
||||
if (type != -1) {
|
||||
if (type != item->type)
|
||||
continue;
|
||||
if (size != 0 && size != item->size)
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dbg->printf (fmt, item->name, value, "\n");
|
||||
break;
|
||||
value = r_reg_get_value (dbg->reg, item);
|
||||
diff = (ut64)r_reg_cmp (dbg->reg, item);
|
||||
switch (rad) {
|
||||
case 'j':
|
||||
dbg->printf ("%s\"%s\":%"PFMT64d,
|
||||
n?",":"",item->name, value);
|
||||
break;
|
||||
case 1:
|
||||
case '*':
|
||||
dbg->printf ("f %s 1 0x%"PFMT64x"\n", item->name, value);
|
||||
break;
|
||||
case 'd':
|
||||
case 2:
|
||||
if (diff) // TODO: DO NOT COLORIZE ALWAYS ..do debug knows about console?? use inverse colors
|
||||
dbg->printf (Color_BWHITE); //INVERT); //Color_BWHITE);
|
||||
if (item->flags) {
|
||||
char *str = r_reg_get_bvalue (dbg->reg, item);
|
||||
dbg->printf ("%s = %s%s", item->name, str, ((n+1)%cols)?" ":"\n");
|
||||
free (str);
|
||||
} else dbg->printf (fmt2, item->name, value, ((n+1)%cols)?" ":"\n");
|
||||
if (diff) // TODO: use inverse colors
|
||||
//dbg->printf (Color_INVERT_RESET); //Color_RESET);
|
||||
dbg->printf (Color_RESET); //Color_RESET);
|
||||
break;
|
||||
case 3:
|
||||
if (diff) {
|
||||
char woot[32];
|
||||
snprintf (woot, sizeof (woot), " was 0x%08"PFMT64x"\n", diff);
|
||||
dbg->printf (fmt, item->name, value, woot);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
dbg->printf (fmt, item->name, value, "\n");
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
if (rad=='j') dbg->printf ("}\n");
|
||||
else if (n>0 && rad==2 && ((n%cols)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user