mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 13:25:31 +00:00
tcg: Include liveness info in the dumps
Backports commit bdfb460ef77500f7b186759b585f06ff2120929d from qemu
This commit is contained in:
parent
e973e89a57
commit
2aa46dd9a1
|
@ -10,11 +10,6 @@
|
||||||
extern FILE *qemu_logfile;
|
extern FILE *qemu_logfile;
|
||||||
extern int qemu_loglevel;
|
extern int qemu_loglevel;
|
||||||
|
|
||||||
/*
|
|
||||||
* The new API:
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Log settings checking macros: */
|
/* Log settings checking macros: */
|
||||||
|
|
||||||
/* Returns true if qemu_log() will really write somewhere
|
/* Returns true if qemu_log() will really write somewhere
|
||||||
|
@ -50,7 +45,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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,15 +24,22 @@
|
||||||
FILE *qemu_logfile;
|
FILE *qemu_logfile;
|
||||||
int qemu_loglevel;
|
int qemu_loglevel;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fflush() the log file */
|
/* fflush() the log file */
|
||||||
|
|
|
@ -1071,6 +1071,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;
|
||||||
|
@ -1078,7 +1079,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;
|
||||||
|
@ -1088,7 +1089,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 */
|
||||||
|
@ -1097,12 +1098,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];
|
||||||
|
@ -1110,10 +1111,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;
|
||||||
|
@ -1122,17 +1123,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:
|
||||||
|
@ -1144,9 +1145,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;
|
||||||
|
@ -1160,12 +1161,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;
|
||||||
}
|
}
|
||||||
|
@ -1180,14 +1181,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(s, args[k])->id);
|
col += qemu_log("%s$L%d", k ? "," : "", arg_label(s, 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");
|
||||||
|
|
Loading…
Reference in a new issue