Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Tedeschi, Walfred" <walfred.tedeschi@intel.com>
To: Joel Brobecker <brobecker@adacore.com>,
	"Yao Qi <yao@codesourcery.com> (yao@codesourcery.com)"
	<yao@codesourcery.com>
Cc: "palves@redhat.com" <palves@redhat.com>,
	"gdb-patches@sourceware.org"	<gdb-patches@sourceware.org>
Subject: RE: [PATCH v1] Synchronize siginfo type described in GDB with the kernel and glibc ones.
Date: Thu, 19 Nov 2015 09:52:00 -0000	[thread overview]
Message-ID: <AC542571535E904D8E8ADAE745D60B19444FBC60@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <20151118230151.GA7958@adacore.com>

Joel and all,

First of all, Thanks a lot for your review, on both patches!

I had a discussion on the GDB list about this topic.
Observation from Yao was that we could use this structure on new and old kernels.
https://sourceware.org/ml/gdb/2015-07/msg00029.html

This was the reason why I wanted to keep it simple and avoid doing any king of check.

I understood from the kernel and glibc patches that the kernel is generic (all architectures) and the 
glibc is added for Intel only.
 
Finally I think it is also better to describe a bit what happens with the new fields in the kernel side.

In case we have a bound violation, the kernel does a disassemble of the current instruction,
Reads the values of the operands of the compare bound instructions and set the _low and _upper bound.
At the same time it sets the sig_code to 3. I.e. Those fields are only valid if the sigcode is 3.

1. Make a mechanism to determine which siginfo version to be used depending from the system being debugged.
I am not sure if there is such a mechanism in GDB already or how error prune it would be to be
able to detect pre presence of these fields from the kernel side and glibc (in the case of
the glibc also taking into account the architecture). 

2. Set the field _low and _upper to 0 in case the sigcode is not 3.

Any ideas or comments on that.

Thanks and regards,
-Fred

-----Original Message-----
From: Joel Brobecker [mailto:brobecker@adacore.com] 
Sent: Thursday, November 19, 2015 12:02 AM
To: Tedeschi, Walfred
Cc: palves@redhat.com; gdb-patches@sourceware.org
Subject: Re: [PATCH v1] Synchronize siginfo type described in GDB with the kernel and glibc ones.

> New kernel and glibc patches have introduced fields in the 
> segmentation fault fields.
> 
> Kernel patch:
> http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=ee1
> b58d36aa1b5a79eaba11f5c3633c88231da83
> 
> Glibc patch:
> http://repo.or.cz/w/glibc.git/commit/d4358b51c26a634eb885955aea06cad26
> af6f696
> 
> 2015-07-21  Walfred Tedeschi  <walfred.tedeschi@intel.com>
> 
> 	* linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
> 	structure to the siginfo.

I would really like someone like Pedro to review this patch, as I am really uncertain about the idea of extending our view of the structure without a way of checking that you have kernel and glibc support for it. As far as I can tell, this sets things up so as to ready undefined data, thus leading to undefined behavior.

> 
> ---
>  gdb/linux-tdep.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 
> 7c24eaa..de773ae 100644
> --- a/gdb/linux-tdep.c
> +++ b/gdb/linux-tdep.c
> @@ -248,10 +248,10 @@ static struct type *  linux_get_siginfo_type 
> (struct gdbarch *gdbarch)  {
>    struct linux_gdbarch_data *linux_gdbarch_data;
> -  struct type *int_type, *uint_type, *long_type, *void_ptr_type;
> +  struct type *int_type, *uint_type, *long_type, *void_ptr_type, 
> + *short_type;
>    struct type *uid_type, *pid_type;
>    struct type *sigval_type, *clock_type;
> -  struct type *siginfo_type, *sifields_type;
> +  struct type *siginfo_type, *sifields_type, *sigfault_bnd_fields;
>    struct type *type;
>  
>    linux_gdbarch_data = get_linux_gdbarch_data (gdbarch); @@ -264,6 
> +264,8 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
>  				 1, "unsigned int");
>    long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
>  				 0, "long");
> +  short_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
> +				 0, "short");
>    void_ptr_type = lookup_pointer_type (builtin_type 
> (gdbarch)->builtin_void);
>  
>    /* sival_t */
> @@ -339,6 +341,12 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
>    /* _sigfault */
>    type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
>    append_composite_type_field (type, "si_addr", void_ptr_type);
> +  append_composite_type_field (type, "_addr_lsb", short_type);
> +
> +  sigfault_bnd_fields = arch_composite_type (gdbarch, NULL, 
> + TYPE_CODE_STRUCT);  append_composite_type_field 
> + (sigfault_bnd_fields, "_lower", void_ptr_type);  
> + append_composite_type_field (sigfault_bnd_fields, "_upper", 
> + void_ptr_type);  append_composite_type_field (type, "_addr_bnd", 
> + sigfault_bnd_fields);
>    append_composite_type_field (sifields_type, "_sigfault", type);
>  
>    /* _sigpoll */
> --
> 2.1.4

--
Joel
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2015-11-19  9:52 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 15:09 [PATCH obv] Changing compiler flags for MPX tests Walfred Tedeschi
2015-10-26 16:10 ` [PATCH v1] Intel(R) MPX registers to the DWARF enumeration Walfred Tedeschi
2015-12-06 16:35   ` Joel Brobecker
2015-12-06 17:42     ` H.J. Lu
2015-12-07  8:29       ` Tedeschi, Walfred
2015-10-26 16:11 ` [PATCH v1] Synchronize siginfo type described in GDB with the kernel and glibc ones Walfred Tedeschi
2015-11-18 23:01   ` Joel Brobecker
2015-11-19  9:52     ` Tedeschi, Walfred [this message]
2015-11-19 13:27       ` Pedro Alves
2015-11-19 16:41         ` Tedeschi, Walfred
2015-11-19 17:07           ` Pedro Alves
2015-12-01 10:08             ` Tedeschi, Walfred
2015-12-01 12:08               ` Pedro Alves
2015-10-26 16:22 ` [PATCH v1] ABI changes for Intel(R) MPX Walfred Tedeschi
2015-10-26 19:07   ` Eli Zaretskii
2015-10-27 17:21     ` Tedeschi, Walfred
2015-12-06 16:16   ` Joel Brobecker
2015-10-26 16:25 ` [PATCH obv] Fix non stopping breakpoint on newer compilers Walfred Tedeschi
2015-11-04 14:42   ` Joel Brobecker
2015-10-26 16:26 ` [PATCH v1] Intel(R) MPX - Bound violation handling Walfred Tedeschi
2015-11-04 14:55   ` Joel Brobecker
2015-11-05 10:04     ` Tedeschi, Walfred
2015-11-19  0:01   ` Joel Brobecker
2015-12-14 17:43     ` Tedeschi, Walfred
2015-12-14 18:45       ` Pedro Alves
2015-12-15 11:01         ` Tedeschi, Walfred
2015-12-16 15:21           ` Tedeschi, Walfred
2015-12-16 16:52             ` Pedro Alves
2015-12-17 17:31               ` Tedeschi, Walfred
2015-12-21 17:23           ` Pedro Alves
2015-11-04 14:42 ` [PATCH obv] Changing compiler flags for MPX tests Joel Brobecker

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=AC542571535E904D8E8ADAE745D60B19444FBC60@IRSMSX104.ger.corp.intel.com \
    --to=walfred.tedeschi@intel.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=yao@codesourcery.com \
    /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