Use UCLOG and fix uc_afl_fuzz

This commit is contained in:
lazymio
2021-10-25 10:46:52 +02:00
parent 17963ff4aa
commit d965c0f159
5 changed files with 78 additions and 60 deletions

View File

@ -1655,7 +1655,7 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
def = &s->tcg_op_defs[c];
if (c == INDEX_op_insn_start) {
nb_oargs = 0;
printf(" ----");
UCLOG(" ----");
for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {
target_ulong a;
@ -1664,7 +1664,7 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
#else
a = op->args[i];
#endif
printf(" " TARGET_FMT_lx, a);
UCLOG(" " TARGET_FMT_lx, a);
}
} else if (c == INDEX_op_call) {
/* variable number of arguments */
@ -1673,11 +1673,11 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
nb_cargs = def->nb_cargs;
/* function name, flags, out args */
printf(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name,
UCLOG(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name,
tcg_find_helper(s, op->args[nb_oargs + nb_iargs]),
op->args[nb_oargs + nb_iargs + 1], nb_oargs);
for (i = 0; i < nb_oargs; i++) {
printf(",%s", tcg_get_arg_str(s, buf, sizeof(buf),
UCLOG(",%s", tcg_get_arg_str(s, buf, sizeof(buf),
op->args[i]));
}
for (i = 0; i < nb_iargs; i++) {
@ -1686,33 +1686,33 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
if (arg != TCG_CALL_DUMMY_ARG) {
t = tcg_get_arg_str(s, buf, sizeof(buf), arg);
}
printf(",%s", t);
UCLOG(",%s", t);
}
} else {
printf(" %s ", def->name);
UCLOG(" %s ", def->name);
nb_oargs = def->nb_oargs;
nb_iargs = def->nb_iargs;
nb_cargs = def->nb_cargs;
if (def->flags & TCG_OPF_VECTOR) {
printf("v%d,e%d,", 64 << TCGOP_VECL(op),
UCLOG("v%d,e%d,", 64 << TCGOP_VECL(op),
8 << TCGOP_VECE(op));
}
k = 0;
for (i = 0; i < nb_oargs; i++) {
if (k != 0) {
printf(",");
UCLOG(",");
}
printf("%s", tcg_get_arg_str(s, buf, sizeof(buf),
UCLOG("%s", tcg_get_arg_str(s, buf, sizeof(buf),
op->args[k++]));
}
for (i = 0; i < nb_iargs; i++) {
if (k != 0) {
printf(",");
UCLOG(",");
}
printf("%s", tcg_get_arg_str(s, buf, sizeof(buf),
UCLOG("%s", tcg_get_arg_str(s, buf, sizeof(buf),
op->args[k++]));
}
switch (c) {
@ -1728,9 +1728,9 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
case INDEX_op_cmpsel_vec:
if (op->args[k] < ARRAY_SIZE(cond_name)
&& cond_name[op->args[k]]) {
printf(",%s", cond_name[op->args[k++]]);
UCLOG(",%s", cond_name[op->args[k++]]);
} else {
printf(",$0x%" TCG_PRIlx, op->args[k++]);
UCLOG(",$0x%" TCG_PRIlx, op->args[k++]);
}
i = 1;
break;
@ -1744,12 +1744,12 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
unsigned ix = get_mmuidx(oi);
if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) {
printf(",$0x%x,%u", op, ix);
UCLOG(",$0x%x,%u", op, ix);
} else {
const char *s_al, *s_op;
s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT];
s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)];
printf(",%s%s,%u", s_al, s_op, ix);
UCLOG(",%s%s,%u", s_al, s_op, ix);
}
i = 1;
}
@ -1764,7 +1764,7 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
case INDEX_op_brcond_i32:
case INDEX_op_brcond_i64:
case INDEX_op_brcond2_i32:
printf("%s$L%d", k ? "," : "",
UCLOG("%s$L%d", k ? "," : "",
arg_label(op->args[k])->id);
i++, k++;
break;
@ -1772,12 +1772,12 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
break;
}
for (; i < nb_cargs; i++, k++) {
printf("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]);
UCLOG("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]);
}
if(c == INDEX_op_mov_i64){
struct TCGTemp* tp = arg_temp(op->args[1]);
if (tp && tp->val_type == TEMP_VAL_MEM){
printf(" mem_base=%p ", tp->mem_base);
UCLOG(" mem_base=%p ", tp->mem_base);
}
}
}
@ -1786,19 +1786,19 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
unsigned life = op->life;
if (life & (SYNC_ARG * 3)) {
printf(" sync:");
UCLOG(" sync:");
for (i = 0; i < 2; ++i) {
if (life & (SYNC_ARG << i)) {
printf(" %d", i);
UCLOG(" %d", i);
}
}
}
life /= DEAD_ARG;
if (life) {
printf(" dead:");
UCLOG(" dead:");
for (i = 0; life; ++i, life >>= 1) {
if (life & 1) {
printf(" %d", i);
UCLOG(" %d", i);
}
}
}
@ -1809,28 +1809,28 @@ void tcg_dump_op(TCGContext *s, bool have_prefs, TCGOp* op)
TCGRegSet set = op->output_pref[i];
if (i == 0) {
printf(" pref=");
UCLOG(" pref=");
} else {
printf(",");
UCLOG(",");
}
if (set == 0) {
printf("none");
UCLOG("none");
} else if (set == MAKE_64BIT_MASK(0, TCG_TARGET_NB_REGS)) {
printf("all");
UCLOG("all");
#ifdef CONFIG_DEBUG_TCG
} else if (tcg_regset_single(set)) {
TCGReg reg = tcg_regset_first(set);
printf("%s", tcg_target_reg_names[reg]);
#endif
} else if (TCG_TARGET_NB_REGS <= 32) {
printf("%#x", (uint32_t)set);
UCLOG("%#x", (uint32_t)set);
} else {
printf("%#" PRIx64, (uint64_t)set);
UCLOG("%#" PRIx64, (uint64_t)set);
}
}
}
printf("\n");
UCLOG("\n");
}
#if 0
@ -1863,16 +1863,16 @@ void tcg_dump_ops(TCGContext *s, bool have_prefs, const char *headline)
int insn_idx = 0;
int op_idx = 0;
printf("\n*** %s\n", headline);
UCLOG("\n*** %s\n", headline);
// tcg_dump_tbs(s, tcg_dump_tb, NULL);
QTAILQ_FOREACH(op, &s->ops, link) {
if (op->opc == INDEX_op_insn_start) {
printf("\n insn_idx=%d", insn_idx);
UCLOG("\n insn_idx=%d", insn_idx);
insn_idx++;
op_idx = 0;
} else {
printf(" %d: ", op_idx);
UCLOG(" %d: ", op_idx);
}
op_idx++;
tcg_dump_op(s, have_prefs, op);