tcg: Include liveness info in the dumps

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Richard Henderson 2016-06-23 19:15:55 -07:00
parent c70fbf0a99
commit bdfb460ef7
3 changed files with 61 additions and 28 deletions

View File

@ -54,7 +54,7 @@ static inline bool qemu_loglevel_mask(int mask)
/* main logging function /* main logging function
*/ */
void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
/* vfprintf-like logging function /* vfprintf-like logging function
*/ */

View File

@ -1026,6 +1026,7 @@ void tcg_dump_ops(TCGContext *s)
const TCGOpDef *def; const TCGOpDef *def;
const TCGArg *args; const TCGArg *args;
TCGOpcode c; TCGOpcode c;
int col = 0;
op = &s->gen_op_buf[oi]; op = &s->gen_op_buf[oi];
c = op->opc; c = op->opc;
@ -1033,7 +1034,7 @@ void tcg_dump_ops(TCGContext *s)
args = &s->gen_opparam_buf[op->args]; args = &s->gen_opparam_buf[op->args];
if (c == INDEX_op_insn_start) { if (c == INDEX_op_insn_start) {
qemu_log("%s ----", oi != s->gen_op_buf[0].next ? "\n" : ""); col += qemu_log("%s ----", oi != s->gen_op_buf[0].next ? "\n" : "");
for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { for (i = 0; i < TARGET_INSN_START_WORDS; ++i) {
target_ulong a; target_ulong a;
@ -1042,7 +1043,7 @@ void tcg_dump_ops(TCGContext *s)
#else #else
a = args[i]; a = args[i];
#endif #endif
qemu_log(" " TARGET_FMT_lx, a); col += qemu_log(" " TARGET_FMT_lx, a);
} }
} else if (c == INDEX_op_call) { } else if (c == INDEX_op_call) {
/* variable number of arguments */ /* variable number of arguments */
@ -1051,12 +1052,12 @@ void tcg_dump_ops(TCGContext *s)
nb_cargs = def->nb_cargs; nb_cargs = def->nb_cargs;
/* function name, flags, out args */ /* function name, flags, out args */
qemu_log(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name, col += qemu_log(" %s %s,$0x%" TCG_PRIlx ",$%d", def->name,
tcg_find_helper(s, args[nb_oargs + nb_iargs]), tcg_find_helper(s, args[nb_oargs + nb_iargs]),
args[nb_oargs + nb_iargs + 1], nb_oargs); args[nb_oargs + nb_iargs + 1], nb_oargs);
for (i = 0; i < nb_oargs; i++) { for (i = 0; i < nb_oargs; i++) {
qemu_log(",%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), col += qemu_log(",%s", tcg_get_arg_str_idx(s, buf, sizeof(buf),
args[i])); args[i]));
} }
for (i = 0; i < nb_iargs; i++) { for (i = 0; i < nb_iargs; i++) {
TCGArg arg = args[nb_oargs + i]; TCGArg arg = args[nb_oargs + i];
@ -1064,10 +1065,10 @@ void tcg_dump_ops(TCGContext *s)
if (arg != TCG_CALL_DUMMY_ARG) { if (arg != TCG_CALL_DUMMY_ARG) {
t = tcg_get_arg_str_idx(s, buf, sizeof(buf), arg); t = tcg_get_arg_str_idx(s, buf, sizeof(buf), arg);
} }
qemu_log(",%s", t); col += qemu_log(",%s", t);
} }
} else { } else {
qemu_log(" %s ", def->name); col += qemu_log(" %s ", def->name);
nb_oargs = def->nb_oargs; nb_oargs = def->nb_oargs;
nb_iargs = def->nb_iargs; nb_iargs = def->nb_iargs;
@ -1076,17 +1077,17 @@ void tcg_dump_ops(TCGContext *s)
k = 0; k = 0;
for (i = 0; i < nb_oargs; i++) { for (i = 0; i < nb_oargs; i++) {
if (k != 0) { if (k != 0) {
qemu_log(","); col += qemu_log(",");
} }
qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), col += qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf),
args[k++])); args[k++]));
} }
for (i = 0; i < nb_iargs; i++) { for (i = 0; i < nb_iargs; i++) {
if (k != 0) { if (k != 0) {
qemu_log(","); col += qemu_log(",");
} }
qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf), col += qemu_log("%s", tcg_get_arg_str_idx(s, buf, sizeof(buf),
args[k++])); args[k++]));
} }
switch (c) { switch (c) {
case INDEX_op_brcond_i32: case INDEX_op_brcond_i32:
@ -1098,9 +1099,9 @@ void tcg_dump_ops(TCGContext *s)
case INDEX_op_setcond_i64: case INDEX_op_setcond_i64:
case INDEX_op_movcond_i64: case INDEX_op_movcond_i64:
if (args[k] < ARRAY_SIZE(cond_name) && cond_name[args[k]]) { if (args[k] < ARRAY_SIZE(cond_name) && cond_name[args[k]]) {
qemu_log(",%s", cond_name[args[k++]]); col += qemu_log(",%s", cond_name[args[k++]]);
} else { } else {
qemu_log(",$0x%" TCG_PRIlx, args[k++]); col += qemu_log(",$0x%" TCG_PRIlx, args[k++]);
} }
i = 1; i = 1;
break; break;
@ -1114,12 +1115,12 @@ void tcg_dump_ops(TCGContext *s)
unsigned ix = get_mmuidx(oi); unsigned ix = get_mmuidx(oi);
if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) { if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) {
qemu_log(",$0x%x,%u", op, ix); col += qemu_log(",$0x%x,%u", op, ix);
} else { } else {
const char *s_al, *s_op; const char *s_al, *s_op;
s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT]; s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT];
s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)]; s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)];
qemu_log(",%s%s,%u", s_al, s_op, ix); col += qemu_log(",%s%s,%u", s_al, s_op, ix);
} }
i = 1; i = 1;
} }
@ -1134,14 +1135,39 @@ void tcg_dump_ops(TCGContext *s)
case INDEX_op_brcond_i32: case INDEX_op_brcond_i32:
case INDEX_op_brcond_i64: case INDEX_op_brcond_i64:
case INDEX_op_brcond2_i32: case INDEX_op_brcond2_i32:
qemu_log("%s$L%d", k ? "," : "", arg_label(args[k])->id); col += qemu_log("%s$L%d", k ? "," : "", arg_label(args[k])->id);
i++, k++; i++, k++;
break; break;
default: default:
break; break;
} }
for (; i < nb_cargs; i++, k++) { for (; i < nb_cargs; i++, k++) {
qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", args[k]); col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", args[k]);
}
}
if (op->life) {
unsigned life = op->life;
for (; col < 48; ++col) {
putc(' ', qemu_logfile);
}
if (life & (SYNC_ARG * 3)) {
qemu_log(" sync:");
for (i = 0; i < 2; ++i) {
if (life & (SYNC_ARG << i)) {
qemu_log(" %d", i);
}
}
}
life /= DEAD_ARG;
if (life) {
qemu_log(" dead:");
for (i = 0; life; ++i, life >>= 1) {
if (life & 1) {
qemu_log(" %d", i);
}
}
} }
} }
qemu_log("\n"); qemu_log("\n");

View File

@ -32,15 +32,22 @@ int qemu_loglevel;
static int log_append = 0; static int log_append = 0;
static GArray *debug_regions; static GArray *debug_regions;
void qemu_log(const char *fmt, ...) /* Return the number of characters emitted. */
int qemu_log(const char *fmt, ...)
{ {
va_list ap; int ret = 0;
va_start(ap, fmt);
if (qemu_logfile) { if (qemu_logfile) {
vfprintf(qemu_logfile, fmt, ap); va_list ap;
va_start(ap, fmt);
ret = vfprintf(qemu_logfile, fmt, ap);
va_end(ap);
/* Don't pass back error results. */
if (ret < 0) {
ret = 0;
}
} }
va_end(ap); return ret;
} }
static bool log_uses_own_buffers; static bool log_uses_own_buffers;