Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: PATCH: Add common files for x86 XSAVE extended state
Date: Tue, 02 Mar 2010 16:32:00 -0000	[thread overview]
Message-ID: <6dc9ffc81003020832i5c133c56k9e74522fb2516f18@mail.gmail.com> (raw)
In-Reply-To: <201003021556.o22FubQt010861@glazunov.sibelius.xs4all.nl>

On Tue, Mar 2, 2010 at 7:56 AM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Tue, 2 Mar 2010 07:28:26 -0800
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>>
>> Hi,
>>
>> This patch adds common files for x86 XSAVE extended state. They
>> are used by native x86 gdb and gdbserver to discover x86 XSAVE
>> extended state support. You can see IA32/Intel64 SDM at
>>
>> http://developer.intel.com/products/processor/manuals/index.htm
>>
>> for details. OK to install?
>
> Huh?  Where does this go?  What's the purpose of this?
>
>> 2010-03-02  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>       * common/i386-cpuid.h: New.
>>       * common/i386-xstate.c: Likewise.
>>       * common/i386-xstate.h: Likewise.
>

They will be installed in gdb/common. Native gdb and gdbserver will
use them to find:

1. If extended state is supported.
2. Which extended states are supported, SSE, AVX, ....
3. The size of extended state.  It is used to allocate
extended state buffer for ptrace.

static const struct target_desc *
i386_linux_read_description (struct target_ops *ops)
{
  gdb_assert (i386_xstate.status != XSTATE_UNKNOWN);

  if (have_ptrace_getregset == -1)
    {
      int tid;
      unsigned long long xstateregs[i386_xstate.n_of_int64];
      struct iovec iov;

      /* GNU/Linux LWP ID's are process ID's.  */
      tid = TIDGET (inferior_ptid);
      if (tid == 0)
        tid = PIDGET (inferior_ptid); /* Not a threaded program.  */

      iov.iov_base = xstateregs;
      iov.iov_len = i386_xstate.size;

      /* Check if PTRACE_GETREGSET works.  */
      if (ptrace (PTRACE_GETREGSET, tid,
                  (unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
        have_ptrace_getregset = 0;
      else
        {
          int i;

          have_ptrace_getregset = 1;

          /* Update the XSAVE extended state size for "gcore".  */
          for (i = 0; i386_linux_regset_sections[i].sect_name != NULL;
               i++)
            if (strcmp (i386_linux_regset_sections[i].sect_name,
                        ".reg-xstate") == 0)
              {
                i386_linux_regset_sections[i].size = i386_xstate.size;
                break;
              }
        }
    }

  /* Check the native XCR0 only if PTRACE_GETREGSET is available.  */
  if (have_ptrace_getregset &&
      (i386_xstate.xcr0 & XSTATE_AVX_MASK) == XSTATE_AVX_MASK)
    return tdesc_i386_avx_linux;
  else
    return tdesc_i386_linux;
}

void
_initialize_i386_linux_nat (void)
{
   ...
   i386_xstate_init ();
}

-- 
H.J.


  reply	other threads:[~2010-03-02 16:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 15:28 H.J. Lu
2010-03-02 15:56 ` Mark Kettenis
2010-03-02 16:32   ` H.J. Lu [this message]
2010-03-02 19:47 ` H.J. Lu
2010-03-03 23:23   ` Mark Kettenis

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=6dc9ffc81003020832i5c133c56k9e74522fb2516f18@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /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