]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/procfs.c
Fix signals reported for faults on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 12 Sep 2019 08:40:59 +0000 (10:40 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 12 Sep 2019 08:40:59 +0000 (10:40 +0200)
commit7a28970742a8a1509917d409af14c84e1f666baa
treebcec44a834d20269ff8239fad3175df7f2c00c54
parent19d16d8789cd1846c33c49f2fdab219b2c1fb4e1
Fix signals reported for faults on Solaris

It's been a long-standing nuisance that gdb reported unaligned accesses
on Solaris/SPARC as SIGSEGV, contrary to the shells and truss which
correctly report SIGBUS instead.

I could trace this down to the fault handling code in procfs.c
(procfs_target::wait): when pr_why is set to PR_FAULTED, the current
code sets the signal based on the fault number.  For one, the code gets
this wrong for FLTACCESS (the unaligned access case) where it uses
SIGSEGV.  What's worse, it's completely unnecessary to make up the
signal number inside gdb.  Instead, it should just take what procfs
reports to avoid mismatches, which is what this patch does.  I've
completely removed the explicit handling of the various fault codes: for
one, the list has already been incomplete, lacking FLTCPCOVF which
existed since at least Solaris 8.  Besides, there's no reason to error
out on unknown fault codes: either the fault causes a signal which can
then be reported from procfs, or it doesn't (as for FLTPAGE) and no
reporting is necessary.

Tested on sparcv9-sun-solaris2.11 and x86_64-pc-solaris2.11.  Also
spot-checked manually for a couple of cases (unaligned access, division
by 0, NULL pointer dereference).

* procfs.c (procfs_target::wait) <PR_FAULTED>: Get signal from
prstatus.pr_lwp.pr_info instead of making it up.
gdb/ChangeLog
gdb/procfs.c