diff --git a/libr/anal/cc.c b/libr/anal/cc.c index cb4a28148d..7fe31de883 100644 --- a/libr/anal/cc.c +++ b/libr/anal/cc.c @@ -116,13 +116,13 @@ R_API char *r_anal_cc_get(RAnal *anal, const char *name) { int i; // get cc by name and print the expr if (r_str_cmp (sdb_const_get (DB, name, 0), "cc", -1)) { - eprintf ("This is not a valid calling convention name (%s)\n", name); + R_LOG_ERROR ("This is not a valid calling convention name (%s)", name); return NULL; } r_strf_var (ccret, 128, "cc.%s.ret", name); const char *ret = sdb_const_get (DB, ccret, 0); if (!ret) { - eprintf ("Cannot find return type for %s\n", name); + R_LOG_ERROR ("Cannot find return type for %s", name); return NULL; } RStrBuf *sb = r_strbuf_new (NULL); diff --git a/libr/anal/esil.c b/libr/anal/esil.c index 1f3604a9d4..6eef03a8b5 100644 --- a/libr/anal/esil.c +++ b/libr/anal/esil.c @@ -36,7 +36,7 @@ static inline ut64 genmask(int bits) { return m; } -#define ERR(x) if (esil->verbose) { eprintf ("%s\n", x); } +#define ERR(...) if (esil->verbose) { R_LOG_ERROR (__VA_ARGS__); } static bool isnum(RAnalEsil *esil, const char *str, ut64 *num) { if (!esil || !str) { @@ -130,11 +130,10 @@ R_API bool r_anal_esil_set_op(RAnalEsil *esil, const char *op, RAnalEsilOpCb cod if (!eop) { eop = R_NEW (RAnalEsilOp); if (!eop) { - eprintf ("Cannot allocate esil-operation %s\n", op); return false; } if (!ht_pp_insert (esil->ops, op, eop)) { - eprintf ("Cannot set esil-operation %s\n", op); + R_LOG_ERROR ("Cannot set esil-operation %s", op); free (eop); return false; } @@ -819,9 +818,7 @@ static bool esil_eq(RAnalEsil *esil) { char *dst = r_anal_esil_pop (esil); char *src = r_anal_esil_pop (esil); if (!src || !dst) { - if (esil->verbose) { - eprintf ("Missing elements in the esil stack for '=' at 0x%08"PFMT64x"\n", esil->address); - } + ERR ("Missing elements in the esil stack for '=' at 0x%08"PFMT64x, esil->address); free (src); free (dst); return false; @@ -2105,7 +2102,7 @@ static bool esil_poke_some(RAnalEsil *esil) { const int size_bytes = regsize / 8; const ut32 written = r_anal_esil_mem_write (esil, ptr, b, size_bytes); if (written != size_bytes) { - //eprintf ("Cannot write at 0x%08" PFMT64x "\n", ptr); + //R_LOG_ERROR ("Cannot write at 0x%08" PFMT64x, ptr); esil->trap = 1; } ptr += size_bytes; @@ -2218,7 +2215,7 @@ static bool esil_peek_some(RAnalEsil *esil) { bool oks = r_anal_esil_mem_read (esil, ptr, a, 4); if (!oks) { if (esil->verbose) { - eprintf ("Cannot peek from 0x%08" PFMT64x "\n", ptr); + R_LOG_ERROR ("Cannot peek from 0x%08" PFMT64x, ptr); } free (dst); free (count); @@ -3568,7 +3565,7 @@ static int evalWord(RAnalEsil *esil, const char *ostr, const char **str) { return 2; } if (esil->verbose) { - eprintf ("Cannot find word %d\n", esil->parse_goto); + R_LOG_ERROR ("Cannot find word %d", esil->parse_goto); } return 1; } diff --git a/libr/anal/esil_cfg.c b/libr/anal/esil_cfg.c index 66ef2a29a5..1b25b3a72b 100644 --- a/libr/anal/esil_cfg.c +++ b/libr/anal/esil_cfg.c @@ -345,7 +345,7 @@ void _handle_goto (EsilCfgGen *gen, ut32 idx) { EsilVal *v = r_stack_pop (gen->vals); if (!v || v->type != ESIL_VAL_CONST) { free (v); - eprintf ("Cannot resolve GOTO dst :(\n"); + R_LOG_ERROR ("Cannot resolve GOTO dst :("); goto beach; } diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index 079e437f98..ed6ca11f4b 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -944,7 +944,7 @@ repeat: if ((buf[2] == 0xff || buf[2] == 0xfe) && buf[3] == 0xff) { leaddr_pair *pair = R_NEW (leaddr_pair); if (!pair) { - eprintf ("Cannot create leaddr_pair\n"); + R_LOG_ERROR ("Cannot create leaddr_pair"); gotoBeach (R_ANAL_RET_ERROR); } pair->op_addr = op->addr; @@ -965,7 +965,7 @@ repeat: if (op->ptr != UT64_MAX) { leaddr_pair *pair = R_NEW (leaddr_pair); if (!pair) { - eprintf ("Cannot create leaddr_pair\n"); + R_LOG_ERROR ("Cannot create leaddr_pair"); gotoBeach (R_ANAL_RET_ERROR); } pair->op_addr = op->addr; diff --git a/libr/anal/jmptbl.c b/libr/anal/jmptbl.c index ac10e50b28..0f1a13b8fe 100644 --- a/libr/anal/jmptbl.c +++ b/libr/anal/jmptbl.c @@ -59,14 +59,14 @@ static inline void analyze_new_case(RAnal *anal, RAnalFunction *fcn, RAnalBlock if (block) { if (block->addr != ip) { st64 d = block->addr - ip; - eprintf ("Cannot find basic block for switch case at 0x%08"PFMT64x" bbdelta = %d\n", ip, (int)R_ABS (d)); + R_LOG_ERROR ("Cannot find basic block for switch case at 0x%08"PFMT64x" bbdelta = %d", ip, (int)R_ABS (d)); block = NULL; return; } else { - eprintf ("Inconsistent basicblock storage issue at 0x%08"PFMT64x"\n", ip); + R_LOG_ERROR ("Inconsistent basicblock storage issue at 0x%08"PFMT64x, ip); } } else { - eprintf ("Major disaster at 0x%08"PFMT64x"\n", ip); + R_LOG_ERROR ("Major disaster at 0x%08"PFMT64x, ip); return; } // analyze at given address diff --git a/libr/anal/p/anal_avr.c b/libr/anal/p/anal_avr.c index 0cfc1b7849..c2fe1f2b7d 100644 --- a/libr/anal/p/anal_avr.c +++ b/libr/anal/p/anal_avr.c @@ -1887,7 +1887,6 @@ static bool avr_custom_spm_page_write(RAnalEsil *esil) { // perform writing //eprintf ("SPM_PAGE_WRITE %ld bytes @ 0x%08" PFMT64x ".\n", page_size, addr); if (!(t = malloc (1 << page_size_bits))) { - eprintf ("Cannot alloc a buffer for copying the temporary page.\n"); return false; } r_anal_esil_mem_read (esil, tmp_page, (ut8 *) t, 1 << page_size_bits); diff --git a/libr/asm/asm.c b/libr/asm/asm.c index 4e090369f6..46354423c3 100644 --- a/libr/asm/asm.c +++ b/libr/asm/asm.c @@ -1128,7 +1128,7 @@ R_API RAsmCode *r_asm_massemble(RAsm *a, const char *assembly) { } if (stage == STAGES - 1) { if (ret < 1) { - eprintf ("Cannot assemble '%s' at line %d\n", ptr_start, linenum); + R_LOG_ERROR ("Cannot assemble '%s' at line %d", ptr_start, linenum); goto fail; } acode->len = idx + ret; diff --git a/libr/bin/bfile.c b/libr/bin/bfile.c index 3ee7cec603..1d8219770a 100644 --- a/libr/bin/bfile.c +++ b/libr/bin/bfile.c @@ -167,8 +167,6 @@ static int string_scan_range(RList *list, RBinFile *bf, int min, len = res; free (buf); buf = out; - } else { - eprintf ("Cannot allocate\n"); } } else { eprintf ("Invalid value for RABIN2_CHARSET.\n"); @@ -945,7 +943,6 @@ R_API RList *r_bin_file_compute_hashes(RBin *bin, ut64 limit) { const size_t blocksize = 64000; ut8 *buf = malloc (blocksize); if (!buf) { - eprintf ("Cannot allocate computation buffer\n"); return NULL; } @@ -1073,7 +1070,7 @@ R_API RBinSymbol *r_bin_file_add_method(RBinFile *bf, const char *klass, const c RBinClass *c = r_bin_file_add_class (bf, klass, NULL, 0); if (!c) { - eprintf ("Cannot allocate class %s\n", klass); + R_LOG_ERROR ("Cannot allocate class %s", klass); return NULL; } RBinSymbol *sym = __getMethod (bf, klass, method); diff --git a/libr/bin/bin.c b/libr/bin/bin.c index 4c9cf98e50..8135b65b93 100644 --- a/libr/bin/bin.c +++ b/libr/bin/bin.c @@ -546,7 +546,7 @@ R_API bool r_bin_list_plugin(RBin *bin, const char* name, PJ *pj, int json) { return true; } - eprintf ("Cannot find plugin %s\n", name); + R_LOG_ERROR ("Cannot find plugin %s", name); return false; } @@ -987,11 +987,11 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) { } Sdb *binfile_sdb = binfile? binfile->sdb: NULL; if (!binfile_sdb) { - // eprintf ("Cannot find SDB!\n"); + // R_LOG_ERROR ("Cannot find SDB!"); return; } if (!binfile) { - // eprintf ("Binary format not currently loaded!\n"); + // R_LOG_ERROR ("Binary format not currently loaded!"); return; } sdb_unset (binfile_sdb, ARCHS_KEY, 0); @@ -1176,7 +1176,7 @@ R_API RBuffer *r_bin_package(RBin *bin, const char *type, const char *file, RLis ut8 *num8 = (ut8*)# RBuffer *buf = r_buf_new_file (file, O_RDWR | O_CREAT, 0644); if (!buf) { - eprintf ("Cannot open file %s - Permission Denied.\n", file); + R_LOG_ERROR ("Cannot open file %s - Permission Denied", file); return NULL; } r_buf_write_at (buf, 0, (const ut8*)"\xca\xfe\xba\xbe", 4); @@ -1193,7 +1193,7 @@ R_API RBuffer *r_bin_package(RBin *bin, const char *type, const char *file, RLis if (f_buf) { eprintf ("ADD %s %"PFMT64u"\n", f, (ut64)f_len); } else { - eprintf ("Cannot open %s\n", f); + R_LOG_ERROR ("Cannot open %s", f); free (f_buf); continue; } diff --git a/libr/bin/bobj.c b/libr/bin/bobj.c index 4e65ec8c0a..9992cfe530 100644 --- a/libr/bin/bobj.c +++ b/libr/bin/bobj.c @@ -221,8 +221,6 @@ static void filter_classes(RBinFile *bf, RList *list) { r_bin_filter_sym (bf, ht, sym->vaddr, sym); } } - } else { - eprintf ("Cannot alloc %d byte(s)\n", namepad_len); } } ht_pu_free (db); diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index c17bfe040e..b05e279b04 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -3563,7 +3563,7 @@ static RBinElfSymbol* parse_gnu_debugdata(ELFOBJ *bin, size_t *ret_size) { return NULL; } if (r_buf_read_at (bin->b, addr, data, size) == -1) { - eprintf ("Cannot read%c\n", 10); + R_LOG_ERROR ("Cannot read"); } size_t osize; ut8 *odata = r_sys_unxz (data, size, &osize); @@ -4092,7 +4092,7 @@ static bool get_nt_file_maps(ELFOBJ *bin, RList *core_maps) { bin->phdr[ph].p_offset + offset, elf_nhdr, elf_nhdr_size); if (ret != elf_nhdr_size) { - eprintf ("Cannot read more NOTES header from CORE\n"); + R_LOG_ERROR ("Cannot read more NOTES header from CORE"); free (elf_nhdr); goto fail; } diff --git a/libr/bin/format/elf/elf_write.c b/libr/bin/format/elf/elf_write.c index f7dd6d2a79..1ad19c3e1c 100644 --- a/libr/bin/format/elf/elf_write.c +++ b/libr/bin/format/elf/elf_write.c @@ -43,7 +43,7 @@ ut64 Elf_(r_bin_elf_resize_section)(RBinFile *bf, const char *name, ut64 size) { } if (delta == 0) { - eprintf ("Cannot find section\n"); + R_LOG_ERROR ("Cannot find section"); return 0; } diff --git a/libr/bin/format/objc/mach0_classes.c b/libr/bin/format/objc/mach0_classes.c index ce411015fd..6a12edb8a6 100644 --- a/libr/bin/format/objc/mach0_classes.c +++ b/libr/bin/format/objc/mach0_classes.c @@ -1172,7 +1172,7 @@ void MACH0_(get_class_t)(mach0_ut p, RBinFile *bf, RBinClass *klass, bool dupe, return; } if (left < size) { - eprintf ("Cannot parse obj class info out of bounds\n"); + R_LOG_ERROR ("Cannot parse obj class info out of bounds"); return; } len = r_buf_read_at (bf->buf, r, sc, size); @@ -1253,7 +1253,7 @@ static SwiftType parse_type_entry(RBinFile *bf, ut64 typeaddr) { ut32 words[16] = {0}; st32 *swords = (st32*)&words; if (r_buf_read_at (bf->buf, typeaddr, (ut8*)&words, sizeof (words)) < 1) { - eprintf ("Invalid pointers.\n"); + R_LOG_ERROR ("Invalid pointers"); return st; } #if 0 @@ -1461,7 +1461,7 @@ RList *MACH0_(parse_classes)(RBinFile *bf, objc_cache_opt_info *oi) { for (i = 0; i < s_size; i += sizeof (mach0_ut)) { left = s_size - i; if (left < sizeof (mach0_ut)) { - eprintf ("Chopped classlist data\n"); + R_LOG_ERROR ("Chopped classlist data"); break; } if (!(klass = R_NEW0 (RBinClass))) { @@ -1613,7 +1613,7 @@ void MACH0_(get_category_t)(mach0_ut p, RBinFile *bf, RBinClass *klass, RSkipLis return; } if (left < size) { - eprintf ("Cannot parse obj category info out of bounds\n"); + R_LOG_ERROR ("Cannot parse obj category info out of bounds"); return; } len = r_buf_read_at (bf->buf, r, sc, size); diff --git a/libr/bin/p/bin_sfc.c b/libr/bin/p/bin_sfc.c index f6ff9a9cfa..acb4d1eb77 100644 --- a/libr/bin/p/bin_sfc.c +++ b/libr/bin/p/bin_sfc.c @@ -47,23 +47,21 @@ static RBinInfo* info(RBinFile *bf) { int reat = r_buf_read_at (bf->buf, 0x7FC0 + hdroffset, (ut8*)&sfchdr, SFC_HDR_SIZE); if (reat != SFC_HDR_SIZE) { - eprintf ("Unable to read SFC/SNES header\n"); + R_LOG_ERROR ("Unable to read SFC/SNES header"); return NULL; } if ( (sfchdr.comp_check != (ut16)~(sfchdr.checksum)) || ((sfchdr.rom_setup & 0x1) != 0) ){ - // if the fixed 0x33 byte or the LoROM indication are not found, then let's try interpreting the ROM as HiROM reat = r_buf_read_at (bf->buf, 0xFFC0 + hdroffset, (ut8*)&sfchdr, SFC_HDR_SIZE); if (reat != SFC_HDR_SIZE) { - eprintf ("Unable to read SFC/SNES header\n"); + R_LOG_ERROR ("Unable to read SFC/SNES header"); return NULL; } if ( (sfchdr.comp_check != (ut16)~(sfchdr.checksum)) || ((sfchdr.rom_setup & 0x1) != 1) ) { - - eprintf ("Cannot determine if this is a LoROM or HiROM file\n"); + R_LOG_ERROR ("Cannot determine if this is a LoROM or HiROM file"); return NULL; } } @@ -128,7 +126,7 @@ static RList* sections(RBinFile *bf) { int reat = r_buf_read_at (bf->buf, 0x7FC0 + hdroffset, (ut8*)&sfchdr, SFC_HDR_SIZE); if (reat != SFC_HDR_SIZE) { - eprintf ("Unable to read SFC/SNES header\n"); + R_LOG_ERROR ("Unable to read SFC/SNES header"); return NULL; } @@ -138,13 +136,12 @@ static RList* sections(RBinFile *bf) { reat = r_buf_read_at (bf->buf, 0xFFC0 + hdroffset, (ut8*)&sfchdr, SFC_HDR_SIZE); if (reat != SFC_HDR_SIZE) { - eprintf ("Unable to read SFC/SNES header\n"); + R_LOG_ERROR ("Unable to read SFC/SNES header"); return NULL; } if ( (sfchdr.comp_check != (ut16)~(sfchdr.checksum)) || ((sfchdr.rom_setup & 0x1) != 1) ) { - - eprintf ("Cannot determine if this is a LoROM or HiROM file\n"); + R_LOG_ERROR ("Cannot determine if this is a LoROM or HiROM file"); return NULL; } is_hirom = true; diff --git a/libr/bin/pdb/pdb_downloader.c b/libr/bin/pdb/pdb_downloader.c index bc3366a602..e7ddc30c4d 100644 --- a/libr/bin/pdb/pdb_downloader.c +++ b/libr/bin/pdb/pdb_downloader.c @@ -73,7 +73,7 @@ static int download(struct SPDBDownloader *pd) { opt->dbg_file); if (r_file_exists (abspath_to_file)) { - eprintf ("File already downloaded.\n"); + R_LOG_ERROR ("File already downloaded"); free (abspath_to_file); return 1; } @@ -88,7 +88,7 @@ static int download(struct SPDBDownloader *pd) { opt->guid, R_SYS_DIR, archive_name); - eprintf ("Attempting to download compressed pdb in %s\n", abspath_to_archive); + R_LOG_INFO ("Attempting to download compressed pdb in %s", abspath_to_archive); char *abs_arch_esc = r_str_escape_sh (abspath_to_archive); #if __WINDOWS__ char *abs_file_esc = r_str_escape_sh (abspath_to_file); @@ -113,7 +113,7 @@ static int download(struct SPDBDownloader *pd) { if (opt->extract > 0 && res) { eprintf ("Attempting to decompress pdb\n"); if (res && ((cmd_ret = r_sys_cmd (extractor_cmd)) != 0)) { - eprintf ("cab extractor exited with error %d\n", cmd_ret); + R_LOG_ERROR ("cab extractor exited with error %d", cmd_ret); res = 0; } r_file_rm (abspath_to_archive); @@ -135,7 +135,7 @@ void init_pdb_downloader(SPDBDownloaderOpt *opt, SPDBDownloader *pd) { pd->opt = R_NEW0 (SPDBDownloaderOpt); if (!pd->opt) { pd->download = 0; - eprintf ("Cannot allocate memory for SPDBDownloaderOpt.\n"); + R_LOG_ERROR ("Cannot allocate memory for SPDBDownloaderOpt"); return; } pd->opt->dbg_file = strdup (opt->dbg_file); @@ -177,17 +177,17 @@ int r_bin_pdb_download(RCore *core, PJ *pj, int isradjson, SPDBOptions *options) RBinInfo *info = r_bin_get_info (core->bin); if (!info || !info->debug_file_name) { - eprintf ("Can't find debug filename\n"); + R_LOG_ERROR ("Can't find debug filename"); return 1; } if (!is_valid_guid (info->guid)) { - eprintf ("Invalid GUID for file\n"); + R_LOG_ERROR ("Invalid GUID for file"); return 1; } if (!options || !options->symbol_server || !options->user_agent) { - eprintf ("Can't retrieve pdb configurations\n"); + R_LOG_ERROR ("Can't retrieve pdb configurations"); return 1; } diff --git a/libr/bp/bp_plugin.c b/libr/bp/bp_plugin.c index 1b834a4d72..a8cafab350 100644 --- a/libr/bp/bp_plugin.c +++ b/libr/bp/bp_plugin.c @@ -24,7 +24,7 @@ R_API int r_bp_plugin_add(RBreakpoint *bp, RBreakpointPlugin *foo) { RListIter *iter; RBreakpointPlugin *h; if (!bp) { - eprintf ("Cannot add plugin because dbg->bp is null and/or plugin is null\n"); + R_LOG_ERROR ("Cannot add plugin because dbg->bp is null and/or plugin is null"); return false; } /* avoid dupped plugins */ diff --git a/libr/cons/cons.c b/libr/cons/cons.c index b64b37896e..206b281b2d 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -1138,11 +1138,11 @@ R_API void r_cons_flush(void) { FILE *d = r_sandbox_fopen (tee, "a+"); if (d) { if (C->buffer_len != fwrite (C->buffer, 1, C->buffer_len, d)) { - eprintf ("r_cons_flush: fwrite: error (%s)\n", tee); + R_LOG_ERROR ("r_cons_flush: fwrite: error (%s)", tee); } fclose (d); } else { - eprintf ("Cannot write on '%s'\n", tee); + R_LOG_ERROR ("Cannot write on '%s'", tee); } } r_cons_highlight (I->highlight); diff --git a/libr/core/agraph.c b/libr/core/agraph.c index c466820f99..3c9a8488fc 100644 --- a/libr/core/agraph.c +++ b/libr/core/agraph.c @@ -4255,8 +4255,8 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int h = 25; can = r_cons_canvas_new (w, h); if (!can) { - eprintf ("Cannot create RCons.canvas context. Invalid screen " - "size? See scr.columns + scr.rows\n"); + R_LOG_ERROR ("Cannot create RCons.canvas context. Invalid screen " + "size? See scr.columns + scr.rows"); r_config_hold_free (hc); return false; } @@ -4598,7 +4598,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int if (undo) { r_core_seek (core, undo->off, false); } else { - eprintf ("Cannot undo\n"); + R_LOG_ERROR ("Cannot undo"); } if (r_config_get_i (core->config, "graph.few")) { g->need_reload_nodes = true; @@ -4611,7 +4611,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int if (undo) { r_core_seek (core, undo->off, false); } else { - eprintf ("Cannot redo\n"); + R_LOG_ERROR ("Cannot redo"); } if (r_config_get_i (core->config, "graph.few")) { g->need_reload_nodes = true; diff --git a/libr/core/blaze.c b/libr/core/blaze.c index 225d03b5b0..57f989a5ea 100644 --- a/libr/core/blaze.c +++ b/libr/core/blaze.c @@ -292,8 +292,8 @@ R_API bool core_anal_bbs(RCore *core, const char* input) { } if (op->mnemonic[0] == '?') { - eprintf ("? Bad op at: 0x%08"PFMT64x"\n", dst); - eprintf ("Cannot analyze opcode at 0x%"PFMT64x"\n", dst); + R_LOG_ERROR ("? Bad op at: 0x%08"PFMT64x, dst); + R_LOG_ERROR ("Cannot analyze opcode at 0x%"PFMT64x, dst); block_score -= 10; cur++; continue; @@ -579,8 +579,8 @@ R_API bool core_anal_bbs_range(RCore *core, const char* input) { } if (op->mnemonic[0] == '?') { - eprintf ("? Bad op at: 0x%08"PFMT64x"\n", cur + b_start); - eprintf ("Cannot analyze opcode at %"PFMT64x"\n", b_start + cur); + R_LOG_ERROR ("? Bad op at: 0x%08"PFMT64x, cur + b_start); + R_LOG_ERROR ("Cannot analyze opcode at %"PFMT64x, b_start + cur); block_score -= 10; cur++; continue; diff --git a/libr/core/canal.c b/libr/core/canal.c index f9f9472731..211e9457f8 100644 --- a/libr/core/canal.c +++ b/libr/core/canal.c @@ -4405,7 +4405,6 @@ R_API RCoreAnalStats* r_core_anal_get_stats(RCore *core, ut64 from, ut64 to, ut6 ut64 at; if (from == to || from == UT64_MAX || to == UT64_MAX) { - eprintf ("Cannot alloc for this range\n"); return NULL; } as = R_NEW0 (RCoreAnalStats); @@ -4683,11 +4682,11 @@ R_API void r_core_anal_fcn_merge(RCore *core, ut64 addr, ut64 addr2) { RAnalFunction *f1 = r_anal_get_function_at (core->anal, addr); RAnalFunction *f2 = r_anal_get_function_at (core->anal, addr2); if (!f1 || !f2) { - eprintf ("Cannot find function\n"); + R_LOG_ERROR ("Cannot find function"); return; } if (f1 == f2) { - eprintf ("Cannot merge the same function\n"); + R_LOG_ERROR ("Cannot merge the same function"); return; } // join all basic blocks from f1 into f2 if they are not @@ -5280,7 +5279,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) { // TODO: backup/restore register state before/after analysis const char *kpcname = r_reg_get_name (core->anal->reg, R_REG_NAME_PC); if (!kpcname || !*kpcname) { - eprintf ("Cannot find program counter register in the current profile.\n"); + R_LOG_ERROR ("Cannot find program counter register in the current profile"); return; } pcname = strdup (kpcname); @@ -5904,11 +5903,11 @@ R_API void r_core_anal_paths(RCore *core, ut64 from, ut64 to, bool followCalls, RAnalBlock *b1 = r_anal_bb_from_offset (core->anal, to); PJ *pj = NULL; if (!b0) { - eprintf ("Cannot find basic block for 0x%08"PFMT64x"\n", from); + R_LOG_ERROR ("Cannot find basic block for 0x%08"PFMT64x, from); return; } if (!b1) { - eprintf ("Cannot find basic block for 0x%08"PFMT64x"\n", to); + R_LOG_ERROR ("Cannot find basic block for 0x%08"PFMT64x, to); return; } RCoreAnalPaths rcap = {{0}}; @@ -6035,7 +6034,7 @@ static bool analyze_noreturn_function(RCore *core, RAnalFunction *f) { // get last opcode RAnalOp *op = r_core_op_anal (core, opaddr, R_ANAL_OP_MASK_HINT); if (!op) { - eprintf ("Cannot analyze opcode at 0x%08" PFMT64x "\n", opaddr); + R_LOG_ERROR ("Cannot analyze opcode at 0x%08" PFMT64x, opaddr); return false; } @@ -6100,7 +6099,7 @@ R_API void r_core_anal_propagate_noreturn(RCore *core, ut64 addr) { r_list_foreach (xrefs, iter, xref) { RAnalOp *xrefop = r_core_op_anal (core, xref->addr, R_ANAL_OP_MASK_ALL); if (!xrefop) { - eprintf ("Cannot analyze opcode at 0x%08" PFMT64x "\n", xref->addr); + R_LOG_ERROR ("Cannot analyze opcode at 0x%08" PFMT64x, xref->addr); continue; } ut64 call_addr = xref->addr; diff --git a/libr/core/cbin.c b/libr/core/cbin.c index 8967f777b4..c695792367 100644 --- a/libr/core/cbin.c +++ b/libr/core/cbin.c @@ -276,7 +276,7 @@ R_API void r_core_bin_export_info(RCore *core, int mode) { if (fi) { fi->size = r_num_math (core->num, v); } else { - eprintf ("Cannot find flag named '%s'\n", flagname); + R_LOG_ERROR ("Cannot find flag named '%s'", flagname); } } } @@ -302,7 +302,7 @@ R_API bool r_core_bin_load_structs(RCore *core, const char *file) { } } if (strchr (file, '\"')) { // TODO: escape "? - eprintf ("Invalid char found in filename\n"); + R_LOG_ERROR ("Invalid char found in filename"); return false; } RBinFileOptions opt = {0}; @@ -313,7 +313,7 @@ R_API bool r_core_bin_load_structs(RCore *core, const char *file) { r_bin_file_delete (core->bin, bf->id); return true; } - eprintf ("Cannot open bin '%s'\n", file); + R_LOG_ERROR ("Cannot open bin '%s'", file); return false; } @@ -3051,11 +3051,11 @@ static int bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, if (dl == datalen) { hashstr = build_hash_string (pj, mode, hashtypes, data, datalen); } else if (r->bin->verbose) { - eprintf ("Cannot read section at 0x%08"PFMT64x"\n", section->paddr); + R_LOG_ERROR ("Cannot read section at 0x%08"PFMT64x, section->paddr); } free (data); } else if (r->bin->verbose) { - eprintf ("Section at 0x%08"PFMT64x" larger than bin.hashlimit\n", section->paddr); + R_LOG_ERROR ("Section at 0x%08"PFMT64x" larger than bin.hashlimit", section->paddr); } } r_cons_printf ("0x%"PFMT64x" 0x%"PFMT64x" %s %s%s%s\n", @@ -3083,11 +3083,11 @@ static int bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, if (dl == datalen) { free (build_hash_string (pj, mode, hashtypes, data, datalen)); } else if (r->bin->verbose) { - eprintf ("Cannot read section at 0x%08"PFMT64x"\n", section->paddr); + R_LOG_ERROR ("Cannot read section at 0x%08"PFMT64x, section->paddr); } free (data); } else if (r->bin->verbose) { - eprintf ("Section at 0x%08"PFMT64x" larger than bin.hashlimit\n", section->paddr); + R_LOG_ERROR ("Section at 0x%08"PFMT64x" larger than bin.hashlimit", section->paddr); } } pj_kN (pj, "paddr", section->paddr); @@ -3107,11 +3107,11 @@ static int bin_sections(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, if (dl == datalen) { hashstr = build_hash_string (pj, mode, hashtypes, data, datalen); } else if (r->bin->verbose) { - eprintf ("Cannot read section at 0x%08"PFMT64x"\n", section->paddr); + R_LOG_ERROR ("Cannot read section at 0x%08"PFMT64x, section->paddr); } free (data); } else if (r->bin->verbose) { - eprintf ("Section at 0x%08"PFMT64x" larger than bin.hashlimit\n", section->paddr); + R_LOG_WARN ("Section at 0x%08"PFMT64x" larger than bin.hashlimit", section->paddr); } } if (section->arch || section->bits) { diff --git a/libr/core/cconfig.c b/libr/core/cconfig.c index 56664dda9f..ba3695f813 100644 --- a/libr/core/cconfig.c +++ b/libr/core/cconfig.c @@ -797,7 +797,7 @@ static bool cb_asmarch(void *user, void *data) { const char *asmcpu = r_config_get (core->config, "asm.cpu"); const char *asmos = r_config_get (core->config, "asm.os"); if (!r_syscall_setup (core->anal->syscall, node->value, core->anal->config->bits, asmcpu, asmos)) { - //eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n", + //R_LOG_ERROR ("asm.arch: Cannot setup syscall '%s/%s' from '%s'", // node->value, asmos, R2_LIBDIR"/radare2/"R2_VERSION"/syscall"); } } @@ -876,13 +876,13 @@ static bool cb_asmbits(void *user, void *data) { if (!ret) { RAsmPlugin *h = core->rasm->cur; if (!h) { - eprintf ("e asm.bits: Cannot set value, no plugins defined yet\n"); + R_LOG_ERROR ("e asm.bits: Cannot set value, no plugins defined yet"); ret = true; } - // else { eprintf ("Cannot set bits %d to '%s'\n", bits, h->name); } + // else { R_LOG_ERROR ("Cannot set bits %d to '%s'", bits, h->name); } } if (!r_anal_set_bits (core->anal, bits)) { - eprintf ("asm.arch: Cannot setup '%d' bits analysis engine\n", bits); + R_LOG_ERROR ("asm.arch: Cannot setup '%d' bits analysis engine", bits); ret = false; } } @@ -916,7 +916,7 @@ static bool cb_asmbits(void *user, void *data) { const char *asmcpu = r_config_get (core->config, "asm.cpu"); if (core->anal) { if (!r_syscall_setup (core->anal->syscall, asmarch, bits, asmcpu, asmos)) { - //eprintf ("asm.arch: Cannot setup syscall '%s/%s' from '%s'\n", + //R_LOG_ERROR ("asm.arch: Cannot setup syscall '%s/%s' from '%s'", // node->value, asmos, R2_LIBDIR"/radare2/"R2_VERSION"/syscall"); } __setsegoff (core->config, asmarch, core->anal->config->bits); @@ -1158,7 +1158,7 @@ static bool cb_binstrenc(void *user, void *data) { return true; } } - eprintf ("Unknown encoding: %s\n", node->value); + R_LOG_ERROR ("Unknown encoding: %s", node->value); free (enc); return false; } @@ -1475,7 +1475,7 @@ static bool cb_cfgsanbox(void *user, void *data) { RConfigNode *node = (RConfigNode*) data; int ret = r_sandbox_enable (node->i_value); if (node->i_value != ret) { - eprintf ("Cannot disable sandbox\n"); + R_LOG_ERROR ("Cannot disable sandbox"); } return (!node->i_value && ret)? 0: 1; } @@ -1834,7 +1834,7 @@ static bool cb_gotolimit(void *user, void *data) { RCore *core = (RCore *) user; RConfigNode *node = (RConfigNode*) data; if (r_sandbox_enable (0)) { - eprintf ("Cannot change gotolimit\n"); + R_LOG_ERROR ("Cannot change gotolimit"); return false; } if (core->anal->esil) { @@ -1855,7 +1855,7 @@ static bool cb_esilverbose(void *user, void *data) { static bool cb_esilstackdepth(void *user, void *data) { RConfigNode *node = (RConfigNode*) data; if (node->i_value < 3) { - eprintf ("esil.stack.depth must be greater than 2\n"); + R_LOG_ERROR ("esil.stack.depth must be greater than 2"); node->i_value = 32; } return true; @@ -2764,7 +2764,7 @@ static bool cb_prjname(void *user, void *data) { if (r_project_rename (core->prj, prjname)) { return true; } - eprintf ("Cannot rename project.\n"); + R_LOG_ERROR ("Cannot rename project"); } else { r_project_close (core->prj); } @@ -2773,7 +2773,7 @@ static bool cb_prjname(void *user, void *data) { if (r_project_open (core->prj, prjname, NULL)) { return true; } - eprintf ("Cannot open project.\n"); + R_LOG_ERROR ("Cannot open project"); } else { return true; } diff --git a/libr/core/cfile.c b/libr/core/cfile.c index 538e46e468..e9fb6dfeef 100644 --- a/libr/core/cfile.c +++ b/libr/core/cfile.c @@ -338,7 +338,7 @@ static bool setbpint(RCore *r, const char *mode, const char *sym) { #endif return true; } - eprintf ("Cannot set breakpoint at %s\n", sym); + R_LOG_ERROR ("Cannot set breakpoint at %s", sym); return false; } #endif @@ -735,7 +735,7 @@ R_API bool r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) { RFlagItem *impsym = r_flag_get (r->flags, flagname); free (flagname); if (!impsym) { - //eprintf ("Cannot find '%s' import in the PLT\n", imp->name); + //R_LOG_ERROR ("Cannot find '%s' import in the PLT", imp->name); continue; } ut64 imp_addr = impsym->offset; diff --git a/libr/core/cio.c b/libr/core/cio.c index 96e2b98217..977c9df722 100644 --- a/libr/core/cio.c +++ b/libr/core/cio.c @@ -25,7 +25,7 @@ R_API int r_core_setup_debugger(RCore *r, const char *debugbackend, bool attach) r_core_cmdf (r, "dpa %d", pid); } } else { - eprintf ("Cannot retrieve pid from io.\n"); + R_LOG_ERROR ("Cannot retrieve pid from io"); } } //this makes to attach twice showing warnings in the output @@ -77,7 +77,7 @@ R_API bool r_core_dump(RCore *core, const char *file, ut64 addr, ut64 size, int fd = r_sandbox_fopen (file, "wb"); } if (!fd) { - eprintf ("Cannot open '%s' for writing\n", file); + R_LOG_ERROR ("Cannot open '%s' for writing", file); return false; } /* some io backends seems to be buggy in those cases */ diff --git a/libr/core/cproject.c b/libr/core/cproject.c index 899462fc06..c8030d0f37 100644 --- a/libr/core/cproject.c +++ b/libr/core/cproject.c @@ -16,7 +16,7 @@ R_API bool r_project_rename(RProject *p, const char *newname) { } char *newprjdir = r_file_new (p->path, "..", newname, NULL); if (r_file_exists (newprjdir)) { - eprintf ("Cannot rename.\n"); + R_LOG_ERROR ("Cannot rename"); free (newprjdir); return false; } diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 31ec9cdfd0..9eef80fb64 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -738,7 +738,7 @@ static RDisasmState *ds_init(RCore *core) { RIOMap *map = r_io_map_add (core->io, ds->stackFd, R_PERM_RW, 0LL, addr, size); if (!map) { r_io_fd_close (core->io, ds->stackFd); - eprintf ("Cannot create map for tha stack, fd %d got closed again\n", ds->stackFd); + R_LOG_ERROR ("Cannot create map for tha stack, fd %d got closed again", ds->stackFd); ds->stackFd = -1; } else { r_io_map_set_name (map, "fake.stack"); @@ -6288,7 +6288,7 @@ static bool handle_backwards_disasm(RCore *core, int *nb_opcodes, int *nb_bytes) if (core->blocksize == *nb_bytes) { r_io_read_at (core->io, core->offset, core->block, *nb_bytes); } else { - eprintf ("Cannot read that much!\n"); + R_LOG_ERROR ("Cannot read that much!"); r_core_block_size (core, obsz); return false; } diff --git a/libr/core/linux_heap_glibc.c b/libr/core/linux_heap_glibc.c index af11c6c4d9..2c4e93df07 100644 --- a/libr/core/linux_heap_glibc.c +++ b/libr/core/linux_heap_glibc.c @@ -1138,7 +1138,7 @@ static void GH(print_heap_segment)(RCore *core, MallocState *main_arena, top_title = r_str_new (""); if (!r_io_read_at (core->io, next_chunk, (ut8 *)cnk, sizeof (GH(RHeapChunk)))) { - eprintf ("Cannot read\n"); + R_LOG_ERROR ("Cannot read"); free (cnk); free (cnk_next); r_cons_canvas_free (can); diff --git a/libr/core/linux_heap_jemalloc.c b/libr/core/linux_heap_jemalloc.c index 499b47afd2..9427455ae1 100644 --- a/libr/core/linux_heap_jemalloc.c +++ b/libr/core/linux_heap_jemalloc.c @@ -272,13 +272,13 @@ static void GH(jemalloc_print_narenas)(RCore *core, const char *input) { PRINTF_GA ("narenas : %"PFMT64d"\n", (ut64)narenas); } if (narenas == 0) { - eprintf ("No arenas allocated.\n"); + R_LOG_ERROR ("No arenas allocated"); free (stats); free (ar); return; } if (narenas == GHT_MAX) { - eprintf ("Cannot find narenas_total\n"); + R_LOG_ERROR ("Cannot find narenas_total"); free (stats); free (ar); return; diff --git a/libr/core/panels.c b/libr/core/panels.c index a01f32031a..37bc592184 100644 --- a/libr/core/panels.c +++ b/libr/core/panels.c @@ -2366,7 +2366,7 @@ static void __init_all_dbs(RCore *core) { static RConsCanvas *__create_new_canvas(RCore *core, int w, int h) { RConsCanvas *can = r_cons_canvas_new (w, h); if (!can) { - eprintf ("Cannot create RCons.canvas context\n"); + R_LOG_ERROR ("Cannot create RCons.canvas context"); return false; } r_cons_canvas_fill (can, 0, 0, w, h, ' '); diff --git a/libr/core/rtr.c b/libr/core/rtr.c index 2cfefcc476..e7cc5a73cd 100644 --- a/libr/core/rtr.c +++ b/libr/core/rtr.c @@ -587,23 +587,23 @@ static int r_core_rtr_gdb_run(RCore *core, int launch, const char *path) { } if (!r_core_file_open (core, file, R_PERM_RX, 0)) { - eprintf ("Cannot open file (%s)\n", file); + R_LOG_ERROR ("Cannot open file (%s)", file); return -1; } r_core_file_reopen_debug (core, args); if (!(sock = r_socket_new (false))) { - eprintf ("gdbserver: Could not open socket for listening\n"); + R_LOG_ERROR ("gdbserver: Could not open socket for listening"); return -1; } if (!r_socket_listen (sock, port, NULL)) { r_socket_free (sock); - eprintf ("gdbserver: Cannot listen on port: %s\n", port); + R_LOG_ERROR ("gdbserver: Cannot listen on port: %s", port); return -1; } if (!(g = R_NEW0 (libgdbr_t))) { r_socket_free (sock); - eprintf ("gdbserver: Cannot alloc libgdbr instance\n"); + R_LOG_ERROR ("gdbserver: Cannot alloc libgdbr instance"); return -1; } gdbr_init (g, true); @@ -612,7 +612,7 @@ static int r_core_rtr_gdb_run(RCore *core, int launch, const char *path) { int bits = r_config_get_i (core->config, "asm.bits"); gdbr_set_architecture (g, arch, bits); core->gdbserver_up = 1; - eprintf ("gdbserver started on port: %s, file: %s\n", port, file); + R_LOG_INFO ("gdbserver started on port: %s, file: %s", port, file); for (;;) { if (!(g->sock = r_socket_accept (sock))) { @@ -796,7 +796,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { char *uri = r_str_newf ("http://%s:%s/%s", host, port, file); char *str = r_socket_http_get (uri, NULL, &len); if (!str) { - eprintf ("Cannot find peer\n"); + R_LOG_ERROR ("Cannot find peer"); r_socket_free (fd); return; } @@ -921,7 +921,7 @@ R_API void r_core_rtr_event(RCore *core, const char *input) { dup2 (ff, 2); errmsg_fd = ff; } else { - eprintf ("Cannot open fifo: %s\n", f); + R_LOG_ERROR ("Cannot open fifo: %s", f); } } // r_core_event (core, ); @@ -929,7 +929,7 @@ R_API void r_core_rtr_event(RCore *core, const char *input) { free (f); // TODO: those files are leaked when closing r_core_free() should be deleted #else - eprintf ("Not supported for your platform.\n"); + R_LOG_ERROR ("Not supported for your platform"); #endif } else { eprintf ("(%s)\n", input); @@ -1069,7 +1069,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) { char *uri = r_str_newf ("http://%s:%d/cmd/%s", rh->host, rh->port, cmd); char *str = r_socket_http_get (uri, NULL, &len); if (!str) { - eprintf ("Cannot find '%s'\n", uri); + R_LOG_ERROR ("Cannot find '%s'", uri); return; } r_core_return_value (core, R_CMD_RC_SUCCESS); @@ -1124,7 +1124,7 @@ R_API char *r_core_rtr_cmds_query(RCore *core, const char *host, const char *por rbuf = r_str_append (rbuf, (const char *)buf); } } else { - eprintf ("Cannot connect\n"); + R_LOG_ERROR ("Cannot connect"); } r_socket_free (s); return rbuf; diff --git a/libr/core/visual.c b/libr/core/visual.c index 663a7673fb..913d34872c 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -1116,7 +1116,7 @@ static void visual_search(RCore *core) { eprintf ("Found in offset 0x%08"PFMT64x" + %d\n", core->offset, core->print->cur); r_cons_any_key (NULL); } else { - eprintf ("Cannot find bytes.\n"); + R_LOG_ERROR ("Cannot find bytes"); r_cons_any_key (NULL); r_cons_clear00 (); } @@ -3666,7 +3666,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { r_core_visual_seek_animation (core, undo->off); core->print->cur = undo->cursor; } else { - eprintf ("Cannot undo\n"); + R_LOG_ERROR ("Cannot undo"); } } break; @@ -4396,7 +4396,7 @@ R_API int r_core_visual(RCore *core, const char *input) { splitPtr = UT64_MAX; if (r_cons_get_size (&ch) < 1 || ch < 1) { - eprintf ("Cannot create Visual context. Use scr.fix_{columns|rows}\n"); + R_LOG_ERROR ("Cannot create Visual context. Use scr.fix_{columns|rows}"); return 0; } diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 25d5f66a5e..e4f71d9619 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -4378,7 +4378,7 @@ onemoretime: free (newname); } } else { - eprintf ("Cannot find instruction with a variable\n"); + R_LOG_ERROR ("Cannot find instruction with a variable"); r_cons_any_key (NULL); } diff --git a/libr/core/vslides.c b/libr/core/vslides.c index d7fca34cdd..e20db39fd1 100644 --- a/libr/core/vslides.c +++ b/libr/core/vslides.c @@ -90,7 +90,7 @@ R_API void r_core_visual_slides(RCore *core, const char *file) { } char *data = r_file_slurp (file, NULL); if (!data) { - eprintf ("Cannot open file.\n"); + R_LOG_ERROR ("Cannot open file"); return; } RList *list = r_str_split_list (data, "\n", 0); diff --git a/libr/debug/debug.c b/libr/debug/debug.c index d866e8f82a..734f93967a 100644 --- a/libr/debug/debug.c +++ b/libr/debug/debug.c @@ -124,7 +124,7 @@ static int r_debug_bp_hit(RDebug *dbg, RRegItem *pc_ri, ut64 pc, RBreakpointItem } if (!dbg->pc_at_bp_set) { - eprintf ("failed to determine position of pc after breakpoint\n"); + R_LOG_ERROR ("failed to determine position of pc after breakpoint"); } if (dbg->pc_at_bp) { @@ -535,12 +535,12 @@ R_API bool r_debug_execute(RDebug *dbg, const ut8 *buf, int len, R_OUT ut64 *ret ri_sp = r_reg_get (dbg->reg, dbg->reg->name[R_REG_NAME_SP], R_REG_TYPE_GPR); if (!ri_pc) { - eprintf ("r_debug_execute: Cannot get program counter\n"); + R_LOG_ERROR ("r_debug_execute: Cannot get program counter"); return false; } if (restore && !ignore_stack && !ri_sp) { - eprintf ("r_debug_execute: Cannot get stack pointer\n"); + R_LOG_ERROR ("r_debug_execute: Cannot get stack pointer"); return false; } @@ -548,7 +548,7 @@ R_API bool r_debug_execute(RDebug *dbg, const ut8 *buf, int len, R_OUT ut64 *ret reg_backup = r_reg_get_bytes (dbg->reg, R_REG_TYPE_ALL, ®_backup_sz); if (!reg_backup) { - eprintf ("Cannot get register arena bytes\n"); + R_LOG_ERROR ("Cannot get register arena bytes"); return false; } @@ -643,7 +643,7 @@ R_API bool r_debug_select(RDebug *dbg, int pid, int tid) { #endif if (pid == -1 && tid == -1) { if (dbg->pid != -1) { - eprintf ("Child %d is dead\n", dbg->pid); + R_LOG_ERROR ("Child %d is dead", dbg->pid); } } if (pid < 0 || tid < 0) { @@ -663,7 +663,7 @@ R_API bool r_debug_select(RDebug *dbg, int pid, int tid) { free (pidcmd); } } else { - eprintf ("Cannot find pid for child %d\n", dbg->pid); + R_LOG_ERROR ("Cannot find pid for child %d", dbg->pid); } // Synchronize with the current thread's data @@ -1021,7 +1021,7 @@ R_API int r_debug_step(RDebug *dbg, int steps) { dbg->session->maxcnum++; dbg->session->bp = 0; if (!r_debug_trace_ins_before (dbg)) { - eprintf ("trace_ins_before: failed\n"); + R_LOG_ERROR ("trace_ins_before: failed"); } } @@ -1031,13 +1031,13 @@ R_API int r_debug_step(RDebug *dbg, int steps) { ret = r_debug_step_hard (dbg, &bp); } if (!ret) { - eprintf ("Stepping failed!\n"); + R_LOG_ERROR ("Stepping failed!"); return steps_taken; } if (dbg->session && dbg->recoil_mode == R_DBG_RECOIL_NONE) { if (!r_debug_trace_ins_after (dbg)) { - eprintf ("trace_ins_after: failed\n"); + R_LOG_ERROR ("trace_ins_after: failed"); } dbg->session->reasontype = dbg->reason.type; dbg->session->bp = bp; @@ -1125,7 +1125,7 @@ R_API int r_debug_step_over(RDebug *dbg, int steps) { return steps_taken; } } else if ((op.prefix & (R_ANAL_OP_PREFIX_REP | R_ANAL_OP_PREFIX_REPNE | R_ANAL_OP_PREFIX_LOCK))) { - //eprintf ("REP: skip to next instruction...\n"); + //R_LOG_ERROR ("REP: skip to next instruction"); if (!r_debug_continue_until (dbg, ins_size)) { R_LOG_ERROR ("step over failed over rep"); return steps_taken; diff --git a/libr/debug/p/debug_native.c b/libr/debug/p/debug_native.c index db2ed4ea7e..8951cefdd7 100644 --- a/libr/debug/p/debug_native.c +++ b/libr/debug/p/debug_native.c @@ -537,18 +537,18 @@ static RDebugReasonType r_debug_native_wait(RDebug *dbg, int pid) { #endif } else if (status == 1) { /* XXX(jjd): does this actually happen? */ - eprintf ("EEK DEAD DEBUGEE!\n"); + R_LOG_ERROR ("EEK DEAD DEBUGEE!"); reason = R_DEBUG_REASON_DEAD; } else if (status == 0) { /* XXX(jjd): does this actually happen? */ - eprintf ("STATUS=0?!?!?!?\n"); + R_LOG_ERROR ("STATUS=0?!?!?!?"); reason = R_DEBUG_REASON_DEAD; } else { if (ret != pid) { reason = R_DEBUG_REASON_NEW_PID; } else { /* ugh. still don't know :-/ */ - eprintf ("CRAP. returning from wait without knowing why...\n"); + R_LOG_ERROR ("CRAP. returning from wait without knowing why"); } } } @@ -800,7 +800,7 @@ static bool linux_map_thp(RDebug *dbg, ut64 addr, int size) { const size_t thpsize = 1<<21; if (size % thpsize) { - eprintf ("size not a power of huge pages size\n"); + R_LOG_ERROR ("size not a power of huge pages size"); return false; } #if __linux__ @@ -808,7 +808,7 @@ static bool linux_map_thp(RDebug *dbg, ut64 addr, int size) { // even though the address might not have the 'hg' // vmflags if (thp_mode () != 1) { - eprintf ("transparent huge page mode is not in madvise mode\n"); + R_LOG_ERROR ("transparent huge page mode is not in madvise mode"); return false; } #endif @@ -823,11 +823,11 @@ static bool linux_map_thp(RDebug *dbg, ut64 addr, int size) { r_egg_setup (dbg->egg, dbg->arch, 8 * dbg->bits, 0, 0); r_egg_load (dbg->egg, code, 0); if (!r_egg_compile (dbg->egg)) { - eprintf ("Cannot compile.\n"); + R_LOG_ERROR ("Cannot compile"); goto err_linux_map_thp; } if (!r_egg_assemble_asm (dbg->egg, asm_list)) { - eprintf ("r_egg_assemble: invalid assembly\n"); + R_LOG_ERROR ("r_egg_assemble: invalid assembly"); goto err_linux_map_thp; } buf = r_egg_get_bin (dbg->egg); @@ -880,11 +880,11 @@ static RDebugMap* linux_map_alloc(RDebug *dbg, ut64 addr, int size, bool thp) { r_egg_setup (dbg->egg, dbg->arch, 8 * dbg->bits, 0, 0); r_egg_load (dbg->egg, code, 0); if (!r_egg_compile (dbg->egg)) { - eprintf ("Cannot compile.\n"); + R_LOG_ERROR ("Cannot compile"); goto err_linux_map_alloc; } if (!r_egg_assemble_asm (dbg->egg, asm_list)) { - eprintf ("r_egg_assemble: invalid assembly\n"); + R_LOG_ERROR ("r_egg_assemble: invalid assembly"); goto err_linux_map_alloc; } buf = r_egg_get_bin (dbg->egg); @@ -902,8 +902,7 @@ static RDebugMap* linux_map_alloc(RDebug *dbg, ut64 addr, int size, bool thp) { if (map_addr < UT64_MAX) { if (thp) { if (!linux_map_thp (dbg, map_addr, size)) { - // Not overly dramatic - eprintf ("map promotion to huge page failed\n"); + R_LOG_WARN ("map promotion to huge page failed"); } } r_debug_map_sync (dbg); @@ -934,11 +933,11 @@ static int linux_map_dealloc(RDebug *dbg, ut64 addr, int size) { r_egg_setup (dbg->egg, dbg->arch, 8 * dbg->bits, 0, 0); r_egg_load (dbg->egg, code, 0); if (!r_egg_compile (dbg->egg)) { - eprintf ("Cannot compile.\n"); + R_LOG_ERROR ("Cannot compile"); goto err_linux_map_dealloc; } if (!r_egg_assemble_asm (dbg->egg, asm_list)) { - eprintf ("r_egg_assemble: invalid assembly\n"); + R_LOG_ERROR ("r_egg_assemble: invalid assembly"); goto err_linux_map_dealloc; } buf = r_egg_get_bin (dbg->egg); @@ -1552,11 +1551,11 @@ static int r_debug_native_map_protect(RDebug *dbg, ut64 addr, int size, int perm r_egg_setup(dbg->egg, dbg->arch, 8 * dbg->bits, 0, 0); r_egg_load (dbg->egg, code, 0); if (!r_egg_compile (dbg->egg)) { - eprintf ("Cannot compile.\n"); + R_LOG_ERROR ("Cannot compile"); return false; } if (!r_egg_assemble (dbg->egg)) { - eprintf ("r_egg_assemble: invalid assembly\n"); + R_LOG_ERROR ("r_egg_assemble: invalid assembly"); return false; } buf = r_egg_get_bin (dbg->egg); diff --git a/libr/debug/p/native/bt/fuzzy_all.c b/libr/debug/p/native/bt/fuzzy_all.c index 1fabec27da..6ae4f19af8 100644 --- a/libr/debug/p/native/bt/fuzzy_all.c +++ b/libr/debug/p/native/bt/fuzzy_all.c @@ -57,13 +57,13 @@ static RList *backtrace_fuzzy(RDebug *dbg, ut64 at) { RReg *reg = dbg->reg; const char *spname = r_reg_get_name (reg, R_REG_NAME_SP); if (!spname) { - eprintf ("Cannot find stack pointer register\n"); + R_LOG_ERROR ("Cannot find stack pointer register"); free (stack); return NULL; } ri = r_reg_get (reg, spname, R_REG_TYPE_GPR); if (!ri) { - eprintf ("Cannot find stack pointer register\n"); + R_LOG_ERROR ("Cannot find stack pointer register"); free (stack); return NULL; } @@ -86,7 +86,7 @@ static RList *backtrace_fuzzy(RDebug *dbg, ut64 at) { case 4: addr = *p32; break; case 2: addr = *p16; break; default: - eprintf ("Invalid word size with asm.bits\n"); + R_LOG_ERROR ("Invalid word size with asm.bits"); r_list_free (list); free (stack); return NULL; @@ -97,7 +97,7 @@ static RList *backtrace_fuzzy(RDebug *dbg, ut64 at) { frame->size = cursp - oldsp; frame->sp = cursp; frame->bp = oldsp; //addr + (i * wordsize); // -4 || -8 - // eprintf ("--------------> 0x%llx (%d)\n", addr, frame->size); + // R_LOG_DEBUG ("--------------> 0x%llx (%d)", addr, frame->size); r_list_append (list, frame); oldsp = cursp; } diff --git a/libr/debug/p/native/maps/darwin.c b/libr/debug/p/native/maps/darwin.c index a52e9a6c1e..d7a1aa3d45 100644 --- a/libr/debug/p/native/maps/darwin.c +++ b/libr/debug/p/native/maps/darwin.c @@ -90,7 +90,7 @@ static RList *ios_dbg_maps(RDebug *dbg) { #if 0 if (dbg->pid == 0) { vm_address_t base = get_kernel_base (task); - eprintf ("Kernel Base Address: 0x%"PFMT64x"\n", (ut64)base); + R_LOG_INFO ("Kernel Base Address: 0x%"PFMT64x, (ut64)base); return NULL; } #endif @@ -106,7 +106,7 @@ static RList *ios_dbg_maps(RDebug *dbg) { kr = mach_vm_region_recurse (task, &address, &size, &depth, (vm_region_recurse_info_t) &info, &info_count); if (kr != KERN_SUCCESS) { - //eprintf ("Cannot kern succ recurse\n"); + //R_LOG_ERROR ("Cannot kern succ recurse"); break; } if (!list) { @@ -154,7 +154,7 @@ static RList *ios_dbg_maps(RDebug *dbg) { mr = r_debug_map_new (buf, address, address+size, xwr2rwx (info.protection), 0); if (!mr) { - eprintf ("Cannot create r_debug_map_new\n"); + R_LOG_ERROR ("Cannot create r_debug_map_new"); break; } mr->file = strdup (module_name); @@ -259,7 +259,7 @@ static RList *osx_dbg_maps(RDebug *dbg) { mr = r_debug_map_new (buf, prev_address, prev_address+prev_size, xwr2rwx (prev_info.protection), 0); if (!mr) { - eprintf ("Cannot create r_debug_map_new\n"); + R_LOG_ERROR ("Cannot create r_debug_map_new"); break; } mr->file = strdup (module_name); diff --git a/libr/debug/p/native/xnu/xnu_debug.c b/libr/debug/p/native/xnu/xnu_debug.c index 46e1733229..ab5fa31fd4 100644 --- a/libr/debug/p/native/xnu/xnu_debug.c +++ b/libr/debug/p/native/xnu/xnu_debug.c @@ -1277,7 +1277,7 @@ static RList *xnu_dbg_modules(RDebug *dbg) { size = mach0_size (dbg, addr); mr = r_debug_map_new (file_path, addr, addr + size, 7, 7); if (!mr) { - eprintf ("Cannot create r_debug_map_new\n"); + R_LOG_ERROR ("Cannot create r_debug_map_new"); break; } mr->file = strdup (file_path); @@ -1406,7 +1406,7 @@ RList *xnu_dbg_maps(RDebug *dbg, int only_modules) { "", info.is_submap ? "_submap": "", module_name, maxperm, depthstr); if (!(mr = r_debug_map_new (buf, address, address + size, xwr2rwx (info.protection), xwr2rwx (info.max_protection)))) { - eprintf ("Cannot create r_debug_map_new\n"); + R_LOG_ERROR ("Cannot create r_debug_map_new"); break; } RDebugMap *rdm = moduleAt (modules, address); diff --git a/libr/egg/egg_cfile.c b/libr/egg/egg_cfile.c index a0f415ce67..9e7397433a 100644 --- a/libr/egg/egg_cfile.c +++ b/libr/egg/egg_cfile.c @@ -84,8 +84,8 @@ static struct cEnv_t* r_egg_cfile_set_cEnv(const char *arch, const char *os, int if (!cEnv->SFLIBPATH) { output = r_sys_cmd_strf ("r2 -hh | grep INCDIR | awk '{print $2}'"); if (!output || (output[0] == '\0')) { - eprintf ("Cannot find SFLIBPATH env var.\n" - "Please define it, or fix r2 installation.\n"); + R_LOG_ERROR ("Cannot find SFLIBPATH env var"); + eprintf ("Please define $SFLIBPATH, or fix r2 installation\n"); goto fail; } @@ -292,7 +292,7 @@ R_API char* r_egg_cfile_parser(const char *file, const char *arch, const char *o printf ("rabin2 -o '%s.text' -O d/S/'%s' '%s.o'\n", file, cEnv->TEXT, file); output = r_sys_cmd_strf ("rabin2 -o '%s.text' -O d/S/'%s' '%s'.o", file, cEnv->TEXT, file); if (!output) { - eprintf ("Linkage failed!\n"); + R_LOG_ERROR ("Linkage failed!"); goto fail; } @@ -302,7 +302,7 @@ R_API char* r_egg_cfile_parser(const char *file, const char *arch, const char *o } if (!r_file_exists (fileExt)) { - eprintf ("Cannot find %s.o\n", file); + R_LOG_ERROR ("Cannot find %s.o", file); goto fail; } diff --git a/libr/egg/egg_lang.c b/libr/egg/egg_lang.c index 6a945b8e7c..2b4ae2c35c 100644 --- a/libr/egg/egg_lang.c +++ b/libr/egg/egg_lang.c @@ -961,7 +961,7 @@ static void rcc_next(REgg *egg) { egg->lang.elem[egg->lang.elem_n - 1] = 0; path = find_include (egg->lang.includedir, egg->lang.includefile); if (!path) { - eprintf ("Cannot find include file '%s'\n", egg->lang.elem); + R_LOG_ERROR ("Cannot find include file '%s'", egg->lang.elem); return; } R_FREE (egg->lang.includefile); @@ -979,7 +979,7 @@ static void rcc_next(REgg *egg) { free (q); egg->lang.line = oline; } else { - eprintf ("Cannot find '%s'\n", path); + R_LOG_ERROR ("Cannot find '%s'", path); } free (path); return; @@ -988,7 +988,7 @@ static void rcc_next(REgg *egg) { if (egg->lang.callname) { if (!strcmp (egg->lang.callname, "goto")) { if (egg->lang.nargs != 1) { - eprintf ("Invalid number of arguments for goto()\n"); + R_LOG_ERROR ("Invalid number of arguments for goto()"); return; } e->jmp (egg, egg->lang.ctxpush[CTX], 0); @@ -1011,7 +1011,7 @@ static void rcc_next(REgg *egg) { } str = r_egg_mkvar (egg, buf, ocn, 0); if (!str) { - eprintf ("Cannot mkvar\n"); + R_LOG_ERROR ("Cannot mkvar"); return; } if (*ocn == '.') { @@ -1065,7 +1065,7 @@ static void rcc_next(REgg *egg) { } free (s); } else { - eprintf ("Cannot get @syscall payload\n"); + R_LOG_ERROR ("Cannot get @syscall payload"); } } egg->lang.docall = 0; @@ -1119,7 +1119,7 @@ static void rcc_next(REgg *egg) { free (str); str = r_egg_mkvar (egg, buf, egg->lang.dstvar, 0); if (*buf == 0) { - eprintf ("Cannot resolve variable '%s'\n", egg->lang.dstvar); + R_LOG_ERROR ("Cannot resolve variable '%s'", egg->lang.dstvar); } else { e->get_result (egg, buf); } diff --git a/libr/egg/emit_x86.c b/libr/egg/emit_x86.c index 41ace1a6a2..7929017193 100644 --- a/libr/egg/emit_x86.c +++ b/libr/egg/emit_x86.c @@ -135,7 +135,7 @@ static void emit_syscall_args(REgg *egg, int nargs) { k = j * R_SZ; const char *reg = getreg (j + 1); if (!reg) { - eprintf ("Cannot find gpr %d\n", j + 1); + R_LOG_ERROR ("Cannot find gpr %d", j + 1); break; } if (attsyntax) { diff --git a/libr/egg/p/egg_bind.c b/libr/egg/p/egg_bind.c index 121f6e82ff..a226141413 100644 --- a/libr/egg/p/egg_bind.c +++ b/libr/egg/p/egg_bind.c @@ -165,14 +165,14 @@ static RBuffer *build(REgg *egg) { } break; case R_EGG_OS_LINUX: - if (suid) eprintf ("no suid for this platform\n"); + if (suid) R_LOG_WARN ("no suid for this platform"); suid = 0; switch (egg->arch) { case R_SYS_ARCH_X86: switch (egg->bits) { case 32: sc = x86_linux_binsh; break; case 64: sc = x86_64_linux_binsh; break; - default: eprintf ("Unsupportted\n"); + default: R_LOG_ERROR ("Unsupported"); } break; case R_SYS_ARCH_ARM: @@ -181,14 +181,17 @@ static RBuffer *build(REgg *egg) { } break; default: - eprintf ("unsupported os %x\n", egg->os); + R_LOG_ERROR ("unsupported os %x", egg->os); break; } if (sc) { r_buf_set_bytes (buf, sc, strlen ((const char *)sc)); if (shell && *shell) { - if (cd) r_buf_write_at (buf, cd, (const ut8*)shell, strlen (shell)+1); - else eprintf ("Cannot set shell\n"); + if (cd) { + r_buf_write_at (buf, cd, (const ut8*)shell, strlen (shell)+1); + } else { + R_LOG_ERROR ("Cannot set shell"); + } } } free (suid); diff --git a/libr/egg/p/egg_exec.c b/libr/egg/p/egg_exec.c index 9d435ea6ef..52eecc72a1 100644 --- a/libr/egg/p/egg_exec.c +++ b/libr/egg/p/egg_exec.c @@ -85,7 +85,7 @@ static RBuffer *build(REgg *egg) { break; case R_EGG_OS_LINUX: if (suid) { - eprintf ("no suid for this platform\n"); + R_LOG_WARN ("no suid for this platform"); } suid = 0; switch (egg->arch) { @@ -100,7 +100,7 @@ static RBuffer *build(REgg *egg) { int len = strlen (shell); if (len > sizeof (st64) - 1) { *shell = 0; - eprintf ("Unsupported CMD length\n"); + R_LOG_ERROR ("Unsupported CMD length"); break; } st64 b = 0; @@ -119,7 +119,7 @@ static RBuffer *build(REgg *egg) { } break; default: - eprintf ("Unsupported arch %d bits\n", egg->bits); + R_LOG_ERROR ("Unsupported arch %d bits", egg->bits); } break; case R_SYS_ARCH_ARM: @@ -131,13 +131,13 @@ static RBuffer *build(REgg *egg) { sc = arm_linux_binsh; break; default: - eprintf ("Unsupported arch %d bits\n", egg->bits); + R_LOG_ERROR ("Unsupported arch %d bits", egg->bits); } break; } break; default: - eprintf ("Unsupported os %x\n", egg->os); + R_LOG_ERROR ("Unsupported os %x", egg->os); break; } @@ -147,7 +147,7 @@ static RBuffer *build(REgg *egg) { if (cd) { r_buf_write_at (buf, cd, (const ut8 *)shell, strlen (shell) + 1); } else { - eprintf ("Cannot set shell\n"); + R_LOG_ERROR ("Cannot set shell"); } } } diff --git a/libr/egg/p/egg_reverse.c b/libr/egg/p/egg_reverse.c index 0c6b4748c6..21048e39f2 100644 --- a/libr/egg/p/egg_reverse.c +++ b/libr/egg/p/egg_reverse.c @@ -48,20 +48,23 @@ static RBuffer *build(REgg *egg) { case R_SYS_ARCH_X86: switch (egg->bits) { case 32: sc = x86_freebsd_reverse; break; - default: eprintf ("Unsupportted\n"); + default: R_LOG_ERROR ("Unsupported"); } break; } break; default: - eprintf ("unsupported os %x\n", egg->os); + R_LOG_ERROR ("unsupported os %x", egg->os); break; } if (sc) { r_buf_set_bytes (buf, sc, strlen ((const char *)sc)); if (shell && *shell) { - if (cd) r_buf_write_at (buf, cd, (const ut8*)shell, strlen (shell)+1); - else eprintf ("Cannot set shell\n"); + if (cd) { + r_buf_write_at (buf, cd, (const ut8*)shell, strlen (shell)+1); + } else { + R_LOG_ERROR ("Cannot set shell"); + } } } free (suid); diff --git a/libr/io/p/io_ihex.c b/libr/io/p/io_ihex.c index dbb692ea97..698c1137f7 100644 --- a/libr/io/p/io_ihex.c +++ b/libr/io/p/io_ihex.c @@ -50,12 +50,12 @@ static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) { pathname = fd->name + 7; out = r_sandbox_fopen (pathname, "w"); if (!out) { - eprintf ("Cannot open '%s' for writing\n", pathname); + R_LOG_ERROR ("Cannot open '%s' for writing", pathname); return -1; } /* mem write */ if (r_buf_write_at (rih->rbuf, io->off, buf, count) != count) { - eprintf ("ihex:write(): sparse write failed\n"); + R_LOG_ERROR ("ihex:write(): sparse write failed"); fclose (out); return -1; } @@ -277,11 +277,11 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { ut32 tmp = 0; r_buf_read_at (rbuf, at, (ut8*)&tmp, 4); if (tmp && tmp != UT32_MAX) { - eprintf ("Cannot write%c", 10); + R_LOG_ERROR ("Cannot write"); return true; } if (r_buf_write_at (rbuf, at, sec_tmp, sec_size) != sec_size) { - eprintf ("sparse buffer problem, giving up\n"); + R_LOG_ERROR ("sparse buffer problem, giving up"); goto fail; } //} @@ -296,13 +296,13 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { if (eol) { // checksum if (sscanf (str + 9 + (i * 2), "%02x", &byte) !=1) { - eprintf("unparsable data !\n"); + R_LOG_ERROR("unparsable data!"); goto fail; } cksum += byte; if (cksum != 0) { ut8 fixedcksum = 0-(cksum-byte); - eprintf ("Checksum failed %02x (got %02x expected %02x)\n", + R_LOG_ERROR ("Checksum failed %02x (got %02x expected %02x)", cksum, byte, fixedcksum); goto fail; } @@ -313,7 +313,7 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { case 1: // EOF. we don't validate checksum here if (at && sec_size) { if (r_buf_write_at (rbuf, at, sec_tmp, sec_size) != sec_size) { - eprintf ("sparse buffer problem, giving up. ssiz=%X, sstart=%X\n", sec_size, sec_start); + R_LOG_ERROR ("sparse buffer problem, giving up. ssiz=%X, sstart=%X", sec_size, sec_start); goto fail; } } @@ -334,12 +334,12 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { cksum += addr_tmp; cksum += type; if ((bc != 2) || (addr_tmp != 0)) { - eprintf ("invalid type 02/04 record!\n"); + R_LOG_ERROR ("invalid type 02/04 record!"); goto fail; } if ((sscanf (str + 9 + 0, "%02x", &extH) !=1) || (sscanf (str + 9 + 2, "%02x", &extL) !=1)) { - eprintf ("unparsable data !\n"); + R_LOG_ERROR ("unparsable data!"); goto fail; } extH &= 0xff; @@ -362,7 +362,7 @@ static bool ihex_parse(RBuffer *rbuf, char *str) { cksum += byte; if (cksum != 0) { ut8 fixedcksum = 0-(cksum-byte); - eprintf ("Checksum failed %02x (got %02x expected %02x)\n", + R_LOG_ERROR ("Checksum failed %02x (got %02x expected %02x)", cksum, byte, fixedcksum); goto fail; } @@ -404,7 +404,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { return NULL; } if (!ihex_parse (mal->rbuf, str)) { - eprintf ("ihex: failed to parse file\n"); + R_LOG_ERROR ("ihex: failed to parse file"); free (str); r_buf_free (mal->rbuf); free (mal); diff --git a/libr/io/p/io_rap.c b/libr/io/p/io_rap.c index bc31722a19..adbf9964d8 100644 --- a/libr/io/p/io_rap.c +++ b/libr/io/p/io_rap.c @@ -123,16 +123,16 @@ static RIODesc *__rap_open(RIO *io, const char *pathname, int rw, int mode) { } RSocket *s = r_socket_new (is_ssl); if (!s) { - eprintf ("Cannot create new socket\n"); + R_LOG_ERROR ("Cannot create new socket"); return NULL; } - eprintf ("Connecting to %s, port %s\n", host, port); + R_LOG_INFO ("Connecting to %s, port %s", host, port); if (!r_socket_connect (s, host, port, R_SOCKET_PROTO_TCP, 0)) { - eprintf ("Cannot connect to '%s' (%d)\n", host, p); + R_LOG_ERROR ("Cannot connect to '%s' (%d)", host, p); r_socket_free (s); return NULL; } - eprintf ("Connected to: %s at port %s\n", host, port); + R_LOG_INFO ("Connected to: %s at port %s", host, port); RIORap *rior = R_NEW0 (RIORap); if (!rior) { r_socket_free (s); diff --git a/libr/io/p/io_shm.c b/libr/io/p/io_shm.c index 4575e7e7af..50aebc3305 100644 --- a/libr/io/p/io_shm.c +++ b/libr/io/p/io_shm.c @@ -120,10 +120,10 @@ static RIODesc *shm__open(RIO *io, const char *pathname, int rw, int mode) { } shm->size = SHMATSZ; if (shm->fd != -1) { - eprintf ("Connected to shared memory 0x%08x\n", shm->id); + R_LOG_INFO ("Connected to shared memory 0x%08x", shm->id); return r_io_desc_new (io, &r_io_plugin_shm, pathname, rw, mode, shm); } - eprintf ("Cannot connect to shared memory (%d)\n", shm->id); + R_LOG_ERROR ("Cannot connect to shared memory (%d)", shm->id); free (shm); } return NULL; diff --git a/libr/io/p/io_socket.c b/libr/io/p/io_socket.c index 2dc7b4d3e0..fd4db577cf 100644 --- a/libr/io/p/io_socket.c +++ b/libr/io/p/io_socket.c @@ -127,7 +127,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { /* listen and wait for connection */ data->sc = r_socket_new (false); if (!r_socket_connect (data->sc, host, port, R_SOCKET_PROTO_TCP, 0)) { - eprintf ("Cannot connect\n"); + R_LOG_ERROR ("Cannot connect"); free (host); free_socketdata (data); return NULL; diff --git a/libr/io/p/io_tcpslurp.c b/libr/io/p/io_tcpslurp.c index 569db3e884..55cd39a6a5 100644 --- a/libr/io/p/io_tcpslurp.c +++ b/libr/io/p/io_tcpslurp.c @@ -20,7 +20,7 @@ static ut8 *tcpme(const char *pathname, int *code, int *len) { /* listen and wait for connection */ RSocket *sl = r_socket_new (false); if (!r_socket_listen (sl, pathname + 1, NULL)) { - eprintf ("Cannot listen\n"); + R_LOG_ERROR ("Cannot listen"); r_socket_free (sl); return NULL; } diff --git a/libr/io/p/io_w32dbg.c b/libr/io/p/io_w32dbg.c index 2a034cc836..941f9dd4b7 100644 --- a/libr/io/p/io_w32dbg.c +++ b/libr/io/p/io_w32dbg.c @@ -240,7 +240,7 @@ static char *__system(RIO *io, RIODesc *fd, const char *cmd) { if (ht) { wrap->pi.hThread = ht; } else { - eprintf ("Cannot attach to %d (%s)\n", pid, cmd); + R_LOG_ERROR ("Cannot attach to %d (%s)", pid, cmd); } } } diff --git a/libr/lang/p/c.c b/libr/lang/p/c.c index bfeca319a1..4ebb26488f 100644 --- a/libr/lang/p/c.c +++ b/libr/lang/p/c.c @@ -30,7 +30,7 @@ static int lang_c_file(RLang *lang, const char *file) { strcpy (name, file); } if (!r_file_exists (name)) { - eprintf ("file not found (%s)\n", name); + R_LOG_ERROR ("file not found (%s)", name); return false; } @@ -76,11 +76,11 @@ static int lang_c_file(RLang *lang, const char *file) { ac = 0; av = NULL; } else { - eprintf ("Cannot find 'entry' symbol in library\n"); + R_LOG_ERROR ("Cannot find 'entry' symbol in library"); } r_lib_dl_close (lib); } else { - eprintf ("Cannot open library\n"); + R_LOG_ERROR ("Cannot open library"); } r_file_rm (buf); // remove lib free (buf); @@ -95,7 +95,7 @@ static int lang_c_init(void *user) { static bool lang_c_run(RLang *lang, const char *code, int len) { FILE *fd = r_sandbox_fopen (".tmp.c", "w"); if (!fd) { - eprintf ("Cannot open .tmp.c\n"); + R_LOG_ERROR ("Cannot open .tmp.c"); return false; } fputs ("#include \n\nvoid entry(RCore *core, int argc, const char **argv) {\n", fd); diff --git a/libr/lang/p/cpipe.c b/libr/lang/p/cpipe.c index b56222e05f..ac0c4922e4 100644 --- a/libr/lang/p/cpipe.c +++ b/libr/lang/p/cpipe.c @@ -74,7 +74,7 @@ static int lang_cpipe_init(void *user) { static bool lang_cpipe_run(RLang *lang, const char *code, int len) { FILE *fd = r_sandbox_fopen (".tmp.c", "w"); if (!fd) { - eprintf ("Cannot open .tmp.c\n"); + R_LOG_ERROR ("Cannot open .tmp.c"); return false; } fputs ("#include \n\n" diff --git a/libr/lang/p/go.c b/libr/lang/p/go.c index a5cda83d98..a7f41fb427 100644 --- a/libr/lang/p/go.c +++ b/libr/lang/p/go.c @@ -77,14 +77,14 @@ static void gorunlib(void *user, const char *lib) { if (fcn) { fcn (user, 0, NULL); } else { - eprintf ("Cannot find '%s' symbol in library.\n", r2go_sym); + R_LOG_ERROR ("Cannot find '%s' symbol in library", r2go_sym); } // dlclosing causes a crash, this is a know issue by Golang // https://github.com/golang/go/issues/32497 // https://github.com/golang/go/issues/11100 // r_lib_dl_close (vl); } else { - eprintf ("Cannot open '%s' library.\n", lib); + R_LOG_ERROR ("Cannot open '%s' library", lib); } } @@ -115,7 +115,7 @@ static bool __gorun(RLang *lang, const char *code, int len) { gocode_fini (&gocode); return true; } - eprintf ("Cannot open tmp.go\n"); + R_LOG_ERROR ("Cannot open tmp.go"); return false; } diff --git a/libr/lang/p/lib.c b/libr/lang/p/lib.c index c94ecff467..222d039c3e 100644 --- a/libr/lang/p/lib.c +++ b/libr/lang/p/lib.c @@ -34,7 +34,7 @@ static bool lang_lib_file_run(RLang *user, const char *file) { if (fcn) { fcn (user->user); } else { - eprintf ("Cannot find 'entry' symbol in library\n"); + R_LOG_ERROR ("Cannot find 'entry' symbol in library"); } r_lib_dl_close (lib); } diff --git a/libr/lang/p/pipe.c b/libr/lang/p/pipe.c index b42250f5bd..670a472b63 100644 --- a/libr/lang/p/pipe.c +++ b/libr/lang/p/pipe.c @@ -221,7 +221,7 @@ static bool lang_pipe_run(RLang *lang, const char *code, int len) { if (safe_in != -1) { dup2 (safe_in, 0); } else { - eprintf ("Cannot open ttyname(0) %s\n", term_in); + R_LOG_ERROR ("Cannot open ttyname(0) %s", term_in); } } } diff --git a/libr/lang/p/rust.c b/libr/lang/p/rust.c index 309438c75f..a1c161aa2a 100644 --- a/libr/lang/p/rust.c +++ b/libr/lang/p/rust.c @@ -54,11 +54,14 @@ static int lang_rust_file(RLang *lang, const char *file) { if (lib!= NULL) { void (*fcn)(RCore *); fcn = r_lib_dl_sym (lib, "entry"); - if (fcn) fcn (lang->user); - else eprintf ("Cannot find 'entry' symbol in library\n"); + if (fcn) { + fcn (lang->user); + } else { + R_LOG_ERROR ("Cannot find 'entry' symbol in library"); + } r_lib_dl_close (lib); } else { - eprintf ("Cannot open library\n"); + R_LOG_ERROR ("Cannot open library"); } r_file_rm (path); // remove lib free (path); @@ -73,7 +76,7 @@ static int lang_rust_init(void *user) { static bool lang_rust_run(RLang *lang, const char *code, int len) { FILE *fd = r_sandbox_fopen ("_tmp.rs", "w"); if (!fd) { - eprintf ("Cannot open _tmp.rs\n"); + R_LOG_ERROR ("Cannot open _tmp.rs"); return false; } const char *rust_header = \ diff --git a/libr/lang/p/v.c b/libr/lang/p/v.c index 88be0b953d..d445c46800 100644 --- a/libr/lang/p/v.c +++ b/libr/lang/p/v.c @@ -100,11 +100,11 @@ static void runlib(void *user, const char *lib) { if (fcn) { fcn (user, 0, NULL); } else { - eprintf ("Cannot find '%s' symbol in library\n", r2v_sym); + R_LOG_ERROR ("Cannot find '%s' symbol in library", r2v_sym); } r_lib_dl_close (vl); } else { - eprintf ("Cannot open '%s' library\n", lib); + R_LOG_ERROR ("Cannot open '%s' library", lib); } } @@ -132,7 +132,7 @@ static bool __run(RLang *lang, const char *code, int len) { vcode_fini (&vcode); return true; } - eprintf ("Cannot open .tmp.v\n"); + R_LOG_ERROR ("Cannot open .tmp.v"); return false; } diff --git a/libr/lang/p/zig.c b/libr/lang/p/zig.c index af6df7048e..38c31ca682 100644 --- a/libr/lang/p/zig.c +++ b/libr/lang/p/zig.c @@ -52,11 +52,11 @@ static bool lang_zig_file(RLang *lang, const char *file) { if (fcn) { fcn (lang->user); } else { - eprintf ("Cannot find 'entry' symbol in library\n"); + R_LOG_ERROR ("Cannot find 'entry' symbol in library"); } r_lib_dl_close (lib); } else { - eprintf ("Cannot open library\n"); + R_LOG_ERROR ("Cannot open library"); free (name); free (path); free (cc); @@ -97,7 +97,7 @@ static bool lang_zig_run(RLang *lang, const char *code, int len) { lang_zig_file (lang, file); r_file_rm (file); } else { - eprintf ("Cannot open %s\n", file); + R_LOG_ERROR ("Cannot open %s", file); } return true; } diff --git a/libr/search/regexp.c b/libr/search/regexp.c index 5aeecbd341..13268a951a 100644 --- a/libr/search/regexp.c +++ b/libr/search/regexp.c @@ -27,7 +27,7 @@ R_IPI int search_regex_read(RSearch *s, ut64 from, ut64 to) { } if (r_regex_init (&rx, (char *)kw->bin_keyword, reflags)) { - eprintf ("Cannot compile '%s' regexp\n", kw->bin_keyword); + R_LOG_ERROR ("Cannot compile '%s' regexp", kw->bin_keyword); ret = -1; goto beach; } @@ -111,7 +111,7 @@ R_IPI int search_regexp_update(RSearch *s, ut64 from, const ut8 *buf, int len) { } if (r_regex_init (&rx, (char *)kw->bin_keyword, reflags)) { - eprintf ("Cannot compile '%s' regexp\n", kw->bin_keyword); + R_LOG_ERROR ("Cannot compile '%s' regexp", kw->bin_keyword); return -1; } diff --git a/libr/search/search.c b/libr/search/search.c index 8c8ead89ee..95826c80a0 100644 --- a/libr/search/search.c +++ b/libr/search/search.c @@ -23,7 +23,7 @@ R_API RSearch *r_search_new(int mode) { } if (!r_search_set_mode (s, mode)) { free (s); - eprintf ("Cannot init search for mode %d\n", mode); + R_LOG_ERROR ("Cannot init search for mode %d", mode); return false; } s->inverse = false; @@ -633,7 +633,7 @@ R_API void r_search_string_prepare_backward(RSearch *s) { R_API void r_search_reset(RSearch *s, int mode) { s->nhits = 0; if (!r_search_set_mode (s, mode)) { - eprintf ("Cannot init search for mode %d\n", mode); + R_LOG_ERROR ("Cannot init search for mode %d", mode); } } diff --git a/libr/socket/socket_http_server.c b/libr/socket/socket_http_server.c index eb6a9df319..fd0b5d86ec 100644 --- a/libr/socket/socket_http_server.c +++ b/libr/socket/socket_http_server.c @@ -211,7 +211,7 @@ R_API void r_socket_http_free(RSocketHTTPRequest *rs) { int main() { RSocket *s = r_socket_new (false); if (!r_socket_listen (s, "8080", NULL)) { - eprintf ("Cannot listen here\n"); + R_LOG_ERROR ("Cannot listen here"); return 1; } for (;;) { diff --git a/libr/socket/socket_rap_client.c b/libr/socket/socket_rap_client.c index 86d8afbeb6..bb0010647a 100644 --- a/libr/socket/socket_rap_client.c +++ b/libr/socket/socket_rap_client.c @@ -45,10 +45,10 @@ R_API int r_socket_rap_client_open(RSocket *s, const char *file, int rw) { if (buf[0] == (char)(RAP_PACKET_OPEN | RAP_PACKET_REPLY)) { fd = r_read_at_be32 (buf + 1, 1); } else { - eprintf ("RapClientOpen: Bad packet 0x%02x\n", buf[0]); + R_LOG_ERROR ("RapClientOpen: Bad packet 0x%02x", buf[0]); } } else { - eprintf ("Cannot read 5 bytes from server\n"); + R_LOG_ERROR ("Cannot read 5 bytes from server"); } free (buf); return fd; diff --git a/libr/util/file.c b/libr/util/file.c index fedaf7abeb..261432ef8e 100644 --- a/libr/util/file.c +++ b/libr/util/file.c @@ -747,7 +747,7 @@ R_API bool r_file_hexdump(const char *file, const ut8 *buf, int len, int append) fd = r_sandbox_fopen (file, "wb"); } if (!fd) { - eprintf ("Cannot open '%s' for writing\n", file); + R_LOG_ERROR ("Cannot open '%s' for writing", file); return false; } for (i = 0; i < len; i += 16) { @@ -787,7 +787,7 @@ R_API bool r_file_dump(const char *file, const ut8 *buf, int len, bool append) { fd = r_sandbox_fopen (file, "wb"); } if (!fd) { - eprintf ("Cannot open '%s' for writing\n", file); + R_LOG_ERROR ("Cannot open '%s' for writing", file); return false; } if (buf) { @@ -1292,7 +1292,7 @@ R_API char *r_file_tmpdir(void) { if (!r_file_is_directory (path)) { free (path); return NULL; - //eprintf ("Cannot find dir.tmp '%s'\n", path); + //R_LOG_ERROR ("Cannot find dir.tmp '%s'", path); } return path; } @@ -1300,7 +1300,7 @@ R_API char *r_file_tmpdir(void) { R_API bool r_file_copy(const char *src, const char *dst) { r_return_val_if_fail (R_STR_ISNOTEMPTY (src) && R_STR_ISNOTEMPTY (dst), false); if (!strcmp (src, dst)) { - eprintf ("Cannot copy file '%s' to itself.\n", src); + R_LOG_ERROR ("Cannot copy file '%s' to itself", src); return false; } /* TODO: implement in C */ diff --git a/libr/util/format.c b/libr/util/format.c index b410dcedd1..3ac3087cf2 100644 --- a/libr/util/format.c +++ b/libr/util/format.c @@ -1792,14 +1792,14 @@ R_API int r_print_format_struct_size(RPrint *p, const char *f, int mode, int n) format_owned = true; } if (!format) { - eprintf ("Cannot find format for struct `%s'\n", structname + 1); + R_LOG_ERROR ("Cannot find format for struct `%s'", structname + 1); free (structname); free (o); return 0; } int newsize = r_print_format_struct_size (p, format, mode, n + 1); if (newsize < 1) { - eprintf ("Cannot find size for `%s'\n", format); + R_LOG_ERROR ("Cannot find size for `%s'", format); free (structname); free (o); return 0; diff --git a/libr/util/lib.c b/libr/util/lib.c index 2019290575..27be58941b 100644 --- a/libr/util/lib.c +++ b/libr/util/lib.c @@ -192,7 +192,7 @@ R_API int r_lib_run_handler(RLib *lib, RLibPlugin *plugin, RLibStruct *symbol) { IFDBG eprintf ("PLUGIN LOADED %p fcn %p\n", h, h->constructor); return h->constructor (plugin, h->user, symbol->data); } - IFDBG eprintf ("Cannot find plugin constructor\n"); + IFDBG R_LOG_ERROR ("Cannot find plugin constructor"); return -1; } @@ -275,7 +275,7 @@ R_API int r_lib_open(RLib *lib, const char *file) { void *handler = r_lib_dl_open (file); if (!handler) { - IFDBG eprintf ("Cannot open library: '%s'\n", file); + IFDBG R_LOG_ERROR ("Cannot open library: '%s'", file); return -1; } @@ -288,7 +288,7 @@ R_API int r_lib_open(RLib *lib, const char *file) { stru = (RLibStruct *) r_lib_dl_sym (handler, lib->symname); } if (!stru) { - IFDBG eprintf ("Cannot find symbol '%s' in library '%s'\n", + IFDBG R_LOG_ERROR ("Cannot find symbol '%s' in library '%s'", lib->symname, file); r_lib_dl_close (handler); return -1; @@ -388,7 +388,7 @@ R_API bool r_lib_opendir(RLib *lib, const char *path) { swprintf (directory, _countof (directory), L"%ls\\*.*", wcpath); fh = FindFirstFileW (directory, &dir); if (fh == INVALID_HANDLE_VALUE) { - IFDBG eprintf ("Cannot open directory %ls\n", wcpath); + IFDBG R_LOG_ERROR ("Cannot open directory %ls", wcpath); free (wcpath); return false; } @@ -399,7 +399,7 @@ R_API bool r_lib_opendir(RLib *lib, const char *path) { if (__lib_dl_check_filename (wctocbuff)) { r_lib_open (lib, wctocbuff); } else { - IFDBG eprintf ("Cannot open %ls\n", dir.cFileName); + IFDBG R_LOG_ERROR ("Cannot open %ls", dir.cFileName); } free (wctocbuff); } @@ -409,7 +409,7 @@ R_API bool r_lib_opendir(RLib *lib, const char *path) { #else dh = opendir (path); if (!dh) { - IFDBG eprintf ("Cannot open directory '%s'\n", path); + IFDBG R_LOG_ERROR ("Cannot open directory '%s'", path); return false; } while ((de = (struct dirent *)readdir (dh))) { @@ -418,10 +418,10 @@ R_API bool r_lib_opendir(RLib *lib, const char *path) { } snprintf (file, sizeof (file), "%s/%s", path, de->d_name); if (__lib_dl_check_filename (file)) { - IFDBG eprintf ("Loading %s\n", file); + IFDBG R_LOG_INFO ("Loading %s", file); r_lib_open (lib, file); } else { - IFDBG eprintf ("Cannot open %s\n", file); + IFDBG R_LOG_ERROR ("Cannot open %s", file); } } closedir (dh); diff --git a/libr/util/sandbox.c b/libr/util/sandbox.c index 2da5ad8bd5..042a774d89 100644 --- a/libr/util/sandbox.c +++ b/libr/util/sandbox.c @@ -274,7 +274,7 @@ R_API int r_sandbox_system(const char *x, int n) { if (argv) { char *argv0 = r_file_path (argv[0]); if (!argv0) { - eprintf ("Cannot find '%s'\n", argv[0]); + R_LOG_ERROR ("Cannot find '%s'", argv[0]); return -1; } pid = 0; diff --git a/libr/util/sys.c b/libr/util/sys.c index 54ae69b2bc..59786f927d 100644 --- a/libr/util/sys.c +++ b/libr/util/sys.c @@ -259,7 +259,7 @@ R_API RList *r_sys_dir(const char *path) { char *cfname; HANDLE fh = r_sandbox_opendir (path, &entry); if (fh == INVALID_HANDLE_VALUE) { - //IFDGB eprintf ("Cannot open directory %ls\n", wcpath); + //IFDGB R_LOG_ERROR ("Cannot open directory %ls", wcpath); return list; } list = r_list_newf (free); diff --git a/libr/util/utype.c b/libr/util/utype.c index cc936df281..4fc18bbf10 100644 --- a/libr/util/utype.c +++ b/libr/util/utype.c @@ -454,7 +454,7 @@ static char *fmt_struct_union(Sdb *TDB, char *var, bool is_typedef) { vars = r_str_append (vars, " "); } } else { - eprintf ("Cannot resolve type '%s'\n", var3); + R_LOG_ERROR ("Cannot resolve type '%s'", var3); } free (type); } diff --git a/libr/util/w32.c b/libr/util/w32.c index 37a0ece001..12372aac78 100644 --- a/libr/util/w32.c +++ b/libr/util/w32.c @@ -19,7 +19,7 @@ static inline HANDLE w32_loadlib(const char *name, const char *libname) { if (!lib) { lib = LoadLibrary (TEXT (libname)); if (!lib) { - eprintf ("Cannot load %s to resolve %s. Aborting\n", libname, name); + R_LOG_ERROR ("Cannot load %s to resolve %s. Aborting", libname, name); return (HANDLE)(size_t)0; } } diff --git a/sys/lint.sh b/sys/lint.sh index 05eb9e72af..8a26895cd2 100755 --- a/sys/lint.sh +++ b/sys/lint.sh @@ -17,7 +17,9 @@ (git grep -n -i 'R_LOG_ERROR ("ERROR' | grep -v sys) && exit 1 (git grep -n ^R_API libr shlr | grep ' (') && exit 1 (git grep -n ^R_API libr shlr | grep '( ') && exit 1 -(git grep -n -e 'eprintf ("Could' -e 'eprintf ("Failed' libr | grep -v -e ^libr/core/cmd_ -e ^libr/main/) && exit 1 +(git grep -n -e 'eprintf ("Could' -e 'eprintf ("Failed' -e 'eprintf ("Cannot' libr \ + | grep -v -e ^libr/core/cmd -e ^libr/main/ -e ^libr/util/syscmd \ + | grep -v -e r_cons_eprintf -e alloc) && exit 1 # pending cleanups # ( git grep 'desc = "[A-Z]' ) && exit 1 @@ -27,6 +29,5 @@ # (git grep 'strncmp' libr) # && exit 1 # use r_str_startswith() # (git grep 'eprintf' libr | grep 'Warning:') # && exit 1 # (git grep 'eprintf' | grep 'Usage:' | grep -v sys/) # && exit 1 -# (git grep -n 'eprintf ("Cannot' libr | grep -v -e ^libr/core/cmd_ -e ^libr/main/) && exit 1 exit 0 diff --git a/test/db/cmd/cmd_pa b/test/db/cmd/cmd_pa index df3bde398c..6f93e40af4 100644 --- a/test/db/cmd/cmd_pa +++ b/test/db/cmd/cmd_pa @@ -38,7 +38,7 @@ pa out 256,AL EOF EXPECT= EXPECT_ERR=<