From patchwork Fri Oct 6 22:48:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 23388 Received: (qmail 70666 invoked by alias); 6 Oct 2017 22:49:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 70657 invoked by uid 89); 6 Oct 2017 22:49:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=H*MI:16311 X-HELO: mail.baldwin.cx Received: from bigwig.baldwin.cx (HELO mail.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Oct 2017 22:49:49 +0000 Received: from ralph.baldwin.cx.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id F0BF610A7DB for ; Fri, 6 Oct 2017 18:49:47 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH] Use gdbarch_long_bit to determine layout of FreeBSD siginfo_t. Date: Fri, 6 Oct 2017 15:48:44 -0700 Message-Id: <20171006224844.16311-1-jhb@FreeBSD.org> X-IsSubscribed: yes FreeBSD architectures are either ILP32 or LP64 resulting in two different layouts for siginfo_t. Previously, the 'bits_per_word' member of bfd_arch_info was used to determine the layout to use for a given FreeBSD architecture. However, mipsn32 architectures inherit from a 64-bit mips architecture where bits_per_word is 64. As a result, $_siginfo was not properly extracted from FreeBSD/mipsn32 core dumps. Fix this by using gdbarch_long_bit instead of 'bits_per_word' to determine if a FreeBSD architecture is ILP32 or LP64. gdb/ChangeLog: * fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit. (fbsd_convert_siginfo): Likewise. * fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise. --- gdb/ChangeLog | 6 ++++++ gdb/fbsd-nat.c | 4 ++-- gdb/fbsd-tdep.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18224e0305..f72c47302e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-10-06 John Baldwin + + * fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit. + (fbsd_convert_siginfo): Likewise. + * fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise. + 2017-10-06 Yao Qi * Makefile.in (ALL_64_TARGET_OBS): Replace aarch64-insn.o with diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 5ad0dda5b4..265175a769 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -279,7 +279,7 @@ fbsd_siginfo_size () struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); /* Is the inferior 32-bit? If so, use the 32-bit siginfo size. */ - if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) + if (gdbarch_long_bit (gdbarch) == 32) return sizeof (struct siginfo32); #endif return sizeof (siginfo_t); @@ -296,7 +296,7 @@ fbsd_convert_siginfo (siginfo_t *si) struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); /* Is the inferior 32-bit? If not, nothing to do. */ - if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word != 32) + if (gdbarch_long_bit (gdbarch) != 32) return; struct siginfo32 si32; diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index fa4cd912ef..fa70f7c20b 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -143,7 +143,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, { size_t siginfo_size; - if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) + if (gdbarch_long_bit (gdbarch) == 32) siginfo_size = SIZE32_SIGINFO_T; else siginfo_size = SIZE64_SIGINFO_T; @@ -168,7 +168,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, len = siginfo_size - offset; ULONGEST siginfo_offset; - if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) + if (gdbarch_long_bit (gdbarch) == 32) siginfo_offset = LWPINFO_OFFSET + LWPINFO32_PL_SIGINFO; else siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO;