close some unused logs
authoryu.dongliang <18588496441@163.com>
Thu, 9 May 2024 13:12:22 +0000 (21:12 +0800)
committeryu.dongliang <18588496441@163.com>
Thu, 9 May 2024 13:12:22 +0000 (21:12 +0800)
24 files changed:
core/scf_ast.c
core/scf_function.c
elf/scf_dwarf_abbrev.c
elf/scf_dwarf_line.c
elf/scf_elf_link.c
elf/scf_elf_native.c
elf/scf_elf_x64.c
elf/scf_elf_x64_so.c
native/eda/scf_eda_pack.c
native/eda/scf_eda_pack.h
native/x64/scf_x64.c
native/x64/scf_x64_bb_color.c
native/x64/scf_x64_graph.c
native/x64/scf_x64_inst.c
native/x64/scf_x64_inst_common.c
native/x64/scf_x64_inst_util.c
native/x64/scf_x64_peephole.c
native/x64/scf_x64_reg.c
parse/main.c
parse/scf_dfa_block.c
parse/scf_dfa_expr.c
parse/scf_dfa_function.c
parse/scf_dfa_type.c
parse/scf_parse.c

index f3026d7e7c30518ec0e18df6cea72fa8843bdba3..4f19ee4e091e3f43ebffefb6078471cbb3e4214c 100644 (file)
@@ -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;
 }
index 16a1611fe68521ebc61dbaff7e789d36a32492fa..eab70b61ca28dbe9db1c43c16a6ec90fce0f73f5 100644 (file)
@@ -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;
index 1cb56d2b83a0488dc1153fe8b528b9c02e4a8dff..5a44e5c25e78e493e4579c3dedb47ae15ac143a1 100644 (file)
@@ -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++) {
index 0bd4fb37871ecbab2e9505fe43a51fcc7f488ce0..a59ec108570659111937f869a8b42f66b593cc0f 100644 (file)
@@ -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;
 }
index fefaf775c3de33b1bdbeba36bf670ff2fa790265..15a999a2cb66045784857a434caa789dcec1856f 100644 (file)
@@ -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;
index 3a32ffeeb3d369ffa01ac87b67bac414b19328ef..a4187daecf35448b1967e2896fde6f82510f37e4 100644 (file)
@@ -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));
 
index eec6161dc37c2852e9aa38c266843724cdefb403..41e69451e1308cc4145943bdc00b939863ae88c6 100644 (file)
@@ -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));
 
index 8fa0ec8faca8c7bfcb160e8194f706889f33da43..b4685601256cb3bf2a768603af3cc968bed2d128 100644 (file)
@@ -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;
 
index 8d3988b3fe343cca00d469db86fe7dcc341c480b..c837e73ea6eef4f4a91304d96a02833643aaf3bc 100644 (file)
@@ -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},
index 2cf8303057c0e89cde1d11771e952ad9d2d5b736..1f48b4cfd256374096f68a4d9ec0bbb75d1b9387 100644 (file)
@@ -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),
index 937c847bf3e97f7f27df66be5adb64aa47ac4337..8ff7f3c56b3c6a6b3a62e4573c344a37058ebe8f 100644 (file)
@@ -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);
        }
index fb04a078d7cea0dbe70649b7e1c83a3841843203..af2055bede1608f8624e393c54b083622ec756f8 100644 (file)
@@ -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");
                }
        }
 }
index 1a604afe1f7da86f5498804b236ffd303a98738a..aebd3cde6f8a7edc6a66b4b74868c50858148352 100644 (file)
@@ -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;
 }
index 985f753facd12f5d547361274de71a3fded4e7bf..690a0a4b5a214b3d2c9c2d7d9ee994b603a988ba 100644 (file)
@@ -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;
index cd113905072300a35b8a0fdfb59811ac2547a5a7..c5df00fc15a4cd0c4c15fed82b8debce9ba7a5b7 100644 (file)
@@ -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;
        }
index 995fa3a69bcd4030ed20419012f13219dfa8286d..81616050fb7bb4364aef8360c9f3ba8ebe3258cd 100644 (file)
@@ -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;
        }
 
index 82b9b4b93b73a13d8a872a27d784d06537acd2ab..784fefd5299ecdd13d76322b09a710fe1b2303c4 100644 (file)
@@ -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);
index 85e08b9dea1341470e92a88711d506a1133c3960..7c0a97ce6fd59df12aad840d36768beddc6d5a89 100644 (file)
@@ -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)
index 753e5b1451a2866d5c341e49aa7433ff02bacdac..2ef02fbe3f45d2fee15328201b3d843402fbd769 100644 (file)
@@ -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) {
index 3158ee2d670f6c1bce762c447340a88b67fedba5..2ed9bc18bece8529250a107346d07509c5514654 100644 (file)
@@ -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;
index a4918c14278e357c2dab5b1d07133cf67656f108..85ce9aa05838c113879f5b8463210974f7a6a334 100644 (file)
@@ -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;
index 33076e4b24bd9454df5bdaf9352b3a438280b31f..916edba3b85cbb353f0a5d13370bb2ccd32f547d 100644 (file)
@@ -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;
 }
 
index ba4804d881571b811b792d43c0b426d556afbcf4..a008929db66ccc3cb232a6513659a10db425e8c9 100644 (file)
@@ -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");
index 87b97a07e236e13bfda9333b457a0a0c9ee8abfe..708dd2de8db56870fa90f929dccd903a7525ca9c 100644 (file)
@@ -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;