diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index a64a7db263..be97f3759c 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -2762,6 +2762,7 @@ static void __anal_reg_list(RCore *core, int type, int bits, char mode) { } else if (!bits) { bits = core->anal->bits; } + int mode2 = mode; if (core->anal) { core->dbg->reg = core->anal->reg; if (core->anal->cur && core->anal->cur->arch) { @@ -2771,10 +2772,16 @@ static void __anal_reg_list(RCore *core, int type, int bits, char mode) { } /* workaround for 6502 */ if (!strcmp (core->anal->cur->arch, "6502") && bits == 8) { - r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, 16, mode, use_color); // XXX detect which one is current usage + mode2 = mode == 'j' ? 'J' : mode; + r_cons_printf ("{"); + r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, 16, mode2, use_color); // XXX detect which one is current usage + r_cons_printf (","); } if (!strcmp (core->anal->cur->arch, "avr") && bits == 8) { - r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, 16, mode, use_color); // XXX detect which one is current usage + mode2 = mode == 'j' ? 'J' : mode; + r_cons_printf ("{"); + r_debug_reg_list (core->dbg, R_REG_TYPE_GPR, 16, mode2, use_color); // XXX detect which one is current usage + r_cons_printf (","); } } } @@ -2790,8 +2797,12 @@ static void __anal_reg_list(RCore *core, int type, int bits, char mode) { 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, type, bits, mode, use_color); + r_debug_reg_list (core->dbg, type, bits, mode2, use_color); + if (mode2 == 'J') { + r_cons_printf ("}"); + } core->dbg->reg = hack; + r_cons_newline (); } // XXX dup from drp :OOO diff --git a/libr/debug/dreg.c b/libr/debug/dreg.c index c435ae4669..bf13df3bc5 100644 --- a/libr/debug/dreg.c +++ b/libr/debug/dreg.c @@ -175,7 +175,7 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char diff = r_reg_get_value (dbg->reg, item); r_reg_arena_swap (dbg->reg, false); delta = value-diff; - if (rad == 'j') { + if (tolower (rad) == 'j') { snprintf (strvalue, sizeof (strvalue),"%"PFMT64d, value); } else { snprintf (strvalue, sizeof (strvalue),"0x%08"PFMT64x, value); @@ -200,6 +200,7 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char itmidx++; switch (rad) { + case 'J': case 'j': dbg->cb_printf ("%s\"%s\":%s", n?",":"", item->name, strvalue); @@ -278,6 +279,8 @@ R_API int r_debug_reg_list(RDebug *dbg, int type, int size, int rad, const char beach: if (rad == 'j') { dbg->cb_printf ("}\n"); + } else if (rad == 'J') { + // do nothing } else if (n > 0 && rad == 2 && ((n%cols))) { dbg->cb_printf ("\n"); }