qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Smolov <smolov@ispras.ru>
To: Yongbok Kim <yongbok.kim@imgtec.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] MIPS 'move' insn emulation
Date: Thu, 14 Sep 2017 16:49:05 +0300	[thread overview]
Message-ID: <59BA88D1.9080202@ispras.ru> (raw)
In-Reply-To: <0c3db1e3-1638-cfbe-8c97-0d1aa87547b0@imgtec.com>


On 13.09.2017 17:20, Yongbok Kim wrote:
> (Especially while implementing new instructions), I tended to add couple of
> helper functions for tracing temporally.
>
> op_helper.c:
> void helper_trace_reg_access(CPUMIPSState *env, target_ulong val)
> {
>      printf("reg = "TARGET_FMT_lx"\n", val);
> }
>
> helper.h:
> DEF_HELPER_2(trace_reg_access, void, env, tl)
>
> After this you could use the helper function where you want to trace the
> register value.
> For your case, you can add following line after the tcg_gen_mov_tl().
> gen_helper_trace_reg_access(cpu_env, cpu_gpr[rs]);
>
> You will get the printf every time the part of code is being executed
> (which might be too often).
>
> Regards,
> Yongbok

Thanks, Yongbok!

I've implemented the code you've written. Now I receive values are 
written into MIPS registers.

Could you explain some aspects about the code you propose?

First, what is the helper function itself? Peter said that it is 
impossible to get the value that is written to MIPS register at 
"translation time", but in "run time" there is no mapping between x86 
and "virtual MIPS" registers. So how it is possible to get these values?:-)

Second, I need to make a final modification of helper function. I need 
to print both "val" that is written to GPR register and the number "num" 
of the register. I wrote the following:

op_helper.c:
void helper_trace_reg_access(CPUMIPSState *env, int reg, target_ulong val)
{
qemu_log("r%d = "TARGET_FMT_lx"\n", reg, val);
}

helper.h:
DEF_HELPER_3(trace_reg_access, void, env, int, tl)

and call the function in translate.c like:

gen_helper_trace_reg_access(cpu_env, rd, cpu_gpr[rs]);

But when I compile the QEMU, i get this:
In function ‘gen_logic’:
target/mips/translate.c:2913:13: warning: passing argument 2 of 
‘gen_helper_trace_reg_access’ makes pointer from integer without a cast 
[enabled by default]

What am I missing here?

-- 
Sincerely yours,
Sergey Smolov

  reply	other threads:[~2017-09-14 13:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-12 14:14 [Qemu-devel] MIPS 'move' insn emulation Sergey Smolov
2017-09-12 14:32 ` Peter Maydell
2017-09-12 14:53   ` Sergey Smolov
2017-09-12 15:06     ` Peter Maydell
2017-09-13  7:29       ` Sergey Smolov
2017-09-13 11:01         ` Peter Maydell
2017-09-13 14:20           ` Yongbok Kim
2017-09-14 13:49             ` Sergey Smolov [this message]
2017-09-14 13:58               ` Peter Maydell
2017-09-14 14:16                 ` Sergey Smolov
2017-09-14 14:23                   ` Yongbok Kim
2017-09-14 14:29                     ` Peter Maydell
2017-09-14 16:32                     ` Sergey Smolov

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=59BA88D1.9080202@ispras.ru \
    --to=smolov@ispras.ru \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=yongbok.kim@imgtec.com \
    /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).