Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "Tedeschi, Walfred" <walfred.tedeschi@intel.com>,
	       Joel Brobecker <brobecker@adacore.com>,
	       "Yao Qi <yao@codesourcery.com> (yao@codesourcery.com)"
	<yao@codesourcery.com>
Cc: "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 13:27:00 -0000	[thread overview]
Message-ID: <564DCE42.5060000@redhat.com> (raw)
In-Reply-To: <AC542571535E904D8E8ADAE745D60B19444FBC60@IRSMSX104.ger.corp.intel.com>

On 11/19/2015 09:51 AM, Tedeschi, Walfred wrote:

> I understood from the kernel and glibc patches that the kernel is generic (all architectures) and the 
> glibc is added for Intel only.

IIRC, not all architectures in the kernel use /include/uapi/asm-generic/siginfo.h, and
some have their own custom siginfo.h.  Those should have a custom gdbarch_get_siginfo_type
hook in gdb as well, but nobody has ever bothered to fix that this far, supposedly
because the siginfo tests in the testsuite don't depend in bits of the siginfo objects
that might differ on such architectures.

It does look a bit odd to me to expose these new fields on all architectures, given that
this is Intel/x86-only.  But it doesn't _really_ hurt, other than potentially being
a little bit confusing.

>  
> 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). 

As alluded to above, the 'get_siginfo_type' method can be set different for each gdbarch.
So x86, arm, etc. each can tailor the siginfo type to their needs by installing
a different hook.  In fact, it's what we did prior to 5cd867b414fe, except that
before that commit, all archs were actually installing the same hook.

Checking the kernel version would be more complicated, considering remote debugging.  We
could have gdbserver probe for support for the feature, and then report it in qSupported
at connection time, for example, or even have the server fully describe the layout of the
object (similar to how it can describe register types, which you used in
gdb/features/i386/64bit-mpx.xml), though I don't think either would be warranted here.
The siginfo object's layout and size is ABI, the kernel can't change it.  Even though new fields
have been added to the end of struct _sigfault, the _sigfault field itself is part of a
union, which is padded to SI_PAD_SIZE bytes.  That is, this change did not change the
siginfo object's size.  Since we're only supposed to interpret the contents of the new
elements when si_code is 3 and the kernel never set si_code to 3 before, the change is
also fully backwards compatible.

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

I'd just leave them be.  You always have to know how to interpret the
siginfo object's elements, and know which enum field to look at between
siginfo._sifields.{_kill|_timer|_sigchld|etc.}, depending on si_code
and si_signo.  Doesn't the kernel of glibc already always memset the
whole object before filling in the valid bits, BTW?


Lastly, I think you missed tweaking amd64_linux_siginfo_fixup & co in order to
correctly convert these fields when debugging 32-bit and x32 programs on
a 64-bit kernel.  Likewise the gdbserver equivalents.


Thanks,
Pedro Alves


  reply	other threads:[~2015-11-19 13:27 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
2015-11-19 13:27       ` Pedro Alves [this message]
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=564DCE42.5060000@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=walfred.tedeschi@intel.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