This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Add common files for x86 XSAVE extended state


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]