Use RLog in RCons ##api

This commit is contained in:
pancake 2022-04-25 01:12:44 +02:00 committed by GitHub
parent 560f7fb424
commit 138906e27f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 49 additions and 52 deletions

View File

@ -674,7 +674,7 @@ static int node_match_functions(RAnal *anal, const RFlirtNode *root_node) {
continue;
}
if (!anal->iob.read_at (anal->iob.io, func->addr, func_buf, (int)func_size)) {
eprintf ("Couldn't read function %s at 0x%"PFMT64x"\n", func->name, func->addr);
R_LOG_WARN ("Couldn't read function %s at 0x%"PFMT64x, func->name, func->addr);
free (func_buf);
continue;
}
@ -732,9 +732,7 @@ static ut8 read_module_tail_bytes(RFlirtModule *module, RBuffer *b) {
goto err_exit;
}
r_list_append (module->tail_bytes, tail_byte);
#if DEBUG
eprintf ("READ TAIL BYTE: %04X: %02X\n", tail_byte->offset, tail_byte->value);
#endif
R_LOG_DEBUG ("READ TAIL BYTE: %04X: %02X", tail_byte->offset, tail_byte->value);
}
return true;

View File

@ -3710,7 +3710,7 @@ static void anop64(csh handle, RAnalOp *op, cs_insn *insn) {
}
break;
default:
R_LOG_DEBUG ("ARM64 analysis: Op type %d at 0x%" PFMT64x " not handled\n", insn->id, op->addr);
R_LOG_DEBUG ("ARM64 analysis: Op type %d at 0x%" PFMT64x " not handled", insn->id, op->addr);
break;
}
}
@ -4210,7 +4210,7 @@ jmp $$ + 4 + ( [delta] * 2 )
op->ptrsize = 2;
break;
default:
R_LOG_DEBUG ("ARM analysis: Op type %d at 0x%" PFMT64x " not handled\n", insn->id, op->addr);
R_LOG_DEBUG ("ARM analysis: Op type %d at 0x%" PFMT64x " not handled", insn->id, op->addr);
break;
}
itcond = ht_uu_find (ht_it, addr, &found);

View File

@ -1209,7 +1209,7 @@ static void anop64(RAnal *a, RAnalOp *op, Instruction *insn) {
op->fail = addr + op->size;
break;
default:
R_LOG_DEBUG ("ARM64 analysis: Op type %d at 0x%" PFMT64x " not handled\n", insn->operation, op->addr);
R_LOG_DEBUG ("ARM64 analysis: Op type %d at 0x%" PFMT64x " not handled", insn->operation, op->addr);
break;
}
}

View File

