mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Use more R_LOG instead of eprintfs in some commands ##shell
This commit is contained in:
parent
195a40edc3
commit
8c73bc6d89
@ -4305,7 +4305,7 @@ static int cmd_af(RCore *core, const char *input) {
|
||||
{
|
||||
ut64 addr = 0;
|
||||
if (input[2] == '?') {
|
||||
eprintf ("afd [offset]\n");
|
||||
r_core_cmd_help_match (core, help_msg_af, "afd", true);
|
||||
} else if (input[2] == ' ') {
|
||||
addr = r_num_math (core->num, input + 2);
|
||||
} else {
|
||||
@ -4334,7 +4334,7 @@ static int cmd_af(RCore *core, const char *input) {
|
||||
r_cons_println (fcn->name);
|
||||
}
|
||||
} else {
|
||||
eprintf ("afd: Cannot find function\n");
|
||||
R_LOG_ERROR ("afd: Cannot find function");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6239,7 +6239,7 @@ static void cmd_anal_info(RCore *core, const char *input) {
|
||||
} else if (input[1] == '-') {
|
||||
r_anal_purge_imports (core->anal);
|
||||
} else {
|
||||
eprintf ("Usagae: aii [namespace] # see afii - imports\n");
|
||||
r_core_cmd_help_match (core, help_msg_ai, "aii", true);
|
||||
}
|
||||
} else {
|
||||
if (core->anal->imports) {
|
||||
@ -7561,7 +7561,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
|
||||
n = strchr (input, ' ');
|
||||
n1 = R_STR_ISNOTEMPTY (n) ? strchr (n + 1, ' ') : NULL;
|
||||
if ((!n || !n1) || (!*n || !*n1)) {
|
||||
eprintf ("aesp [offset] [num]\n");
|
||||
r_core_cmd_help_match (core, help_msg_aes, "aesp", true);
|
||||
break;
|
||||
}
|
||||
adr = R_STR_ISNOTEMPTY (n)? r_num_math (core->num, n + 1): 0;
|
||||
@ -7641,7 +7641,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
|
||||
break;
|
||||
}
|
||||
if (op->type == R_ANAL_OP_TYPE_CALL || op->type == R_ANAL_OP_TYPE_UCALL) {
|
||||
eprintf ("stop in call instruction at 0x%08" PFMT64x "\n", addr);
|
||||
R_LOG_INFO ("stop in call instruction at 0x%08" PFMT64x, addr);
|
||||
break;
|
||||
}
|
||||
r_anal_op_free (op);
|
||||
@ -7771,7 +7771,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
|
||||
free (out);
|
||||
}
|
||||
} else {
|
||||
eprintf ("esil.stats is empty. Run 'aei'\n");
|
||||
R_LOG_INFO ("esil.stats is empty. Run 'aei'");
|
||||
}
|
||||
break;
|
||||
case '-':
|
||||
@ -7819,10 +7819,10 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
|
||||
cmd_aespc (core, bb->addr, bb->addr + bb->size, bb->ninstr);
|
||||
// r_core_cmdf (core, "aesp `ab~addr[1]` `ab~ninstr[1]`");
|
||||
} else {
|
||||
eprintf ("No basic block in this address\n");
|
||||
R_LOG_ERROR ("No basic block in this address");
|
||||
}
|
||||
} else {
|
||||
eprintf ("No function in this address\n");
|
||||
R_LOG_ERROR ("No function in this address");
|
||||
}
|
||||
// ab~ninstr[1]
|
||||
}
|
||||
@ -7859,7 +7859,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
|
||||
break;
|
||||
}
|
||||
if (!esil->trace) {
|
||||
eprintf ("No ESIL trace started\n");
|
||||
R_LOG_ERROR ("No ESIL trace started");
|
||||
break;
|
||||
}
|
||||
r_esil_trace_free (esil->trace);
|
||||
@ -7872,7 +7872,7 @@ static void cmd_anal_esil(RCore *core, const char *input, bool verbose) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
eprintf ("Unknown command. Use `aetr`\n");
|
||||
R_LOG_ERROR ("Unknown command");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -8342,7 +8342,7 @@ static void cmd_anal_opcode(RCore *core, const char *input) {
|
||||
R_LOG_ERROR ("Unknown mnemonic");
|
||||
}
|
||||
} else {
|
||||
eprintf ("Use: aod[?a] ([opcode]) describe current, [given] or all mnemonics\n");
|
||||
r_core_cmd_help_match (core, help_msg_ao, "aod", false);
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
@ -8408,7 +8408,7 @@ static void cmd_anal_aftertraps(RCore *core, const char *input) {
|
||||
ut64 addr, addr_end;
|
||||
ut64 len = r_num_math (core->num, input);
|
||||
if (len > 0xffffff) {
|
||||
eprintf ("Too big\n");
|
||||
R_LOG_ERROR ("Length is too large");
|
||||
return;
|
||||
}
|
||||
RBinFile *bf = r_bin_cur (core->bin);
|
||||
@ -8426,7 +8426,7 @@ static void cmd_anal_aftertraps(RCore *core, const char *input) {
|
||||
if (bf->size > map->delta) {
|
||||
len = bf->size - map->delta;
|
||||
} else {
|
||||
eprintf ("Opps something went wrong aac\n");
|
||||
R_LOG_ERROR ("Oops something went wrong aac");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@ -8440,7 +8440,7 @@ static void cmd_anal_aftertraps(RCore *core, const char *input) {
|
||||
if (bf->size > core->offset) {
|
||||
len = bf->size - core->offset;
|
||||
} else {
|
||||
eprintf ("Oops invalid range\n");
|
||||
R_LOG_ERROR ("Oops invalid range");
|
||||
len = 0;
|
||||
}
|
||||
}
|
||||
@ -9249,7 +9249,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
|
||||
if (space) {
|
||||
addr = r_num_math (core->num, space + 1);
|
||||
if (core->num->nc.errors > 0) {
|
||||
eprintf ("Invalid argument.\n");
|
||||
R_LOG_ERROR ("Invalid argument");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -9420,7 +9420,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
|
||||
r_cons_println (pj_string (pj));
|
||||
}
|
||||
} else {
|
||||
eprintf ("Cannot find any function\n");
|
||||
R_LOG_ERROR ("Cannot find any function");
|
||||
}
|
||||
pj_free (pj);
|
||||
} else { // "axf"
|
||||
@ -9441,7 +9441,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) {
|
||||
if (space) {
|
||||
addr = r_num_math (core->num, space + 1);
|
||||
if (core->num->nc.errors > 0) {
|
||||
eprintf ("Invalid argument.\n");
|
||||
R_LOG_ERROR ("Invalid argument");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@ -9602,7 +9602,7 @@ static void cmd_anal_hint(RCore *core, const char *input) {
|
||||
} else if (input[1] == '-') {
|
||||
r_anal_hint_unset_arch (core->anal, core->offset);
|
||||
} else {
|
||||
eprintf ("Missing argument\n");
|
||||
R_LOG_ERROR ("Missing argument");
|
||||
}
|
||||
break;
|
||||
case 'o': // "aho"
|
||||
@ -9629,7 +9629,7 @@ static void cmd_anal_hint(RCore *core, const char *input) {
|
||||
if (type != -1) {
|
||||
r_anal_hint_set_type (core->anal, core->offset, type);
|
||||
} else {
|
||||
eprintf ("Unknown opcode type. Try: io, acmp, add, sync, call, cjmp, cmp, nop, ...\n");
|
||||
R_LOG_ERROR ("Unknown opcode type. Try: io, acmp, add, sync, call, cjmp, cmp, nop,,,");
|
||||
}
|
||||
} else {
|
||||
r_core_cmd_help (core, help_msg_aho);
|
||||
@ -9650,7 +9650,7 @@ static void cmd_anal_hint(RCore *core, const char *input) {
|
||||
free (ptr);
|
||||
} else if (input[1] == '-') {
|
||||
if (!strcmp (input + 2, "*")) {
|
||||
eprintf ("Delete all asm.bits hints is not yet supported.\n");
|
||||
R_LOG_TODO ("Delete all asm.bits hints is not yet supported");
|
||||
} else {
|
||||
ut64 off = input[2]? r_num_math (core->num, input + 2): core->offset;
|
||||
r_anal_hint_unset_bits (core->anal, off);
|
||||
@ -9899,7 +9899,7 @@ static void cmd_anal_hint(RCore *core, const char *input) {
|
||||
if (ptr && *ptr) {
|
||||
addr = r_num_math (core->num, ptr);
|
||||
} else {
|
||||
eprintf ("address is unvalid\n");
|
||||
R_LOG_ERROR ("address is not valid");
|
||||
free (type);
|
||||
break;
|
||||
}
|
||||
@ -9954,7 +9954,7 @@ static void cmd_anal_hint(RCore *core, const char *input) {
|
||||
}
|
||||
}
|
||||
if (!otype) {
|
||||
eprintf ("wrong type for opcode offset\n");
|
||||
R_LOG_ERROR ("wrong type for opcode offset");
|
||||
}
|
||||
r_list_free (otypes);
|
||||
}
|
||||
@ -10056,7 +10056,7 @@ static bool convert_dot_to_image(RCore *core, const char *dot_file, const char *
|
||||
char *dot = dot_executable_path ();
|
||||
bool result = false;
|
||||
if (!dot) {
|
||||
eprintf ("Graphviz not found\n");
|
||||
R_LOG_ERROR ("Graphviz not found in PATH");
|
||||
return false;
|
||||
}
|
||||
const char *ext = r_config_get (core->config, "graph.gv.format");
|
||||
@ -10071,7 +10071,7 @@ static bool convert_dot_to_image(RCore *core, const char *dot_file, const char *
|
||||
dot, ext, ext, viewer, ext);
|
||||
free (viewer);
|
||||
} else {
|
||||
eprintf ("Cannot find a valid picture viewer\n");
|
||||
R_LOG_ERROR ("Cannot find a valid picture viewer");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
@ -46,57 +46,26 @@ static void showBuffer(RBuffer *b) {
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int compileShellcode(REgg *egg, const char *input) {
|
||||
int i = 0;
|
||||
RBuffer *b;
|
||||
if (!r_egg_shellcode (egg, input)) {
|
||||
eprintf ("Unknown shellcode '%s'\n", input);
|
||||
return 1;
|
||||
}
|
||||
if (!r_egg_assemble (egg)) {
|
||||
eprintf ("r_egg_assemble : invalid assembly\n");
|
||||
r_egg_reset (egg);
|
||||
return 1;
|
||||
}
|
||||
if (!egg->bin) {
|
||||
egg->bin = r_buf_new ();
|
||||
}
|
||||
if (!(b = r_egg_get_bin (egg))) {
|
||||
eprintf ("r_egg_get_bin: invalid egg :(\n");
|
||||
r_egg_reset (egg);
|
||||
return 1;
|
||||
}
|
||||
r_egg_finalize (egg);
|
||||
for (i = 0; i < b->length; i++) {
|
||||
r_cons_printf ("%02x", b->buf[i]);
|
||||
}
|
||||
r_cons_newline ();
|
||||
r_egg_reset (egg);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int cmd_egg_compile(REgg *egg) {
|
||||
RBuffer *b;
|
||||
int ret = false;
|
||||
char *p = r_egg_option_get (egg, "egg.shellcode");
|
||||
if (p && *p) {
|
||||
if (!r_egg_shellcode (egg, p)) {
|
||||
eprintf ("Unknown shellcode '%s'\n", p);
|
||||
R_LOG_ERROR ("Unknown shellcode '%s'", p);
|
||||
free (p);
|
||||
return false;
|
||||
}
|
||||
free (p);
|
||||
} else {
|
||||
eprintf ("Setup a shellcode before (gi command)\n");
|
||||
R_LOG_ERROR ("Setup a shellcode before (gi command)");
|
||||
free (p);
|
||||
return false;
|
||||
}
|
||||
|
||||
r_egg_compile (egg);
|
||||
if (!r_egg_assemble (egg)) {
|
||||
eprintf ("r_egg_assemble: invalid assembly\n");
|
||||
R_LOG_ERROR ("r_egg_assemble: invalid assembly");
|
||||
return false;
|
||||
}
|
||||
p = r_egg_option_get (egg, "egg.padding");
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* radare - LGPL - Copyright 2009-2022 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2023 - pancake */
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_core.h"
|
||||
|
||||
static RCoreHelpMessage help_msg_fR = {
|
||||
@ -876,7 +875,7 @@ rep:
|
||||
if (fi) {
|
||||
r_flag_item_set_alias (fi, ptr);
|
||||
} else {
|
||||
eprintf ("Cannot find flag '%s'\n", name);
|
||||
R_LOG_ERROR ("Cannot find flag '%s'", name);
|
||||
}
|
||||
} else {
|
||||
r_core_cmd_help_match (core, help_msg_f, "fa", true);
|
||||
@ -912,8 +911,7 @@ rep:
|
||||
switch (*str) {
|
||||
case '\0':
|
||||
r_core_cmd_help_match (core, help_msg_f, "fR", true);
|
||||
eprintf ("Example to relocate PIE flags on debugger:\n"
|
||||
" > fR entry0 `dm~:1[1]`\n");
|
||||
R_LOG_INFO ("Relocate PIE flags in debugger with f.ex: fR entry0 `dm~:1[1]`");
|
||||
break;
|
||||
case '?':
|
||||
r_core_cmd_help (core, help_msg_fR);
|
||||
@ -933,11 +931,10 @@ rep:
|
||||
from = r_num_math (core->num, str+1);
|
||||
to = r_num_math (core->num, p+1);
|
||||
ret = r_flag_relocate (core->flags, from, mask, to);
|
||||
eprintf ("Relocated %d flags\n", ret);
|
||||
R_LOG_INFO ("Relocated %d flags", ret);
|
||||
} else {
|
||||
r_core_cmd_help_match (core, help_msg_f, "fR", true);
|
||||
eprintf ("Example to relocate PIE flags on debugger:\n"
|
||||
" > fR entry0 `dm~:1[1]`\n");
|
||||
R_LOG_INFO ("Relocate PIE flags in debugger with f.ex: fR entry0 `dm~:1[1]`");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1038,7 +1035,7 @@ rep:
|
||||
}
|
||||
if (addFlag) {
|
||||
if (!r_name_check (cstr)) {
|
||||
eprintf ("Invalid flag name '%s'.\n", cstr);
|
||||
R_LOG_ERROR ("Invalid flag name '%s'", cstr);
|
||||
return false;
|
||||
}
|
||||
item = r_flag_set (core->flags, cstr, off, bsze);
|
||||
@ -1064,7 +1061,7 @@ rep:
|
||||
if (fcn) {
|
||||
r_anal_function_delete_label_at (fcn, off);
|
||||
} else {
|
||||
eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
R_LOG_ERROR ("Cannot find function at 0x%08"PFMT64x, off);
|
||||
}
|
||||
} else {
|
||||
if (strchr (flagname, '*')) {
|
||||
@ -1090,7 +1087,7 @@ rep:
|
||||
if (fcn) {
|
||||
print_function_labels (core->anal, fcn, input[1]);
|
||||
} else {
|
||||
eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
R_LOG_ERROR ("Cannot find function at 0x%08"PFMT64x, off);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1110,7 +1107,7 @@ rep:
|
||||
r_anal_function_set_label (fcn, name, off);
|
||||
}
|
||||
} else {
|
||||
eprintf ("Cannot find function at 0x%08"PFMT64x"\n", off);
|
||||
R_LOG_ERROR ("Cannot find function at 0x%08"PFMT64x, off);
|
||||
}
|
||||
free (name);
|
||||
}
|
||||
@ -1120,7 +1117,7 @@ rep:
|
||||
if (fcn) {
|
||||
print_function_labels (core->anal, fcn, 0);
|
||||
} else {
|
||||
eprintf ("Local flags require a function to work.");
|
||||
R_LOG_ERROR ("Local flags require a function to work");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1164,8 +1161,9 @@ rep:
|
||||
free (arg);
|
||||
} else { // "fl"
|
||||
item = r_flag_get_i (core->flags, core->offset);
|
||||
if (item)
|
||||
if (item) {
|
||||
r_cons_printf ("0x%08"PFMT64x"\n", item->size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
@ -1180,7 +1178,9 @@ rep:
|
||||
item->offset, item->size);
|
||||
r_core_cmd0 (core, cmd);
|
||||
}
|
||||
} else eprintf ("Missing arguments\n");
|
||||
} else {
|
||||
R_LOG_ERROR ("add help here");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 'z': // "fz"
|
||||
@ -1188,17 +1188,14 @@ rep:
|
||||
break;
|
||||
case 'x':
|
||||
if (input[1] == ' ') {
|
||||
char cmd[128];
|
||||
RFlagItem *item = r_flag_get_i (core->flags,
|
||||
r_num_math (core->num, input+2));
|
||||
if (item) {
|
||||
r_cons_printf ("0x%08"PFMT64x"\n", item->offset);
|
||||
snprintf (cmd, sizeof (cmd), "px@%"PFMT64d":%"PFMT64d,
|
||||
item->offset, item->size);
|
||||
r_core_cmd0 (core, cmd);
|
||||
r_core_cmdf (core, "px@%"PFMT64d":%"PFMT64d, item->offset, item->size);
|
||||
}
|
||||
} else {
|
||||
eprintf ("Missing arguments\n");
|
||||
R_LOG_ERROR ("Missing arguments");
|
||||
}
|
||||
break;
|
||||
case ',': // "f,"
|
||||
|
@ -1552,7 +1552,7 @@ static void ds_show_xrefs(RDisasmState *ds) {
|
||||
R_FREE (name);
|
||||
free (realname);
|
||||
} else {
|
||||
eprintf ("Corrupted database?\n");
|
||||
R_LOG_ERROR ("Corrupted database?");
|
||||
}
|
||||
}
|
||||
r_list_free (addrs);
|
||||
|
@ -23,9 +23,9 @@ EXPECT=<<EOF
|
||||
0xffffffffffffffff
|
||||
EOF
|
||||
EXPECT_ERR=<<EOF
|
||||
Invalid flag name '123'.
|
||||
Invalid flag name '$123'.
|
||||
Invalid flag name '$foo'.
|
||||
ERROR: Invalid flag name '123'
|
||||
ERROR: Invalid flag name '$123'
|
||||
ERROR: Invalid flag name '$foo'
|
||||
EOF
|
||||
RUN
|
||||
|
||||
@ -439,7 +439,7 @@ all
|
||||
f.patata@0x00400410
|
||||
EOF
|
||||
EXPECT_ERR=<<EOF
|
||||
Cannot find function at 0x00000000
|
||||
ERROR: Cannot find function at 0x00000000
|
||||
EOF
|
||||
RUN
|
||||
|
||||
@ -462,7 +462,7 @@ all
|
||||
{"entry0":{"patata":4195344}}
|
||||
EOF
|
||||
EXPECT_ERR=<<EOF
|
||||
Cannot find function at 0x00000000
|
||||
ERROR: Cannot find function at 0x00000000
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user