On 4/24/20 10:39 AM, Alex Bennée wrote:
> +        /* first dump prologue */
> +        insn_start = tcg_ctx->gen_insn_end_off[0];
> +        if (insn_start > 0) {
> +            qemu_log("  prologue: [size=%ld]\n", insn_start);
> +            log_disas(tb->tc.ptr, insn_start);
> +        }
> +
> +        do {
> +            size_t insn_end;
> +            if (insn < (tb->icount - 1)) {
> +                insn_end = tcg_ctx->gen_insn_end_off[insn + 1];
> +            } else {
> +                insn_end = code_size;
> +            }
> +            qemu_log("  for guest addr: " TARGET_FMT_lx ":\n",
> +                     tcg_ctx->gen_insn_data[insn][0]);

The one thing you're missing here is when a given guest insn emits no host
insns.  E.g. an actual guest nop, or if two guest insns are optimized together.

So you need to search forward through empty insns til you find one that has
contents.  E.g. the very first TB that alpha-softmmu executes in its bios:

OP after optimization and liveness analysis:
 ld_i32 tmp0,env,$0xfffffffffffffff0      dead: 1  pref=0xffff
 movi_i32 tmp1,$0x0                       pref=0xffff
 brcond_i32 tmp0,tmp1,lt,$L0              dead: 0 1

 ---- fffffc0000000000

 ---- fffffc0000000004

 ---- fffffc0000000008
 movi_i64 gp,$0xfffffc0000012f50          sync: 0  pref=0xffff



OUT: [size=280]
  prologue: [size=11]
0x7fffa0000100:  8b 5d f0                 movl     -0x10(%rbp), %ebx
0x7fffa0000103:  85 db                    testl    %ebx, %ebx
0x7fffa0000105:  0f 8c d6 00 00 00        jl       0x7fffa00001e1
  for guest addr: fffffc0000000000:
  for guest addr: fffffc0000000004:
0x7fffa000010b:  48 bb 50 2f 01 00 00 fc  movabsq  $0xfffffc0000012f50, %rbx
0x7fffa0000113:  ff ff
0x7fffa0000115:  48 89 9d e8 00 00 00     movq     %rbx, 0xe8(%rbp)
  for guest addr: fffffc0000000008:

So you've attributed to ...04 what actually belongs to ...08.


But it's a good idea.


r~

Reply via email to