Fix show register value in column (#16010) ##debug
* Fix for ar= and dr= and add tests * increase width to accomodate register name larger than 4 chr * fix flag type register value not printed * update r_debug_reg_list() to accept '=' arg
This commit is contained in:
parent
14d7f7c1df
commit
17026c8c62
|
@ -3968,7 +3968,7 @@ static void __anal_reg_list(RCore *core, int type, int bits, char mode) {
|
|||
pcbits = reg->size;
|
||||
}
|
||||
if (pcbits) {
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, 2, use_color); // XXX detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, mode, use_color); // XXX detect which one is current usage
|
||||
}
|
||||
}
|
||||
r_debug_reg_list (core->dbg, type, bits, mode2, use_color);
|
||||
|
@ -4286,7 +4286,7 @@ void cmd_anal_reg(RCore *core, const char *str) {
|
|||
}
|
||||
}
|
||||
}
|
||||
__anal_reg_list (core, type, size, 2);
|
||||
__anal_reg_list (core, type, size, str[0]);
|
||||
if (!r_list_empty (core->dbg->q_regs)) {
|
||||
r_list_free (core->dbg->q_regs);
|
||||
}
|
||||
|
|
|
@ -2989,19 +2989,19 @@ static void cmd_debug_reg(RCore *core, const char *str) {
|
|||
if (r_config_get_i (core->config, "cfg.debug")) {
|
||||
if (r_debug_reg_sync (core->dbg, R_REG_TYPE_GPR, false)) {
|
||||
if (pcbits && pcbits != bits) {
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, 2, use_color); // xxx detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, str[0], use_color); // xxx detect which one is current usage
|
||||
}
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, bits, 2, use_color); // xxx detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, bits, str[0], use_color); // xxx detect which one is current usage
|
||||
if (pcbits2) {
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits2, 2, use_color); // xxx detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits2, str[0], use_color); // xxx detect which one is current usage
|
||||
}
|
||||
} //else eprintf ("cannot retrieve registers from pid %d\n", core->dbg->pid);
|
||||
} else {
|
||||
RReg *orig = core->dbg->reg;
|
||||
core->dbg->reg = core->anal->reg;
|
||||
if (pcbits && pcbits != bits)
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, 2, use_color); // xxx detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, bits, 2, use_color); // xxx detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, pcbits, str[0], use_color); // xxx detect which one is current usage
|
||||
r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, bits, str[0], use_color); // xxx detect which one is current usage
|
||||
core->dbg->reg = orig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,14 +105,14 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char
|
|||
if (dbg->bits & R_SYS_BITS_64) {
|
||||
//fmt = "%s = 0x%08"PFMT64x"%s";
|
||||
fmt = "%s = %s%s";
|
||||
fmt2 = "%s%4s%s %s%s";
|
||||
fmt2 = "%s%7s%s %s%s";
|
||||
kwhites = " ";
|
||||
colwidth = dbg->regcols? 20: 25;
|
||||
cols = 3;
|
||||
} else {
|
||||
//fmt = "%s = 0x%08"PFMT64x"%s";
|
||||
fmt = "%s = %s%s";
|
||||
fmt2 = "%s%4s%s %s%s";
|
||||
fmt2 = "%s%7s%s %s%s";
|
||||
kwhites = " ";
|
||||
colwidth = 20;
|
||||
cols = 4;
|
||||
|
@ -226,8 +226,7 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char
|
|||
case '.':
|
||||
dbg->cb_printf ("dr %s=%s\n", item->name, strvalue);
|
||||
break;
|
||||
case 'd':
|
||||
case 2:
|
||||
case '=':
|
||||
{
|
||||
int len, highlight = use_color && pr && pr->cur_enabled && itmidx == pr->cur;
|
||||
char *str, whites[32], content[300];
|
||||
|
@ -241,26 +240,16 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char
|
|||
if (delta && use_color) {
|
||||
dbg->cb_printf ("%s", use_color);
|
||||
}
|
||||
if (item->flags) {
|
||||
str = r_reg_get_bvalue (dbg->reg, item);
|
||||
len = 12 - strlen (str);
|
||||
memset (whites, ' ', sizeof (whites));
|
||||
whites[len] = 0;
|
||||
dbg->cb_printf (" %s%s%s %s%s", a, item->name, b,
|
||||
str, ((n+1)%cols)? whites: "\n");
|
||||
free (str);
|
||||
} else {
|
||||
snprintf (content, sizeof (content),
|
||||
fmt2, "", item->name, "", strvalue, "");
|
||||
len = colwidth - strlen (content);
|
||||
if (len < 0) {
|
||||
len = 0;
|
||||
}
|
||||
memset (whites, ' ', sizeof (whites));
|
||||
whites[len] = 0;
|
||||
dbg->cb_printf (fmt2, a, item->name, b, strvalue,
|
||||
((n+1)%cols)? whites: "\n");
|
||||
snprintf (content, sizeof (content),
|
||||
fmt2, "", item->name, "", strvalue, "");
|
||||
len = colwidth - strlen (content);
|
||||
if (len < 0) {
|
||||
len = 0;
|
||||
}
|
||||
memset (whites, ' ', sizeof (whites));
|
||||
whites[len] = 0;
|
||||
dbg->cb_printf (fmt2, a, item->name, b, strvalue,
|
||||
((n+1)%cols)? whites: "\n");
|
||||
if (highlight) {
|
||||
dbg->cb_printf (Color_INVERT_RESET);
|
||||
}
|
||||
|
@ -269,6 +258,7 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 3:
|
||||
if (delta) {
|
||||
char woot[512];
|
||||
|
|
|
@ -959,3 +959,23 @@ aae 20 @ main
|
|||
pd 9 @ main
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=arm show registers in table
|
||||
FILE=-
|
||||
EXPECT=<<EOF
|
||||
sb 0x00000000 sl 0x00000000 fp 0x00000000
|
||||
ip 0x00000000 sp 0x00000000 lr 0x00000000
|
||||
pc 0x00000000 r0 0x00000000 r1 0x00000000
|
||||
r2 0x00000000 r3 0x00000000 r4 0x00000000
|
||||
r5 0x00000000 r6 0x00000000 r7 0x00000000
|
||||
r8 0x00000000 r9 0x00000000 r10 0x00000000
|
||||
r11 0x00000000 r12 0x00000000 r13 0x00000000
|
||||
r14 0x00000000 r15 0x00000000 cpsr 0x00000000
|
||||
blank 0x00000000
|
||||
EOF
|
||||
CMDS=<<EOF
|
||||
e asm.arch=arm
|
||||
e asm.bits=32
|
||||
ar=
|
||||
EOF
|
||||
RUN
|
||||
|
|
|
@ -3303,3 +3303,20 @@ af
|
|||
pdf
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=x86_64 show registers in table
|
||||
FILE=-
|
||||
EXPECT=<<EOF
|
||||
rax 0x00000000 rbx 0x00000000 rcx 0x00000000
|
||||
rdx 0x00000000 rsi 0x00000000 rdi 0x00000000
|
||||
r8 0x00000000 r9 0x00000000 r10 0x00000000
|
||||
r11 0x00000000 r12 0x00000000 r13 0x00000000
|
||||
r14 0x00000000 r15 0x00000000 rip 0x00000000
|
||||
rbp 0x00000000 rflags 0x00000000 rsp 0x00000000
|
||||
EOF
|
||||
CMDS=<<EOF
|
||||
e asm.arch=x86
|
||||
e asm.bits=64
|
||||
ar=
|
||||
EOF
|
||||
RUN
|
||||
|
|
Loading…
Reference in New Issue