Skip to content

Commit

Permalink
Prefix 0x hex values in drr ##debug
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Oct 25, 2023
1 parent dfc0c20 commit e424a1b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
8 changes: 4 additions & 4 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static RCoreHelpMessage help_msg_avg = {

static RCoreHelpMessage help_msg_aC = {
"Usage:", "aC[fej] [addr-of-call]", " # analyze call args",
"aCe", "", "use ESIL emulation to find out arguments of a call (uses 'abte')",
"aCe", "", "use ESIL emulation to find out arguments of a call (uses 'abpe')",
"aCf", "", "same as .aCe* $$ @@=`pdr~call`",
NULL
};
Expand Down Expand Up @@ -5894,7 +5894,7 @@ void cmd_anal_reg(RCore *core, const char *str) {
r_cons_printf ("%d\n", sz);
free (buf);
} break;
case 'b':
case 'b':
if (str[1] == '?') { // "arb" WORK IN PROGRESS // DEBUG COMMAND
r_core_cmd_help_match (core, help_msg_ar, "arb", false);
} else {
Expand Down Expand Up @@ -12337,7 +12337,7 @@ static void cmd_anal_abp(RCore *core, const char *input) {
if (showcmds) {
r_cons_printf ("aepc orip\n");
} else {
r_core_cmd0 (core, "dr=");
// r_core_cmd0 (core, "dr=");
r_core_cmd_call (core, "aepc orip");
}
free (paths);
Expand Down Expand Up @@ -13847,7 +13847,7 @@ static void cmd_anal_aC(RCore *core, const char *input) {
ut64 pcv = r_num_math (core->num, iarg);
if (input[0] == 'e') { // "aCe"
is_aCer = (input[1] == '*');
r_core_cmdf (core, ".abpe 0x%08"PFMT64x, pcv);
r_core_cmdf (core, "abpe 0x%08"PFMT64x, pcv);
}
RAnalOp* op = r_core_anal_op (core, pcv, -1);
if (!op) {
Expand Down
13 changes: 6 additions & 7 deletions libr/core/cmd_debug.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2074,8 +2074,8 @@ R_API void r_core_debug_ri(RCore *core, RReg *reg, int mode) {
R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
char *color = "";
char *colorend = "";
int had_colors = r_config_get_i (core->config, "scr.color");
bool use_colors = had_colors != 0;
int scr_color = r_config_get_i (core->config, "scr.color");
bool use_colors = scr_color != 0;
int delta = 0;
ut64 diff, value;
int bits = core->rasm->config->bits;
Expand Down Expand Up @@ -2127,11 +2127,11 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
char *valuestr = NULL;
if (delta && use_colors) {
namestr = r_str_newf ("%s%s%s", color, r->name, colorend);
valuestr = r_str_newf ("%s%"PFMT64x"%s", color, value, colorend);
valuestr = r_str_newf ("%s0x%"PFMT64x"%s", color, value, colorend);
r_cons_print (Color_RESET);
} else {
namestr = r_str_new (r->name);
valuestr = r_str_newf ("%"PFMT64x, value);
valuestr = r_str_newf ("0x%"PFMT64x, value);
}
ut64 o_offset = core->offset;
char *rrstr = r_core_anal_hasrefs (core, value, true);
Expand All @@ -2150,9 +2150,8 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
r_cons_print (s);
free (s);
r_table_free (t);

if (had_colors) {
r_config_set_i (core->config, "scr.color", had_colors);
if (scr_color) {
r_config_set_i (core->config, "scr.color", scr_color);
}
}

Expand Down
18 changes: 18 additions & 0 deletions test/db/anal/path
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,21 @@ EXPECT=<<EOF
421
EOF
RUN

NAME=abpe-ls-m1
FILE=bins/mach0/ls-m1
ARGS=-a arm -b 64
CMDS=<<EOF
aeim
aa
s main
abpe 0x100003b00
arA
EOF
EXPECT=<<EOF
0x100007a3d 0x100007a3d 0x5500736c2f6e6962 bin/ls.U @ x0 ascii ('b')
0x100007a44 0x100007a44 0x3330303278696e55 Unix2003 @ x1 ascii ('U')
0x00000000 0x00000000 0xffffffffffffffff ........
0x00000000 0x00000000 0xffffffffffffffff ........
EOF
RUN
2 changes: 1 addition & 1 deletion test/db/cmd/cmd_dr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ dr ebx=0x10
drrj~{3}
EOF
EXPECT=<<EOF
{"role":"A1","reg":"ebx","value":"10","refstr":"16 ebx"}
{"role":"A1","reg":"ebx","value":"0x10","refstr":"16 ebx"}
EOF
RUN

0 comments on commit e424a1b

Please sign in to comment.