Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* xtensa: reading privileged special registers
@ 2011-07-17 20:29 Max Filippov
  2011-07-18  1:12 ` Maxim Grigoriev
       [not found] ` <CAC3St3DkgTP_bAbpdSh6n3bVivik1tieUopy-jd-yNrEyE=C1A@mail.gmail.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Max Filippov @ 2011-07-17 20:29 UTC (permalink / raw)
  To: Maxim Grigoriev; +Cc: gdb

Hello.

I'm trying to read privileged SRs from a remote gdbserver by the gdb configured for the elf target. All gdb versions that I've tried (6.8, 7.2 and 7.3) return 0 for those registers.
Running gdb under gdb showed that reading those registers ends inside xtensa_pseudo_register_read in the following block:

[...]
  /* We have to find out how to deal with priveleged registers.
     Let's treat them as pseudo-registers, but we cannot read/write them.  */

  else if (regnum < gdbarch_tdep (gdbarch)->a0_base)
    {
      buffer[0] = (gdb_byte)0;
      buffer[1] = (gdb_byte)0;
      buffer[2] = (gdb_byte)0;
      buffer[3] = (gdb_byte)0;
    }
[...]

The question is is there any reason we cannot read/write them with the elf target?
What would be the right way to make privileged SRs available to gdb?

Thanks.
-- Max


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

* Re: xtensa: reading privileged special registers
  2011-07-17 20:29 xtensa: reading privileged special registers Max Filippov
@ 2011-07-18  1:12 ` Maxim Grigoriev
       [not found] ` <CAC3St3DkgTP_bAbpdSh6n3bVivik1tieUopy-jd-yNrEyE=C1A@mail.gmail.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Maxim Grigoriev @ 2011-07-18  1:12 UTC (permalink / raw)
  To: Max Filippov; +Cc: gdb, Marc Gauthier

Hello Max,

Please, help us to precisely identify what exactly do you experience
by answering some questions:

1) Did you apply a source overlay for your specific hardware ?
    Xtensa is a configurable and expendable architecture. It's impossible
    to maintain the data base of all supported Xtensa processors
    because it's potentially infinite. Many Tensilica customers
    keep their hardware secret even from Tensilica, but all the tools
    still work. So for every instance of Xtensa processor, a set of source
    overlay files have to be provided. By default, so-called Xtensa FSF
    processor (we call it config) is supported by FSF tools. It is
    checked-in into FSF tree.

2) What Xtensa processor do you work with ( if it's not a secret ) ?
    What privileged registers do you have problems with ?

Thanks,
-- Maxim

On Sun, Jul 17, 2011 at 1:28 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> Hello.
>
> I'm trying to read privileged SRs from a remote gdbserver by the gdb configured for the elf target. All gdb versions that I've tried (6.8, 7.2 and 7.3) return 0 for those registers.
> Running gdb under gdb showed that reading those registers ends inside xtensa_pseudo_register_read in the following block:
>
> [...]
>  /* We have to find out how to deal with priveleged registers.
>     Let's treat them as pseudo-registers, but we cannot read/write them.  */
>
>  else if (regnum < gdbarch_tdep (gdbarch)->a0_base)
>    {
>      buffer[0] = (gdb_byte)0;
>      buffer[1] = (gdb_byte)0;
>      buffer[2] = (gdb_byte)0;
>      buffer[3] = (gdb_byte)0;
>    }
> [...]
>
> The question is is there any reason we cannot read/write them with the elf target?
> What would be the right way to make privileged SRs available to gdb?
>
> Thanks.
> -- Max
>


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

* RE: xtensa: reading privileged special registers
       [not found] ` <CAC3St3DkgTP_bAbpdSh6n3bVivik1tieUopy-jd-yNrEyE=C1A@mail.gmail.com>
@ 2011-07-18  2:00   ` Marc Gauthier
  2011-07-18  8:38     ` Max Filippov
  2011-07-18  8:20   ` Max Filippov
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Gauthier @ 2011-07-18  2:00 UTC (permalink / raw)
  To: Maxim Grigoriev, Max Filippov; +Cc: gdb

Hi Max,

On Sun, Jul 17, 2011 at 1:28 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> I'm trying to read privileged SRs from a remote gdbserver by the gdb
> configured for the elf target. All gdb versions that I've tried (6.8,
> 7.2 and 7.3) return 0 for those registers.

