From f7d4e298a38977c88825ddaf9c7ad44541798ec6 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Thu, 9 May 2024 21:12:22 +0800 Subject: [PATCH] close some unused logs --- core/scf_ast.c | 13 ++++++------- core/scf_function.c | 2 +- elf/scf_dwarf_abbrev.c | 2 +- elf/scf_dwarf_line.c | 4 ++-- elf/scf_elf_link.c | 24 ++++++++++-------------- elf/scf_elf_native.c | 8 ++++---- elf/scf_elf_x64.c | 2 +- elf/scf_elf_x64_so.c | 14 +++++++------- native/eda/scf_eda_pack.c | 3 +-- native/eda/scf_eda_pack.h | 16 ++++------------ native/x64/scf_x64.c | 18 +++++++++--------- native/x64/scf_x64_bb_color.c | 10 +++++----- native/x64/scf_x64_graph.c | 4 ++-- native/x64/scf_x64_inst.c | 2 +- native/x64/scf_x64_inst_common.c | 5 ++--- native/x64/scf_x64_inst_util.c | 2 -- native/x64/scf_x64_peephole.c | 4 ++-- native/x64/scf_x64_reg.c | 26 +++++++++++++------------- parse/main.c | 4 +++- parse/scf_dfa_block.c | 2 +- parse/scf_dfa_expr.c | 5 ++--- parse/scf_dfa_function.c | 6 +----- parse/scf_dfa_type.c | 2 +- parse/scf_parse.c | 21 ++++++++++----------- 24 files changed, 89 insertions(+), 110 deletions(-) diff --git a/core/scf_ast.c b/core/scf_ast.c index f3026d7..4f19ee4 100644 --- a/core/scf_ast.c +++ b/core/scf_ast.c @@ -34,13 +34,13 @@ int scf_ast_close(scf_ast_t* ast) int scf_ast_add_base_type(scf_ast_t* ast, scf_base_type_t* base_type) { if (!ast || !base_type) { - printf("%s(),%d, error\n", __func__, __LINE__); - return -1; + scf_loge("\n"); + return -EINVAL; } scf_type_t* t = scf_type_alloc(NULL, base_type->name, base_type->type, base_type->size); if (!t) { - printf("%s(),%d, error\n", __func__, __LINE__); + scf_loge("\n"); return -1; } @@ -51,13 +51,13 @@ int scf_ast_add_base_type(scf_ast_t* ast, scf_base_type_t* base_type) int scf_ast_add_file_block(scf_ast_t* ast, const char* path) { if (!ast || !path) { - printf("%s(),%d, error\n", __func__, __LINE__); - return -1; + scf_loge("\n"); + return -EINVAL; } scf_block_t* file_block = scf_block_alloc_cstr(path); if (!file_block) { - printf("%s(),%d, error\n", __func__, __LINE__); + scf_loge("\n"); return -1; } @@ -65,7 +65,6 @@ int scf_ast_add_file_block(scf_ast_t* ast, const char* path) scf_node_add_child((scf_node_t*)ast->root_block, (scf_node_t*)file_block); ast->current_block = file_block; - printf("%s(),%d, file_block: %p\n", __func__, __LINE__, file_block); return 0; } diff --git a/core/scf_function.c b/core/scf_function.c index 16a1611..eab70b6 100644 --- a/core/scf_function.c +++ b/core/scf_function.c @@ -235,7 +235,7 @@ int scf_function_signature(scf_function_t* f) } } - scf_logw("f signature: %s\n", s->data); + scf_logd("f signature: %s\n", s->data); f->signature = s; return 0; diff --git a/elf/scf_dwarf_abbrev.c b/elf/scf_dwarf_abbrev.c index 1cb56d2..5a44e5c 100644 --- a/elf/scf_dwarf_abbrev.c +++ b/elf/scf_dwarf_abbrev.c @@ -408,7 +408,7 @@ int scf_dwarf_abbrev_encode(scf_vector_t* abbrev_results, scf_string_t* debug_ab d->visited_flag = 0; if (d->code) - scf_loge("d->code: %u, d->tag: %s\n", d->code, scf_dwarf_find_tag(d->tag)); + scf_logd("d->code: %u, d->tag: %s\n", d->code, scf_dwarf_find_tag(d->tag)); } for (i = 0; i < abbrev_results->size; i++) { diff --git a/elf/scf_dwarf_line.c b/elf/scf_dwarf_line.c index 0bd4fb3..a59ec10 100644 --- a/elf/scf_dwarf_line.c +++ b/elf/scf_dwarf_line.c @@ -624,7 +624,7 @@ int scf_dwarf_line_encode(scf_dwarf_debug_t* debug, scf_dwarf_line_machine_t* lm lm->prologue->prologue_length = debug_line->len - prologue_pos - sizeof(lm->prologue->prologue_length); memcpy(debug_line->data + prologue_pos, &lm->prologue->prologue_length, sizeof(lm->prologue->prologue_length)); - scf_loge("lm->prologue->prologue_length: %u\n\n", lm->prologue->prologue_length); + scf_logd("lm->prologue->prologue_length: %u\n\n", lm->prologue->prologue_length); lm->address = 0; @@ -806,7 +806,7 @@ int scf_dwarf_line_encode(scf_dwarf_debug_t* debug, scf_dwarf_line_machine_t* lm lm->prologue->total_length = debug_line->len - origin_len - sizeof(lm->prologue->total_length); memcpy(debug_line->data + origin_len, &lm->prologue->total_length, sizeof(lm->prologue->total_length)); - scf_loge("lm->prologue->total_length: %u\n", lm->prologue->total_length); + scf_logd("lm->prologue->total_length: %u\n", lm->prologue->total_length); return 0; } diff --git a/elf/scf_elf_link.c b/elf/scf_elf_link.c index fefaf77..15a999a 100644 --- a/elf/scf_elf_link.c +++ b/elf/scf_elf_link.c @@ -488,7 +488,7 @@ static int merge_relas(scf_vector_t* dst, scf_vector_t* src, size_t offset, int return -ENOMEM; } - scf_logw("j: %d, nb_syms: %d:%ld, sym: %s\n", j, nb_syms, ELF32_R_SYM(rela2->r_info), rela2->name); + scf_logd("j: %d, nb_syms: %d:%ld, sym: %s\n", j, nb_syms, ELF32_R_SYM(rela2->r_info), rela2->name); rela->r_offset = rela2->r_offset; rela->r_info = rela2->r_info; @@ -554,7 +554,7 @@ static int merge_syms(scf_elf_file_t* exec, scf_elf_file_t* obj) return -ENOMEM; } - scf_loge("sym: %d, %s\n", exec->syms->size, sym->name); + scf_logd("sym: %d, %s\n", exec->syms->size, sym->name); if (scf_vector_add(exec->syms, sym) < 0) { scf_loge("\n"); @@ -645,7 +645,7 @@ static int merge_objs(scf_elf_file_t* exec, char* inputs[], int nb_inputs, const return -1; } - scf_loge("i: %d, input: %s\n", i, inputs[i]); + scf_logi("i: %d, input: %s\n", i, inputs[i]); int ret = merge_obj(exec, obj, bits); if (ret < 0) { @@ -698,12 +698,10 @@ static int _find_sym(scf_elf_sym_t** psym, scf_elf_rela_t* rela, scf_vector_t* s } } - if (0 == n) { - scf_loge("global symbol: %s not found\n", sym->name); + if (0 == n) return -1; - - } else if (n > 1) { - scf_loge("tow global symbol: %s\n", sym->name); + else if (n > 1) { + scf_logi("tow global symbol: %s\n", sym->name); return -1; } } @@ -733,10 +731,8 @@ static int _find_lib_sym(scf_ar_file_t** par, uint32_t* poffset, uint32_t* psize break; } - if (j == libs->size) { - scf_loge("\n"); + if (j == libs->size) return -1; - } fseek(ar->fp, asym->offset, SEEK_SET); @@ -970,7 +966,7 @@ static int link_relas(scf_elf_file_t* exec, char* afiles[], int nb_afiles, char* else rela->r_info = ELF32_R_INFO(j + 1, ELF32_R_TYPE(rela->r_info)); - scf_loge("j: %d, sym: %s, r_offset: %#lx, r_addend: %ld\n", j, + scf_logd("j: %d, sym: %s, r_offset: %#lx, r_addend: %ld\n", j, sym->name, rela->r_offset, rela->r_addend); } @@ -999,7 +995,7 @@ static int link_relas(scf_elf_file_t* exec, char* afiles[], int nb_afiles, char* return -1; } - scf_loge("sym: %s, offset: %d, size: %d\n\n", sym->name, offset, size); + scf_logi("sym: %s, offset: %d, size: %d\n\n", sym->name, offset, size); ret = merge_ar_obj(exec, ar, offset, size, arch); if (ret < 0) { @@ -1011,7 +1007,7 @@ static int link_relas(scf_elf_file_t* exec, char* afiles[], int nb_afiles, char* for (i = 0; i < exec->dyn_needs->size; i++) { so = exec->dyn_needs->data[i]; - scf_loge("so: %s\n", so->name->data); + scf_logd("so: %s\n", so->name->data); int sym_idx; int j; diff --git a/elf/scf_elf_native.c b/elf/scf_elf_native.c index 3a32ffe..a4187da 100644 --- a/elf/scf_elf_native.c +++ b/elf/scf_elf_native.c @@ -609,7 +609,7 @@ int elf_add_dyn_need(scf_elf_context_t* elf, const char* soname) return -ENOMEM; } - scf_loge("soname: %s\n", soname); + scf_logi("soname: %s\n", soname); return 0; } @@ -660,7 +660,7 @@ int elf_read_relas(scf_elf_context_t* elf, scf_vector_t* relas, const char* sh_n if (ret < 0) return ret; - scf_loge("sh_rela: %u\n", sh_rela->sh.sh_link); + scf_logd("sh_rela: %u\n", sh_rela->sh.sh_link); ret = __elf_read_section_by_index(elf, &symtab, sh_rela->sh.sh_link); if (ret < 0) { @@ -810,7 +810,7 @@ int elf_write_sections(scf_elf_context_t* elf) for (i = 0; i < e->sections->size; i++) { s = e->sections->data[i]; - scf_loge("sh->name: %s, data: %p, len: %d\n", s->name->data, s->data, s->data_len); + scf_logd("sh->name: %s, data: %p, len: %d\n", s->name->data, s->data, s->data_len); if (s->data && s->data_len > 0) fwrite(s->data, s->data_len, 1, elf->fp); @@ -876,7 +876,7 @@ int elf_write_rel(scf_elf_context_t* elf, uint16_t e_machine) local_syms++; } - scf_loge("e->symbols->size: %d\n", e->symbols->size); + scf_logd("e->symbols->size: %d\n", e->symbols->size); // .symtab header section_header(&e->sh_symtab, shstrtab, 0, offset, symtab, nb_sections - 2, local_syms, sizeof(Elf64_Sym)); diff --git a/elf/scf_elf_x64.c b/elf/scf_elf_x64.c index eec6161..41e6945 100644 --- a/elf/scf_elf_x64.c +++ b/elf/scf_elf_x64.c @@ -170,7 +170,7 @@ static int _x64_elf_link_sections(elf_native_t* x64, uint32_t cs_index, uint32_t s = x64->sections->data[rs->sh.sh_info - 1]; - scf_loge("s: %s, rs: %s, rs->sh.sh_info: %u\n", s->name->data, rs->name->data, rs->sh.sh_info); + scf_logd("s: %s, rs: %s, rs->sh.sh_info: %u\n", s->name->data, rs->name->data, rs->sh.sh_info); assert(!strcmp(s->name->data, rs->name->data + 5)); diff --git a/elf/scf_elf_x64_so.c b/elf/scf_elf_x64_so.c index 8fa0ec8..b468560 100644 --- a/elf/scf_elf_x64_so.c +++ b/elf/scf_elf_x64_so.c @@ -470,7 +470,7 @@ int __x64_elf_add_dyn (elf_native_t* x64) s->index = x64->sections->size + 1 + sizeof(sh_names) / sizeof(sh_names[0]); - scf_logw("s: %s, link: %d, info: %d\n", s->name->data, s->sh.sh_link, s->sh.sh_info); + scf_logd("s: %s, link: %d, info: %d\n", s->name->data, s->sh.sh_link, s->sh.sh_info); if (s->sh.sh_link > 0) { assert(s->sh.sh_link - 1 < x64->sections->size); @@ -515,7 +515,7 @@ int __x64_elf_add_dyn (elf_native_t* x64) syms[i + 1].st_name = str->len; - scf_loge("i: %d, st_value: %#lx\n", i, syms[i + 1].st_value); + scf_logd("i: %d, st_value: %#lx\n", i, syms[i + 1].st_value); scf_string_cat_cstr_len(str, xsym->name->data, xsym->name->len + 1); } @@ -551,7 +551,7 @@ int __x64_elf_add_dyn (elf_native_t* x64) dyns[i].d_tag = DT_NEEDED; dyns[i].d_un.d_val = str->len; - scf_logw("i: %d, %s, %s\n", i, needed->data, needed->data + prefix); + scf_logd("i: %d, %s, %s\n", i, needed->data, needed->data + prefix); scf_string_cat_cstr_len(str, needed->data + prefix, needed->len - prefix + 1); } @@ -627,7 +627,7 @@ int __x64_elf_add_dyn (elf_native_t* x64) for (i = 0; i < x64->sections->size; i++) { s = x64->sections->data[i]; - scf_loge("i: %d, s: %s, index: %d\n", i, s->name->data, s->index); + scf_logd("i: %d, s: %s, index: %d\n", i, s->name->data, s->index); if (s->link) { scf_logd("link: %s, index: %d\n", s->link->name->data, s->link->index); @@ -665,8 +665,8 @@ int __x64_elf_post_dyn(elf_native_t* x64, uint64_t rx_base, uint64_t rw_base, el x64->interp->sh.sh_addr = rx_base + x64->interp->offset; x64->plt->sh.sh_addr = rx_base + x64->plt->offset; - scf_loge("rw_base: %#lx, offset: %#lx\n", rw_base, x64->got_plt->offset); - scf_loge("got_addr: %#lx\n", x64->got_plt->sh.sh_addr); + scf_logd("rw_base: %#lx, offset: %#lx\n", rw_base, x64->got_plt->offset); + scf_logd("got_addr: %#lx\n", x64->got_plt->sh.sh_addr); Elf64_Rela* rela_plt = (Elf64_Rela*)x64->rela_plt->data; Elf64_Sym* dynsym = (Elf64_Sym* )x64->dynsym->data; @@ -704,7 +704,7 @@ int __x64_elf_post_dyn(elf_native_t* x64, uint64_t rx_base, uint64_t rw_base, el rela_plt[i].r_addend = 0; rela_plt[i].r_info = ELF64_R_INFO(i + 1, R_X86_64_JUMP_SLOT); - scf_loge("got_addr: %#lx\n", got_addr); + scf_logd("got_addr: %#lx\n", got_addr); *got_plt = plt_addr + 6; diff --git a/native/eda/scf_eda_pack.c b/native/eda/scf_eda_pack.c index 8d3988b..c837e73 100644 --- a/native/eda/scf_eda_pack.c +++ b/native/eda/scf_eda_pack.c @@ -1,5 +1,4 @@ #include "scf_eda_pack.h" -//#include "scf_def.h" static int component_pins[SCF_EDA_Components_NB] = { @@ -18,7 +17,7 @@ static int component_pins[SCF_EDA_Components_NB] = static scf_edata_t component_datas[] = { {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0}, - {SCF_EDA_Battery, 0, SCF_EDA_Battery_POS, 0, 0, 0, 0, 0, 0}, + {SCF_EDA_Battery, 0, SCF_EDA_Battery_POS, 0, 0, 1e-9, 1e9, 0, 0}, {SCF_EDA_Resistor, 0, 0, 0, 0, 1e4, 0, 0, 0}, {SCF_EDA_Capacitor, 0, 0, 0, 0, 10, 0.1, 0, 0}, diff --git a/native/eda/scf_eda_pack.h b/native/eda/scf_eda_pack.h index 2cf8303..1f48b4c 100644 --- a/native/eda/scf_eda_pack.h +++ b/native/eda/scf_eda_pack.h @@ -119,15 +119,11 @@ struct scf_epin_s SCF_PACK_DEF_VAR(double, uh); SCF_PACK_DEF_VAR(double, hfe); - SCF_PACK_DEF_VAR(double, jdr); SCF_PACK_DEF_VAR(double, dr); SCF_PACK_DEF_VAR(double, sr); SCF_PACK_DEF_VAR(double, pr); - SCF_PACK_DEF_VAR(double, jsr); - SCF_PACK_DEF_VAR(double, jpr); - SCF_PACK_DEF_VAR(uint64_t, path); SCF_PACK_DEF_VAR(int, x); @@ -158,13 +154,9 @@ SCF_PACK_INFO_VAR(ScfEpin, uf), SCF_PACK_INFO_VAR(ScfEpin, uh), SCF_PACK_INFO_VAR(ScfEpin, hfe), -SCF_PACK_INFO_VAR(ScfEpin, jdr), SCF_PACK_INFO_VAR(ScfEpin, dr), - SCF_PACK_INFO_VAR(ScfEpin, sr), SCF_PACK_INFO_VAR(ScfEpin, pr), -SCF_PACK_INFO_VAR(ScfEpin, jsr), -SCF_PACK_INFO_VAR(ScfEpin, jpr), SCF_PACK_INFO_VAR(ScfEpin, path), SCF_PACK_INFO_VAR(ScfEpin, x), @@ -199,7 +191,8 @@ typedef struct { SCF_PACK_DEF_OBJS(ScfLine, lines); SCF_PACK_DEF_VAR(double, v); - SCF_PACK_DEF_VAR(double, a); + SCF_PACK_DEF_VAR(double, ain); + SCF_PACK_DEF_VAR(double, aout); SCF_PACK_DEF_VAR(uint8_t, vconst); SCF_PACK_DEF_VAR(uint8_t, aconst); SCF_PACK_DEF_VAR(uint8_t, vflag); @@ -217,7 +210,8 @@ SCF_PACK_INFO_OBJS(ScfEline, conns, ScfEconn), SCF_PACK_INFO_OBJS(ScfEline, lines, ScfLine), SCF_PACK_INFO_VAR(ScfEline, v), -SCF_PACK_INFO_VAR(ScfEline, a), +SCF_PACK_INFO_VAR(ScfEline, ain), +SCF_PACK_INFO_VAR(ScfEline, aout), SCF_PACK_INFO_VAR(ScfEline, vconst), SCF_PACK_INFO_VAR(ScfEline, aconst), SCF_PACK_INFO_VAR(ScfEline, vflag), @@ -234,7 +228,6 @@ struct scf_ecomponent_s SCF_PACK_DEF_VAR(double, a); SCF_PACK_DEF_VAR(double, dr); - SCF_PACK_DEF_VAR(double, jdr); SCF_PACK_DEF_VAR(double, r); SCF_PACK_DEF_VAR(double, uf); @@ -261,7 +254,6 @@ SCF_PACK_INFO_VAR(ScfEcomponent, v), SCF_PACK_INFO_VAR(ScfEcomponent, a), SCF_PACK_INFO_VAR(ScfEcomponent, dr), -SCF_PACK_INFO_VAR(ScfEcomponent, jdr), SCF_PACK_INFO_VAR(ScfEcomponent, r), SCF_PACK_INFO_VAR(ScfEcomponent, uf), diff --git a/native/x64/scf_x64.c b/native/x64/scf_x64.c index 937c847..8ff7f3c 100644 --- a/native/x64/scf_x64.c +++ b/native/x64/scf_x64.c @@ -508,7 +508,7 @@ static int _x64_bb_regs_from_graph(scf_basic_block_t* bb, scf_graph_t* g) scf_dn_status_t* ds; if (!dn) { - _x64_rcg_node_printf(rn); + //_x64_rcg_node_printf(rn); continue; } @@ -524,9 +524,9 @@ static int _x64_bb_regs_from_graph(scf_basic_block_t* bb, scf_graph_t* g) ds->color = gn->color; dn->color = gn->color; - _x64_rcg_node_printf(rn); + //_x64_rcg_node_printf(rn); } - printf("\n"); + //printf("\n"); return 0; } @@ -654,8 +654,8 @@ static int _x64_make_insts_for_list(scf_native_t* ctx, scf_list_t* h, int bb_off if (!c->instructions) continue; - scf_3ac_code_print(c, NULL); - _x64_inst_printf(c); +// scf_3ac_code_print(c, NULL); +// _x64_inst_printf(c); } return bb_offset; @@ -913,7 +913,7 @@ static void _x64_bbg_fix_loads(scf_bb_group_t* bbg) if (ds->color == dn->color) continue; -#if 1 +#if 0 scf_variable_t* v = dn->var; if (v->w) scf_logw("v_%d_%d/%s, ", v->w->line, v->w->pos, v->w->text->data); @@ -1039,12 +1039,12 @@ int _scf_x64_select_inst(scf_native_t* ctx) return ret; } - scf_loge("************ bb: %d\n", bb->index); + scf_logd("************ bb: %d\n", bb->index); ret = _x64_make_insts_for_list(ctx, &bb->code_list_head, 0); if (ret < 0) return ret; bb->native_flag = 1; - scf_loge("************ bb: %d\n", bb->index); + scf_logd("************ bb: %d\n", bb->index); ret = x64_save_bb_colors(bb->dn_colors_exit, bbg, bb); if (ret < 0) @@ -1165,7 +1165,7 @@ int scf_x64_select_inst(scf_native_t* ctx, scf_function_t* f) for (i = 0; i < local_vars->size; i++) { scf_variable_t* v = local_vars->data[i]; assert(v->w); - scf_logi("v: %p, name: %s_%d_%d, size: %d, bp_offset: %d, arg_flag: %d\n", + scf_logd("v: %p, name: %s_%d_%d, size: %d, bp_offset: %d, arg_flag: %d\n", v, v->w->text->data, v->w->line, v->w->pos, scf_variable_size(v), v->bp_offset, v->arg_flag); } diff --git a/native/x64/scf_x64_bb_color.c b/native/x64/scf_x64_bb_color.c index fb04a07..af2055b 100644 --- a/native/x64/scf_x64_bb_color.c +++ b/native/x64/scf_x64_bb_color.c @@ -25,17 +25,17 @@ void x64_init_bb_colors(scf_basic_block_t* bb) if (scf_vector_find(bb->dn_loads, dn)) { scf_variable_t* v = dn->var; if (v->w) - scf_loge("v_%d_%d/%s, ", v->w->line, v->w->pos, v->w->text->data); + scf_logd("v_%d_%d/%s, ", v->w->line, v->w->pos, v->w->text->data); else - scf_loge("v_%#lx, ", 0xffff & (uintptr_t)v); + scf_logd("v_%#lx, ", 0xffff & (uintptr_t)v); - printf("color: %ld, loaded: %d", dn->color, dn->loaded); +// printf("color: %ld, loaded: %d", dn->color, dn->loaded); if (dn->color > 0) { scf_register_t* r = x64_find_register_color(dn->color); - printf(", reg: %s", r->name); +// printf(", reg: %s", r->name); } - printf("\n"); +// printf("\n"); } } } diff --git a/native/x64/scf_x64_graph.c b/native/x64/scf_x64_graph.c index 1a604af..aebd3cd 100644 --- a/native/x64/scf_x64_graph.c +++ b/native/x64/scf_x64_graph.c @@ -270,9 +270,9 @@ static scf_graph_node_t* _x64_max_neighbors(scf_graph_t* graph) x64_rcg_node_t* rn = node_max->data; if (rn->dag_node->var->w) - scf_logi("max_neighbors: %d, %s\n", max, rn->dag_node->var->w->text->data); + scf_logd("max_neighbors: %d, %s\n", max, rn->dag_node->var->w->text->data); else - scf_logi("max_neighbors: %d, v_%p\n", max, rn->dag_node->var); + scf_logd("max_neighbors: %d, v_%p\n", max, rn->dag_node->var); return node_max; } diff --git a/native/x64/scf_x64_inst.c b/native/x64/scf_x64_inst.c index 985f753..690a0a4 100644 --- a/native/x64/scf_x64_inst.c +++ b/native/x64/scf_x64_inst.c @@ -454,7 +454,7 @@ static int _x64_inst_call_handler(scf_native_t* ctx, scf_3ac_code_t* c) int data_rela_size = f->data_relas->size; int text_rela_size = f->text_relas->size; - scf_loge("f->data_relas->size: %d, f->text_relas->size: %d\n", f->data_relas->size, f->text_relas->size); + scf_logd("f->data_relas->size: %d, f->text_relas->size: %d\n", f->data_relas->size, f->text_relas->size); int ret; int i; diff --git a/native/x64/scf_x64_inst_common.c b/native/x64/scf_x64_inst_common.c index cd11390..c5df00f 100644 --- a/native/x64/scf_x64_inst_common.c +++ b/native/x64/scf_x64_inst_common.c @@ -195,10 +195,9 @@ int x64_inst_op2(int OpCode_type, scf_dag_node_t* dst, scf_dag_node_t* src, scf_ if (scf_variable_const_string(src->var)) return _x64_inst_op2_imm_str(OpCode_type, dst, src, c, f); - if (!scf_variable_float(src->var)) { - scf_loge("\n"); + if (!scf_variable_float(src->var)) return _x64_inst_op2_imm(OpCode_type, dst, src, c, f); - } + src->color = -1; src->var->global_flag = 1; } diff --git a/native/x64/scf_x64_inst_util.c b/native/x64/scf_x64_inst_util.c index 995fa3a..8161605 100644 --- a/native/x64/scf_x64_inst_util.c +++ b/native/x64/scf_x64_inst_util.c @@ -150,8 +150,6 @@ static int _x64_make_disp(scf_rela_t** prela, scf_instruction_t* inst, uint32_t int i; for (i = 0; i < 4; i++) inst->code[inst->len++] = p[i]; - - scf_logw("global var\n"); return 0; } diff --git a/native/x64/scf_x64_peephole.c b/native/x64/scf_x64_peephole.c index 82b9b4b..784fefd 100644 --- a/native/x64/scf_x64_peephole.c +++ b/native/x64/scf_x64_peephole.c @@ -26,7 +26,7 @@ static void _x64_peephole_del_push_by_pop(scf_vector_t* insts, scf_instruction_t scf_vector_del(insts, push); - scf_loge("del: \n"); + scf_logw("del: \n"); scf_instruction_print(push); free(push); @@ -393,7 +393,7 @@ static void _x64_peephole_function(scf_vector_t* tmp_insts, scf_function_t* f, i assert(0 == scf_vector_del(c->instructions, inst)); assert(0 == scf_vector_del(tmp_insts, inst)); - scf_loge("del: \n"); + scf_logw("del: \n"); scf_instruction_print(inst); free(inst); diff --git a/native/x64/scf_x64_reg.c b/native/x64/scf_x64_reg.c index 85e08b9..7c0a97c 100644 --- a/native/x64/scf_x64_reg.c +++ b/native/x64/scf_x64_reg.c @@ -346,9 +346,9 @@ int x64_registers_reset() scf_dag_node_t* dn = r->dag_nodes->data[j]; if (dn->var->w) - scf_logw("drop: v_%d_%d/%s\n", dn->var->w->line, dn->var->w->pos, dn->var->w->text->data); + scf_logd("drop: v_%d_%d/%s\n", dn->var->w->line, dn->var->w->pos, dn->var->w->text->data); else - scf_logw("drop: v_%#lx\n", 0xffff & (uintptr_t)dn->var); + scf_logd("drop: v_%#lx\n", 0xffff & (uintptr_t)dn->var); int ret = scf_vector_del(r->dag_nodes, dn); if (ret < 0) { @@ -470,9 +470,9 @@ int x64_save_var2(scf_dag_node_t* dn, scf_register_t* r, scf_3ac_code_t* c, scf_ if (scf_variable_const(v)) { if (v->w) - scf_logw("const literal var: v_%s_%d_%d not save\n", v->w->text->data, v->w->line, v->w->pos); + scf_logd("const literal var: v_%s_%d_%d not save\n", v->w->text->data, v->w->line, v->w->pos); else - scf_logw("const literal var: v_%#lx not save\n", 0xffff & (uintptr_t)v); + scf_logd("const literal var: v_%#lx not save\n", 0xffff & (uintptr_t)v); goto end; } @@ -489,15 +489,15 @@ int x64_save_var2(scf_dag_node_t* dn, scf_register_t* r, scf_3ac_code_t* c, scf_ v->tmp_flag = 1; f->local_vars_size = local_vars_size; - +#if 0 scf_logw("r: %s, temp var, ", r->name); if (v->w) printf("v_%d_%d/%s, bp_offset: %d\n", v->w->line, v->w->pos, v->w->text->data, v->bp_offset); else printf("v_%#lx, bp_offset: %d\n", 0xffff & (uintptr_t)v, v->bp_offset); - +#endif } else { -#if 1 +#if 0 if (v->w) scf_logw("save var: v_%d_%d/%s, ", v->w->line, v->w->pos, v->w->text->data); else @@ -513,7 +513,7 @@ int x64_save_var2(scf_dag_node_t* dn, scf_register_t* r, scf_3ac_code_t* c, scf_ mov = x64_find_OpCode(SCF_X64_MOVSD, r->bytes, r->bytes, SCF_X64_G2E); } else { mov = x64_find_OpCode(SCF_X64_MOV, r->bytes, r->bytes, SCF_X64_G2E); - scf_loge("v->size: %d\n", v->size); + scf_logd("v->size: %d\n", v->size); } inst = x64_make_inst_G2M(&rela, mov, v, NULL, r); @@ -656,18 +656,18 @@ static int _x64_overflow_reg3(scf_register_t* r, scf_dag_node_t* dn, scf_3ac_cod j++; continue; } -#if 1 +#if 0 scf_variable_t* v = dn->var; scf_variable_t* v2 = dn2->var; if (v->w) - scf_loge("v_%d_%d/%s, bp_offset: %d\n", v->w->line, v->w->pos, v->w->text->data, v->bp_offset); + scf_logi("v_%d_%d/%s, bp_offset: %d\n", v->w->line, v->w->pos, v->w->text->data, v->bp_offset); else - scf_loge("v_%#lx, bp_offset: %d\n", 0xffff & (uintptr_t)v, v->bp_offset); + scf_logi("v_%#lx, bp_offset: %d\n", 0xffff & (uintptr_t)v, v->bp_offset); if (v2->w) - scf_loge("v2_%d_%d/%s, bp_offset: %d\n", v2->w->line, v2->w->pos, v2->w->text->data, v2->bp_offset); + scf_logi("v2_%d_%d/%s, bp_offset: %d\n", v2->w->line, v2->w->pos, v2->w->text->data, v2->bp_offset); else - scf_loge("v2_%#lx, bp_offset: %d\n", 0xffff & (uintptr_t)v2, v2->bp_offset); + scf_logi("v2_%#lx, bp_offset: %d\n", 0xffff & (uintptr_t)v2, v2->bp_offset); #endif int ret = x64_save_var(dn2, c, f); if (ret < 0) diff --git a/parse/main.c b/parse/main.c index 753e5b1..2ef02fb 100644 --- a/parse/main.c +++ b/parse/main.c @@ -114,7 +114,7 @@ int main(int argc, char* argv[]) return -1; } - scf_loge("fname: %s\n", fname); + scf_logi("fname: %s\n", fname); scf_vector_t* vec; @@ -138,6 +138,8 @@ int main(int argc, char* argv[]) return -ENOMEM; } + printf("\n"); + scf_parse_t* parse = NULL; if (scf_parse_open(&parse) < 0) { diff --git a/parse/scf_dfa_block.c b/parse/scf_dfa_block.c index 3158ee2..2ed9bc1 100644 --- a/parse/scf_dfa_block.c +++ b/parse/scf_dfa_block.c @@ -230,7 +230,7 @@ static int _dfa_init_syntax_block(scf_dfa_t* dfa) for (i = 0; i < entry->childs->size; i++) { scf_dfa_node_t* n = entry->childs->data[i]; - scf_logi("n->name: %s\n", n->name); + scf_logd("n->name: %s\n", n->name); } return 0; diff --git a/parse/scf_dfa_expr.c b/parse/scf_dfa_expr.c index a4918c1..85ce9aa 100644 --- a/parse/scf_dfa_expr.c +++ b/parse/scf_dfa_expr.c @@ -762,7 +762,6 @@ static int _expr_fini_expr(scf_parse_t* parse, dfa_parse_data_t* d, int semi_fla d->expr = d->expr->parent; if (0 == d->expr->nb_nodes) { - scf_loge("d->expr: %p\n", d->expr); scf_expr_free(d->expr); d->expr = NULL; @@ -778,7 +777,7 @@ static int _expr_fini_expr(scf_parse_t* parse, dfa_parse_data_t* d, int semi_fla scf_node_add_child(parent, d->expr); - scf_loge("d->expr->parent->type: %d\n", d->expr->parent->type); + scf_logd("d->expr->parent->type: %d\n", d->expr->parent->type); if (_expr_multi_rets(d->expr) < 0) { scf_loge("\n"); @@ -789,7 +788,7 @@ static int _expr_fini_expr(scf_parse_t* parse, dfa_parse_data_t* d, int semi_fla d->expr = NULL; } - scf_loge("d->expr: %p, d->expr_local_flag: %d\n", d->expr, d->expr_local_flag); + scf_logd("d->expr: %p, d->expr_local_flag: %d\n", d->expr, d->expr_local_flag); } return SCF_DFA_OK; diff --git a/parse/scf_dfa_function.c b/parse/scf_dfa_function.c index 33076e4..916edba 100644 --- a/parse/scf_dfa_function.c +++ b/parse/scf_dfa_function.c @@ -42,8 +42,7 @@ int _function_add_function(scf_dfa_t* dfa, dfa_parse_data_t* d) free(id); id = NULL; - scf_logi("function: %s,line:%d,pos:%d, member_flag: %d\n", - f->node.w->text->data, f->node.w->line, f->node.w->pos, f->member_flag); + scf_logi("function: %s,line:%d, member_flag: %d\n", f->node.w->text->data, f->node.w->line, f->member_flag); int void_flag = 0; @@ -171,8 +170,6 @@ static int _function_action_vargs(scf_dfa_t* dfa, scf_vector_t* words, void* dat d->current_function->vargs_flag = 1; - scf_logw("\n"); - return SCF_DFA_NEXT_WORD; } @@ -348,7 +345,6 @@ static int _function_action_end(scf_dfa_t* dfa, scf_vector_t* words, void* data) d->nb_lps = 0; d->nb_rps = 0; - scf_logi("\n"); return SCF_DFA_OK; } diff --git a/parse/scf_dfa_type.c b/parse/scf_dfa_type.c index ba4804d..a008929 100644 --- a/parse/scf_dfa_type.c +++ b/parse/scf_dfa_type.c @@ -309,7 +309,7 @@ static int _dfa_init_syntax_type(scf_dfa_t* dfa) for (i = 0; i < base_type->childs->size; i++) { scf_dfa_node_t* n = base_type->childs->data[i]; - scf_logw("n->name: %s\n", n->name); + scf_logd("n->name: %s\n", n->name); } scf_logi("\n"); diff --git a/parse/scf_parse.c b/parse/scf_parse.c index 87b97a0..708dd2d 100644 --- a/parse/scf_parse.c +++ b/parse/scf_parse.c @@ -187,18 +187,17 @@ int scf_parse_file(scf_parse_t* parse, const char* path) int ret = scf_lex_pop_word(parse->lex, &w); if (ret < 0) { scf_loge("lex pop word failed\n"); - return -1; + return ret; } if (SCF_LEX_WORD_EOF == w->type) { - scf_logi("eof\n"); + scf_logi("eof\n\n"); scf_lex_push_word(parse->lex, w); w = NULL; break; } if (SCF_LEX_WORD_SPACE == w->type) { - scf_loge("lex word space\n"); scf_lex_word_free(w); w = NULL; continue; @@ -309,7 +308,7 @@ static int __debug_add_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev_decla return -1; } - scf_loge("abbrevs->size: %d\n", parse->debug->abbrevs->size); + scf_logd("abbrevs->size: %d\n", parse->debug->abbrevs->size); d = parse->debug->abbrevs->data[parse->debug->abbrevs->size - 1]; } @@ -326,7 +325,7 @@ static int __debug_add_type(scf_dwarf_info_entry_t** pie, scf_dwarf_abbrev_decla return -1; } - scf_loge("abbrevs->size: %d\n", parse->debug->abbrevs->size); + scf_logd("abbrevs->size: %d\n", parse->debug->abbrevs->size); d = parse->debug->abbrevs->data[parse->debug->abbrevs->size - 1]; } @@ -1084,16 +1083,16 @@ static int _debug_add_subprogram(scf_dwarf_info_entry_t** pie, scf_parse_t* pars return ret; } else if (DW_AT_decl_file == iattr->name) { - scf_loge("f->node.w->file->data: %s\n", f->node.w->file->data); + scf_logd("f->node.w->file->data: %s\n", f->node.w->file->data); scf_string_t* s; int k; - scf_loge("parse->debug->file_names->size: %d\n", parse->debug->file_names->size); + scf_logd("parse->debug->file_names->size: %d\n", parse->debug->file_names->size); for (k = 0; k < parse->debug->file_names->size; k++) { s = parse->debug->file_names->data[k]; - scf_loge("s->data: %s\n", s->data); + scf_logd("s->data: %s\n", s->data); if (!strcmp(s->data, f->node.w->file->data)) break; @@ -1858,8 +1857,8 @@ int scf_parse_compile_functions(scf_parse_t* parse, scf_vector_t* functions) for (i = 0; i < functions->size; i++) { f = functions->data[i]; - scf_logi("i: %d, f: %p, fname: %s, f->argv->size: %d, f->node.define_flag: %d, inline_flag: %d\n", - i, f, f->node.w->text->data, f->argv->size, f->node.define_flag, f->inline_flag); + scf_logi("i: %d, fname: %s, f->argv->size: %d, f->node.define_flag: %d, inline_flag: %d\n", + i, f->node.w->text->data, f->argv->size, f->node.define_flag, f->inline_flag); if (!f->node.define_flag) continue; @@ -2176,7 +2175,7 @@ int scf_parse_compile(scf_parse_t* parse, const char* out, const char* arch, int goto code_error; } - scf_logi("all global_vars: %d\n", global_vars->size); + scf_logd("all global_vars: %d\n", global_vars->size); parse->debug->arch = (char*)arch; -- 2.25.1