@ -208,8 +208,8 @@ static int java_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len
return sz;
}
IFDBG {
//eprintf ("Extracting op from buffer (%d byte(s)) @ 0x%04x\n", len, addr);
//eprintf ("Parsing op: (0x%02x) %s.\n", op_byte, JAVA_OPS[op_byte].name);
R_LOG_DEBUG ("Extracting op from buffer (%d byte(s)) @ 0x%04x\n", len, addr);
R_LOG_DEBUG ("Parsing op: (0x%02x) %s.\n", op_byte, JAVA_OPS[op_byte].name);
}
op->addr = addr;
op->size = sz;
@ -312,19 +312,20 @@ static int java_cmd_ext(RAnal *anal, const char* input) {
r_java_new_method ();
break;
case 'u':
switch (*(input+1)) {
switch (input[1]) {
case 't': {java_update_anal_types (anal, obj); return true;}
default: break;
}
break;
case 's':
switch (*(input+1)) {
//case 'e': return java_resolve_cp_idx_b64 (anal, input+2);
default: break;
switch (input[1]) {
//case 'e': return java_resolve_cp_idx_b64 (anal, input+2);
default: break;
}
break;
default: eprintf("Command not supported"); break;
default:
eprintf ("Command not supported");
break;
}
return 0;
}

View File

@ -1374,21 +1374,21 @@ static bool elf_init(ELFOBJ *bin) {
return false;
}
if (!init_phdr (bin) && !is_bin_etrel (bin)) {
R_LOG_DEBUG ("Cannot initialize program headers\n");
R_LOG_DEBUG ("Cannot initialize program headers");
}
if (bin->ehdr.e_type != ET_CORE) {
if (!init_shdr (bin)) {
R_LOG_DEBUG ("Cannot initialize section headers\n");
R_LOG_DEBUG ("Cannot initialize section headers");
}
if (!init_strtab (bin)) {
R_LOG_DEBUG ("Cannot initialize strings table\n");
R_LOG_DEBUG ("Cannot initialize strings table");
}
if (!init_dynstr (bin) && !is_bin_etrel (bin)) {
R_LOG_DEBUG ("Cannot initialize dynamic strings\n");
R_LOG_DEBUG ("Cannot initialize dynamic strings");
}
bin->baddr = Elf_(r_bin_elf_get_baddr) (bin);
if (!init_dynamic_section (bin) && !Elf_(r_bin_elf_is_static) (bin) && !is_bin_etrel (bin)) {
R_LOG_DEBUG ("Cannot initialize dynamic section\n");
R_LOG_DEBUG ("Cannot initialize dynamic section");
}
}
bin->imports_by_ord_size = 0;

View File

@ -680,7 +680,7 @@ R_API RCons *r_cons_new(void) {
GetConsoleMode (h, &I->term_buf);
I->term_raw = 0;
if (!SetConsoleCtrlHandler ((PHANDLER_ROUTINE)__w32_control, TRUE)) {
eprintf ("r_cons: Cannot set control console handler\n");
R_LOG_ERROR ("r_cons: Cannot set control console handler");
}
#endif
I->pager = NULL; /* no pager by default */

View File

@ -42,7 +42,7 @@ R_API int r_cons_pipe_open(const char *file, int fdn, int append) {
const int fd_flags = O_BINARY | O_RDWR | O_CREAT | (append? O_APPEND: O_TRUNC);
int fd = r_sandbox_open (targetFile, fd_flags, 0644);
if (fd == -1) {
eprintf ("r_cons_pipe_open: Cannot open file '%s'\n", file);
R_LOG_ERROR ("r_cons_pipe_open: Cannot open file '%s'", file);
free (targetFile);
return -1;
}
@ -52,7 +52,7 @@ R_API int r_cons_pipe_open(const char *file, int fdn, int append) {
}
backup_fdn = fdn;
if (!__dupDescriptor (fd, fdn)) {
eprintf ("Cannot dup stdout to %d\n", fdn);
R_LOG_ERROR ("Cannot dup stdout to %d", fdn);
free (targetFile);
return -1;
}

View File

@ -545,7 +545,7 @@ R_API bool r_line_hist_save(const char *file) {
*p = 0;
if (!r_sys_mkdirp (path)) {
if (r_sandbox_check (R_SANDBOX_GRAIN_FILES)) {
eprintf ("Could not save history into %s\n", path);
R_LOG_ERROR ("Could not save history into %s", path);
}
goto end;
}
@ -1551,7 +1551,7 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) {
if (clipText) {
char *txt = r_sys_conv_win_to_utf8 (clipText);
if (!txt) {
R_LOG_ERROR ("Failed to allocate memory\n");
R_LOG_ERROR ("Failed to allocate memory");
break;
}
int len = strlen (txt);

View File

@ -59,7 +59,7 @@ static void filesave(void) {
}
}
if (!path) {
eprintf ("No file given.\n");
R_LOG_ERROR ("No file given.");
return;
}
if (lines) {
@ -70,9 +70,9 @@ static void filesave(void) {
}
}
if (r_file_dump (path, (const ut8 *)lines, bytes, 0)) {
eprintf ("File '%s' saved (%d byte(s))\n", path, bytes);
R_LOG_INFO ("File '%s' saved (%d byte(s))", path, bytes);
} else {
eprintf ("Cannot save file\n");
R_LOG_ERROR ("Cannot save file");
}
nlines = r_str_split (lines, '\n');
}
@ -91,13 +91,12 @@ R_API char *r_cons_editor(const char *file, const char *str) {
lines = r_file_slurp (file, &sz);
bytes = (int)sz;
if (!lines) {
eprintf ("Failed to load '%s'.\n", file);
R_LOG_ERROR ("Failed to load '%s'.", file);
R_FREE (path);
return NULL;
}
nlines = r_str_split (lines, '\n');
eprintf ("Loaded %d lines on %d byte(s)\n",
(nlines? (nlines - 1): 0), bytes);
R_LOG_INFO ("Loaded %d lines on %d byte(s)", (nlines? (nlines - 1): 0), bytes);
} else {
path = NULL;
}

View File

@ -87,7 +87,7 @@ static void parse_grep_expression(const char *str) {
len = 0;
}
if (len > R_CONS_GREP_BUFSIZE - 1) {
eprintf ("r_cons_grep: too long!\n");
R_LOG_ERROR ("r_cons_grep: too long!\n");
return;
}
if (len > 0 && str[len] == '?') {
@ -109,7 +109,7 @@ static void parse_grep_expression(const char *str) {
ptr = ptrs[ptrs_length];
ptrs_length++;
if (ptrs_length >= R_CONS_GREP_COUNT) {
eprintf ("to many nested greps\n");
R_LOG_ERROR ("to many nested greps\n");
return;
}
}
@ -353,12 +353,12 @@ static void parse_grep_expression(const char *str) {
continue;
}
if (wlen >= R_CONS_GREP_WORD_SIZE - 1) {
eprintf ("grep string too long\n");
R_LOG_ERROR ("grep string too long\n");
continue;
}
grep->nstrings++;
if (grep->nstrings > R_CONS_GREP_WORDS - 1) {
eprintf ("too many grep strings\n");
R_LOG_ERROR ("too many grep strings\n");
break;
}
r_str_ncpy (grep->strings[grep->nstrings - 1],
@ -893,7 +893,7 @@ R_API int r_cons_grep_line(char *buf, int len) {
}
outlen = outlen > 0? outlen - 1: 0;
if (outlen > len) { // should never happen
eprintf ("r_cons_grep_line: wtf, how you reach this?\n");
R_LOG_ERROR ("r_cons_grep_line: wtf, how you reach this?\n");
free (in);
free (out);
return -1;

View File

@ -116,7 +116,7 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
if (esc == 1) {
// \x1b[2J
if (ptr[0] != '[') {
eprintf ("Oops invalid escape char\n");
R_LOG_ERROR ("Oops invalid escape char\n");
esc = 0;
str = ptr + 1;
continue;

View File

@ -20,7 +20,7 @@ R_API char *r_cons_hud_file(const char *f) {
// the lines starting with # )
R_API char *r_cons_hud_line_string(const char *s) {
if (!r_cons_is_interactive ()) {
eprintf ("Hud mode requires scr.interactive=true.\n");
R_LOG_ERROR ("Hud mode requires scr.interactive=true.");
return NULL;
}
char *os, *track, *ret, *o = strdup (s);
@ -59,7 +59,7 @@ R_API char *r_cons_hud_line_string(const char *s) {
// the lines starting with # )
R_API char *r_cons_hud_string(const char *s) {
if (!r_cons_is_interactive ()) {
eprintf ("Hud mode requires scr.interactive=true.\n");
R_LOG_ERROR ("Hud mode requires scr.interactive=true.");
return NULL;
}
char *os, *track, *ret, *o = strdup (s);
@ -454,7 +454,7 @@ R_API char *r_cons_hud_path(const char *path, int dir) {
}
r_list_free (files);
} else {
eprintf ("No files found\n");
R_LOG_ERROR ("No files found\n");
}
if (!ret) {
free (tmp);

View File

@ -173,7 +173,6 @@ R_API int r_cons_arrow_to_hjkl(int ch) {
do {
ch = r_cons_readchar ();
// just for debugging
//eprintf ( "%c", ch);
if (sc > 0) {
if (ch >= '0' && ch <= '9') {
pos[p++] = ch;
@ -642,7 +641,7 @@ R_API int r_cons_readchar(void) {
sigdelset (&sigmask, SIGWINCH);
while (pselect (STDIN_FILENO + 1, &readfds, NULL, NULL, NULL, &sigmask) == -1) {
if (errno == EBADF) {
eprintf ("r_cons_readchar (): EBADF\n");
R_LOG_ERROR ("r_cons_readchar (): EBADF");
return -1;
}
if (sigwinchFlag) {

View File

@ -8,7 +8,7 @@
R_API int r_cons_less_str(const char *str, const char *exitkeys) {
r_return_val_if_fail (str && *str, 0);
if (!r_cons_is_interactive ()) {
eprintf ("Internal less requires scr.interactive=true.\n");
R_LOG_ERROR ("Internal less requires scr.interactive=true.");
return 0;
}

View File

@ -25,7 +25,7 @@ R_API RLine *r_line_new(void) {
I.vtmode = 2;
#endif
if (!r_line_dietline_init ()) {
eprintf ("error: r_line_dietline_init\n");
R_LOG_ERROR ("r_line_dietline_init has failed");
}
r_line_completion_init (&I.completion, 4096);
return &I;
@ -81,7 +81,7 @@ R_API void r_line_completion_push(RLineCompletion *completion, const char *str)
}
} else {
completion->quit = true;
eprintf ("Warning: Maximum completion capacity reached, increase scr.maxtab");
R_LOG_WARN ("Maximum completion capacity reached, increase scr.maxtab");
}
}
@ -89,7 +89,7 @@ R_API void r_line_completion_set(RLineCompletion *completion, int argc, const ch
r_return_if_fail (completion && (argc >= 0));
r_line_completion_clear (completion);
if (argc > completion->args_limit) {
eprintf ("Warning: Maximum completion capacity reached, increase scr.maxtab");
R_LOG_WARN ("Maximum completion capacity reached, increase scr.maxtab");
}
size_t count = R_MIN (argc, completion->args_limit);
r_pvector_reserve (&completion->args, count);

View File

@ -211,7 +211,7 @@ static int r_cons_w32_hprint(DWORD hdl, const char *ptr, int len, bool vmode) {
if (esc == 1) {
// \x1b[2J
if (ptr[0] != '[') {
eprintf ("Oops invalid escape char\n");
R_LOG_ERROR ("Oops invalid escape char");
esc = 0;
str = ptr + 1;
continue;

View File

@ -325,7 +325,7 @@ R_API char *r_cons_pal_parse(const char *str, R_NULLABLE RColor *outcol) {
r_cons_rgb_str (out, sizeof (out), &rcolor);
}
} else {
eprintf ("Invalid html color code\n");
R_LOG_WARN ("Invalid html color code");
}
} else if (!strncmp (fgcolor, "rgb:", 4)) { // "rgb:123" rgb format
if (strlen (fgcolor + 4) == 3) { // "rgb:RGB"
@ -401,7 +401,7 @@ R_API char *r_cons_pal_parse(const char *str, R_NULLABLE RColor *outcol) {
} else if (!strncmp(p, "blink", 5)) {
rcolor.attr |= R_CONS_ATTR_BLINK;
} else {
eprintf ("Failed to parse terminal attributes: %s\n", p);
R_LOG_ERROR ("Failed to parse terminal attributes: %s", p);
break;
}
p = strchr (p, ' ');
@ -625,7 +625,7 @@ R_API int r_cons_pal_set(const char *key, const char *val) {
return true;
}
}
eprintf ("r_cons_pal_set: Invalid color %s\n", key);
R_LOG_ERROR ("r_cons_pal_set: Invalid color %s", key);
return false;
}

View File

@ -5,7 +5,7 @@ e scr.interactive=false
pd 1~..
EOF
EXPECT_ERR=<<EOF
Internal less requires scr.interactive=true.
ERROR: Internal less requires scr.interactive=true.
EOF
RUN
@ -16,6 +16,6 @@ e scr.interactive=false
pd 1~...
EOF
EXPECT_ERR=<<EOF
Hud mode requires scr.interactive=true.
ERROR: Hud mode requires scr.interactive=true.
EOF
RUN