Skip to content

Commit

Permalink
Implement ccdf and improve help for ccd? ##diff
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Jan 2, 2025
1 parent c234086 commit 86b06e5
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions libr/core/cmd_cmp.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static RCoreHelpMessage help_msg_c = {
"cc", " [at]", "compares in two hexdump columns of block size",
"ccc", " [at]", "same as above, but only showing different lines",
"ccd", " [at]", "compares in two disasm columns of block size",
"ccdf", " [at]", "compares function disasm with the other function",
"ccdd", " [at]", "compares decompiler output (e cmd.pdc=pdg|pdd)",
"cd", " [dir]", "chdir",
// "cc", " [offset]", "code bindiff current block against offset"
Expand Down Expand Up @@ -1399,19 +1400,36 @@ static int cmd_cmp(void *data, const char *input) {
if (input[1] == '?') { // "cc?"
r_core_cmd_help_contains (core, help_msg_c, "cc");
} else if (input[1] == 'd') { // "ccd"
if (input[2] == 'd') { // "ccdd"
if (input[2] == '?') {
r_core_cmd_help_contains (core, help_msg_c, "ccd");
} else if (input[2] == 'd') { // "ccdd"
cmd_cmp_disasm (core, input + 3, 'd');
} else {
cmd_cmp_disasm (core, input + 2, 'c');
}
} else {
} else if (input[1] == 'f') { // "ccdf"
RAnalFunction *fcn = r_anal_get_function_at (core->anal, core->offset);
if (fcn) {
const int obs = core->blocksize;
const int fsz = r_anal_function_linear_size (fcn);
r_core_block_size (core, fsz);
if (input[2] == ' ') {
r_core_cmdf (core, "ccd%s", input + 2);
} else {
R_LOG_ERROR ("Missing argument");
}
r_core_block_size (core, obs);
} else {
R_LOG_ERROR ("Cannot find function");
}
} else if (!input[1] || input[1] == ' ') {
ut32 oflags = core->print->flags;
ut64 addr = 0; // TOTHINK: Not sure what default address should be
if (input[1] == 'c') { // "ccc"
core->print->flags |= R_PRINT_FLAGS_DIFFOUT;
addr = r_num_math (core->num, input + 2);
} else {
if (*input && input[1]) {
if (input[0] && input[1]) {
addr = r_num_math (core->num, input + 2);
}
}
Expand All @@ -1425,6 +1443,8 @@ static int cmd_cmp(void *data, const char *input) {
free (b);
}
core->print->flags = oflags;
} else {
r_core_return_invalid_command (core, "cc", input[1]);
}
break;
case 'i': // "ci"
Expand Down

0 comments on commit 86b06e5

Please sign in to comment.