Correct.  This is simply a consequence of gdbserver being designed/used to debug user processes.  And user processes don't have access to privileged registers, i.e. privileged registers aren't part of their context.  Hence, you can't see them.

To see privileged registers, you'd want a setup that can e.g. debug a kernel or raw hardware.  Most Xtensa processor users can generally use OCD (on-chip debug) and thus use Tensilica's xt-gdb connecting directly to the processor hardware via XOCD (Xtensa OCD Daemon) and a JTAG probe.  Of course, you don't get user-process level debugging that way, you simply see everything the processor is doing.  But you certainly get access to privileged registers, and anything the processor does.  Another alternative is kgdb, however I don't think it is working at the moment for the Xtensa arch (it used to long ago).

For simplicity, the same register set is generated both for user and kernel situations, so GDB lists privileged registers even for user processes (e.g. via gdbserver or Linux native), even though they're not accessible.  Maybe one day we'll fix that.

Hope that answers your question,

-Marc


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

* Re: xtensa: reading privileged special registers
       [not found] ` <CAC3St3DkgTP_bAbpdSh6n3bVivik1tieUopy-jd-yNrEyE=C1A@mail.gmail.com>
  2011-07-18  2:00   ` Marc Gauthier
@ 2011-07-18  8:20   ` Max Filippov
  1 sibling, 0 replies; 5+ messages in thread
From: Max Filippov @ 2011-07-18  8:20 UTC (permalink / raw)
  To: Maxim Grigoriev; +Cc: gdb, Marc Gauthier

> Please, help us to precisely identify what exactly do you experience
> by answering some questions:
> 1) Did you apply a source overlay for your specific hardware ?

Yes, I have applied publicly available dc232b overlay. Although the
code that returns zeros for privileged SRs is not overlay-specific.

> 2) What Xtensa processor do you work with ( if it's not a secret ) ?
>     What privileged registers do you have problems with ?

It is not a processor, it is qemu-based ISS that I've been developing.
It emulates dc232b.
I was mostly interested in $ccount/$ccompare.
I started to dig here because although I've implemented access to
these registers in gdbstub, I couldn't make gdb to query them.

-- 
Thanks.
-- Max


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

* Re: xtensa: reading privileged special registers
  2011-07-18  2:00   ` Marc Gauthier
@ 2011-07-18  8:38     ` Max Filippov
  0 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2011-07-18  8:38 UTC (permalink / raw)
  To: Marc Gauthier; +Cc: Maxim Grigoriev, gdb

Maxim, Marc, thank you for the answers.

> To see privileged registers, you'd want a setup that can e.g. debug a kernel or raw hardware.

That's my case: I have a gdbserver built into qemu, it has full access
to the processor state.

> For simplicity, the same register set is generated both for user and kernel situations, so GDB lists privileged registers even for user processes (e.g. via gdbserver or Linux native), even though they're not accessible.  Maybe one day we'll fix that.

I can try to fix it, but I'm not sure what's the right way. I'd query
these registers from within xtensa_pseudo_register_read and fall back
to returning 0 if that query fails. Does that makes sense?

-- 
Thanks.
-- Max


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

end of thread, other threads:[~2011-07-18  8:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-17 20:29 xtensa: reading privileged special registers Max Filippov
2011-07-18  1:12 ` Maxim Grigoriev
     [not found] ` <CAC3St3DkgTP_bAbpdSh6n3bVivik1tieUopy-jd-yNrEyE=C1A@mail.gmail.com>
2011-07-18  2:00   ` Marc Gauthier
2011-07-18  8:38     ` Max Filippov
2011-07-18  8:20   ` Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox