qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>
Subject: Re: [RFC PATCH] translate-all: include guest address in out_asm output
Date: Fri, 24 Apr 2020 12:38:25 -0700	[thread overview]
Message-ID: <6b8a6ab1-d093-d54c-17ed-5221458c36df@linaro.org> (raw)
In-Reply-To: <20200424173914.2957-1-alex.bennee@linaro.org>

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	other threads:[~2020-04-24 19:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 17:39 [RFC PATCH] translate-all: include guest address in out_asm output Alex Bennée
2020-04-24 19:38 ` Richard Henderson [this message]
2020-04-24 20:10 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6b8a6ab1-d093-d54c-17ed-5221458c36df@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).