Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* PATCH: Check section size for valid core sections
@ 2010-02-07 17:44 H.J. Lu
  2010-02-07 21:15 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2010-02-07 17:44 UTC (permalink / raw)
  To: GDB

I added a new core section, .reg-xstate, to support x86 XSAVE extended
state.  We can read it on any machine. But we can only write it on
machines with x86 XSAVE extended state. I have

/* Supported register note sections.  */
static struct core_regset_section amd64_linux_regset_sections[] =
{
  { ".reg", 144, "general-purpose" },
  { ".reg2", 512, "floating-point" },
  { ".reg-xstate", 0, "XSAVE extended state" },
  { NULL, 0 }
};

I update its size with

 /* Update the XSAVE extended state size on Linux/x86 host.  Need it
    for "gcore".  */
  i386_xstate_init ();
  amd64_linux_regset_sections[2].size = i386_xstate.size;

If the machine suppors XSAVE, size will be non-zero. We can still
read the core section since size is only used for gcore. OK to install?

Thanks.


H.J.
---
2010-02-07  H.J. Lu  <hongjiu.lu@intel.com>
 
	* linux-nat.c (linux_nat_do_thread_registers): Check section
	size instead of section name for valid core sections.

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 7fc9584..44a3288 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4112,9 +4112,12 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
   /* The loop below uses the new struct core_regset_section, which stores
      the supported section names and sizes for the core file.  Note that
      note PRSTATUS needs to be treated specially.  But the other notes are
-     structurally the same, so they can benefit from the new struct.  */
+     structurally the same, so they can benefit from the new struct.  We
+     check section size instead of section name for valid core sections
+     since we can read x86 XSAVE extended state core section, but we can
+     write it only if x86 XSAVE extended state is available natively.  */
   if (core_regset_p && sect_list != NULL)
-    while (sect_list->sect_name != NULL)
+    while (sect_list->size != 0)
       {
 	/* .reg was already handled above.  */
 	if (strcmp (sect_list->sect_name, ".reg") == 0)


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

* Re: PATCH: Check section size for valid core sections
  2010-02-07 17:44 PATCH: Check section size for valid core sections H.J. Lu
@ 2010-02-07 21:15 ` Mark Kettenis
  2010-02-07 21:25   ` H.J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2010-02-07 21:15 UTC (permalink / raw)
  To: hjl.tools; +Cc: gdb-patches

> Date: Sun, 7 Feb 2010 09:42:13 -0800
> From: "H.J. Lu" <hongjiu.lu@intel.com>
> 
> I added a new core section, .reg-xstate, to support x86 XSAVE extended
> state.  We can read it on any machine. But we can only write it on
> machines with x86 XSAVE extended state. I have
> 
> /* Supported register note sections.  */
> static struct core_regset_section amd64_linux_regset_sections[] =
> {
>   { ".reg", 144, "general-purpose" },
>   { ".reg2", 512, "floating-point" },
>   { ".reg-xstate", 0, "XSAVE extended state" },
>   { NULL, 0 }
> };
> 
> I update its size with
> 
>  /* Update the XSAVE extended state size on Linux/x86 host.  Need it
>     for "gcore".  */
>   i386_xstate_init ();
>   amd64_linux_regset_sections[2].size = i386_xstate.size;
> 
> If the machine suppors XSAVE, size will be non-zero. We can still
> read the core section since size is only used for gcore. OK to install?

Sorry, but this makes no sense to me.

> 2010-02-07  H.J. Lu  <hongjiu.lu@intel.com>
>  
> 	* linux-nat.c (linux_nat_do_thread_registers): Check section
> 	size instead of section name for valid core sections.
> 
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index 7fc9584..44a3288 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -4112,9 +4112,12 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
>    /* The loop below uses the new struct core_regset_section, which stores
>       the supported section names and sizes for the core file.  Note that
>       note PRSTATUS needs to be treated specially.  But the other notes are
> -     structurally the same, so they can benefit from the new struct.  */
> +     structurally the same, so they can benefit from the new struct.  We
> +     check section size instead of section name for valid core sections
> +     since we can read x86 XSAVE extended state core section, but we can
> +     write it only if x86 XSAVE extended state is available natively.  */
>    if (core_regset_p && sect_list != NULL)
> -    while (sect_list->sect_name != NULL)
> +    while (sect_list->size != 0)
>        {
>  	/* .reg was already handled above.  */
>  	if (strcmp (sect_list->sect_name, ".reg") == 0)
> 


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

* Re: PATCH: Check section size for valid core sections
  2010-02-07 21:15 ` Mark Kettenis
@ 2010-02-07 21:25   ` H.J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2010-02-07 21:25 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Sun, Feb 7, 2010 at 1:15 PM, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Sun, 7 Feb 2010 09:42:13 -0800
>> From: "H.J. Lu" <hongjiu.lu@intel.com>
>>
>> I added a new core section, .reg-xstate, to support x86 XSAVE extended
>> state.  We can read it on any machine. But we can only write it on
>> machines with x86 XSAVE extended state. I have
>>
>> /* Supported register note sections.  */
>> static struct core_regset_section amd64_linux_regset_sections[] =
>> {
>>   { ".reg", 144, "general-purpose" },
>>   { ".reg2", 512, "floating-point" },
>>   { ".reg-xstate", 0, "XSAVE extended state" },
>>   { NULL, 0 }
>> };
>>
>> I update its size with
>>
>>  /* Update the XSAVE extended state size on Linux/x86 host.  Need it
>>     for "gcore".  */
>>   i386_xstate_init ();
>>   amd64_linux_regset_sections[2].size = i386_xstate.size;
>>
>> If the machine suppors XSAVE, size will be non-zero. We can still
>> read the core section since size is only used for gcore. OK to install?
>
> Sorry, but this makes no sense to me.

Which part doesn't it make sense to you?

Thanks.


H.J.
----
>> 2010-02-07  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>       * linux-nat.c (linux_nat_do_thread_registers): Check section
>>       size instead of section name for valid core sections.
>>
>> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
>> index 7fc9584..44a3288 100644
>> --- a/gdb/linux-nat.c
>> +++ b/gdb/linux-nat.c
>> @@ -4112,9 +4112,12 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
>>    /* The loop below uses the new struct core_regset_section, which stores
>>       the supported section names and sizes for the core file.  Note that
>>       note PRSTATUS needs to be treated specially.  But the other notes are
>> -     structurally the same, so they can benefit from the new struct.  */
>> +     structurally the same, so they can benefit from the new struct.  We
>> +     check section size instead of section name for valid core sections
>> +     since we can read x86 XSAVE extended state core section, but we can
>> +     write it only if x86 XSAVE extended state is available natively.  */
>>    if (core_regset_p && sect_list != NULL)
>> -    while (sect_list->sect_name != NULL)
>> +    while (sect_list->size != 0)
>>        {
>>       /* .reg was already handled above.  */
>>       if (strcmp (sect_list->sect_name, ".reg") == 0)
>>
>



-- 
H.J.


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

end of thread, other threads:[~2010-02-07 21:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-07 17:44 PATCH: Check section size for valid core sections H.J. Lu
2010-02-07 21:15 ` Mark Kettenis
2010-02-07 21:25   ` H.J. Lu

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