qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] When are register values committed to CPUARMState
@ 2014-03-31 17:59 Gaurav Sharma
  2014-03-31 18:05 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Gaurav Sharma @ 2014-03-31 17:59 UTC (permalink / raw)
  To: QEMU-DEVEL

[-- Attachment #1: Type: text/plain, Size: 718 bytes --]

I am trying to build a register trace for ARM target.
I am trying to just log the register values, for that I added TCG ops to
generate a helper function that dumps the register values in CPUARMState.
This helper function i have called at the end of disas_arm_state function,
so that if enabled i get a trace for each instruction.
However, the register values that are dumped do not seem to be correct, it
always the register at the 0th index that seems to have any value, even
though the disassembly indicates otherwise.
I want to know, when are the register values committed to  CPUARMState
structure ?

Is there any way , i could find out the register values that have changed
for any instruction ?

Thanks,
Gaurav

[-- Attachment #2: Type: text/html, Size: 847 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] When are register values committed to CPUARMState
  2014-03-31 17:59 [Qemu-devel] When are register values committed to CPUARMState Gaurav Sharma
@ 2014-03-31 18:05 ` Peter Maydell
       [not found]   ` <CABiB5K6F9hrJ9mhmxDCNv+txt40s=P-gk8AEHUUjnsaGOcyNbg@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2014-03-31 18:05 UTC (permalink / raw)
  To: Gaurav Sharma; +Cc: QEMU-DEVEL

On 31 March 2014 18:59, Gaurav Sharma <gauravs.2010@gmail.com> wrote:
> I am trying to build a register trace for ARM target.
> I am trying to just log the register values, for that I added TCG ops to
> generate a helper function that dumps the register values in CPUARMState.
> This helper function i have called at the end of disas_arm_state function,
> so that if enabled i get a trace for each instruction.
> However, the register values that are dumped do not seem to be correct, it
> always the register at the 0th index that seems to have any value, even
> though the disassembly indicates otherwise.
> I want to know, when are the register values committed to  CPUARMState
> structure ?

When they need to be. Mostly we keep register values in TCG
globals, which means they're held in host registers except
when calling helpers which might read or write globals, or
for doing guest memory accesses, or at branches. Thumb
condexec bits (in the CPSR) are only written back at the
point where we leave a translation block. The PC is a special
case which we don't update very often at all.

> Is there any way , i could find out the register values that
> have changed for any instruction ?

Not conveniently. We optimise for speed of execution, not
for transparency of what is happening to the guest CPU.
(It can be done, and people have done it, but none of this
support is upstream, because it's usually a lot of local
and special-purpose hacks.)

You might consider just connecting to the gdbstub and
singlestepping the CPU and using the gdbstub protocol
to read register values.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] When are register values committed to CPUARMState
       [not found]   ` <CABiB5K6F9hrJ9mhmxDCNv+txt40s=P-gk8AEHUUjnsaGOcyNbg@mail.gmail.com>
@ 2014-03-31 19:17     ` Peter Maydell
  2014-04-01  6:08       ` Gaurav Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2014-03-31 19:17 UTC (permalink / raw)
  To: Gaurav Sharma, QEMU Developers

[put qemu-devel back on CC]
On 31 March 2014 20:13, Gaurav Sharma <gauravs.2010@gmail.com> wrote:
> On Mon, Mar 31, 2014 at 11:35 PM, Peter Maydell <peter.maydell@linaro.org>
> wrote:
>> On 31 March 2014 18:59, Gaurav Sharma <gauravs.2010@gmail.com> wrote:
>> > I want to know, when are the register values committed to  CPUARMState
>> > structure ?
>>
>> When they need to be. Mostly we keep register values in TCG
>> globals,
>
>    >> By TCG globals here do we mean, cpu_R[] array, because if i see the
> code for a simple add, i can see source and destination values for the TCG
> ops being this array? In the init function isn't this array mapped on to
> CPUARMState ?

Yes, but...

>> which means they're held in host registers except
>> when calling helpers which might read or write globals

...as I say TCG is free to keep globals in host registers
a lot of the time and only writes values back to the
CPUARMState when it needs to.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] When are register values committed to CPUARMState
  2014-03-31 19:17     ` Peter Maydell
@ 2014-04-01  6:08       ` Gaurav Sharma
  0 siblings, 0 replies; 4+ messages in thread
From: Gaurav Sharma @ 2014-04-01  6:08 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]

Seems, I am bit confused. So if i have to dump the target cpu registers,
where would be the corresponding code to look into


On Tue, Apr 1, 2014 at 12:47 AM, Peter Maydell <peter.maydell@linaro.org>wrote:

> [put qemu-devel back on CC]
> On 31 March 2014 20:13, Gaurav Sharma <gauravs.2010@gmail.com> wrote:
> > On Mon, Mar 31, 2014 at 11:35 PM, Peter Maydell <
> peter.maydell@linaro.org>
> > wrote:
> >> On 31 March 2014 18:59, Gaurav Sharma <gauravs.2010@gmail.com> wrote:
> >> > I want to know, when are the register values committed to  CPUARMState
> >> > structure ?
> >>
> >> When they need to be. Mostly we keep register values in TCG
> >> globals,
> >
> >    >> By TCG globals here do we mean, cpu_R[] array, because if i see the
> > code for a simple add, i can see source and destination values for the
> TCG
> > ops being this array? In the init function isn't this array mapped on to
> > CPUARMState ?
>
> Yes, but...
>
> >> which means they're held in host registers except
> >> when calling helpers which might read or write globals
>
> ...as I say TCG is free to keep globals in host registers
> a lot of the time and only writes values back to the
> CPUARMState when it needs to.
>
> thanks
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 1911 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-01  6:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 17:59 [Qemu-devel] When are register values committed to CPUARMState Gaurav Sharma
2014-03-31 18:05 ` Peter Maydell
     [not found]   ` <CABiB5K6F9hrJ9mhmxDCNv+txt40s=P-gk8AEHUUjnsaGOcyNbg@mail.gmail.com>
2014-03-31 19:17     ` Peter Maydell
2014-04-01  6:08       ` Gaurav Sharma

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).