From: "H.J. Lu" <hongjiu.lu@intel.com>
To: GDB <gdb-patches@sourceware.org>
Subject: PATCH: Fix 32bit coredump read on Linux/AVX
Date: Tue, 20 Apr 2010 03:22:00 -0000 [thread overview]
Message-ID: <20100420032234.GA10544@intel.com> (raw)
Hi,
This patch:
http://sourceware.org/ml/gdb-patches/2010-04/msg00276.html
breaks 32bit coredump read on Linux/AVX since we only dump .reg and
.reg-xstate sections on AVX. But i386_linux_core_read_description
checks .reg2 and .reg-xfp sections first. Since there are no
.reg2 and .reg-xfp sections, NULL is returned and SSE target is used.
This patch changes the section check order to .reg-xstate, .reg-xfp,
.reg2. OK to install?
Thanks.
H.J.
---
2010-04-19 H.J. Lu <hongjiu.lu@intel.com>
* amd64-linux-tdep.c (amd64_linux_core_read_description): Always
use xcr0 from i386_linux_core_read_xcr0.
* i386-linux-tdep.c (i386_linux_core_read_xcr0): Check .reg-xfp
and .reg2 sections for SSE and MMX.
(i386_linux_core_read_description): Always use xcr0 from
i386_linux_core_read_xcr0.
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index f249d5d..e66c08e 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -1269,14 +1269,9 @@ amd64_linux_core_read_description (struct gdbarch *gdbarch,
struct target_ops *target,
bfd *abfd)
{
- asection *section = bfd_get_section_by_name (abfd, ".reg2");
- uint64_t xcr0;
-
- if (section == NULL)
- return NULL;
-
/* Linux/x86-64. */
- xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
+ uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
+ gdb_assert (xcr0 != 0);
if ((xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK)
return tdesc_amd64_avx_linux;
else
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 5952153..750e039 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -610,8 +610,12 @@ i386_linux_core_read_xcr0 (struct gdbarch *gdbarch,
xcr0 = bfd_get_64 (abfd, contents);
}
}
- else
+ else if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
xcr0 = I386_XSTATE_SSE_MASK;
+ else if (bfd_get_section_by_name (abfd, ".reg2") != NULL)
+ xcr0 = I386_XSTATE_X87_MASK;
+ else
+ xcr0 = 0;
return xcr0;
}
@@ -623,22 +627,20 @@ i386_linux_core_read_description (struct gdbarch *gdbarch,
struct target_ops *target,
bfd *abfd)
{
- asection *section = bfd_get_section_by_name (abfd, ".reg2");
- uint64_t xcr0;
-
- if (section == NULL)
- return NULL;
-
- section = bfd_get_section_by_name (abfd, ".reg-xfp");
- if (section == NULL)
- return tdesc_i386_mmx_linux;
+ uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
/* Linux/i386. */
- xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
- if ((xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK)
- return tdesc_i386_avx_linux;
- else
- return tdesc_i386_linux;
+ switch ((xcr0 & I386_XSTATE_AVX_MASK))
+ {
+ case I386_XSTATE_AVX_MASK:
+ return tdesc_i386_avx_linux;
+ case I386_XSTATE_SSE_MASK:
+ return tdesc_i386_linux;
+ case I386_XSTATE_X87_MASK:
+ return tdesc_i386_mmx_linux;
+ default:
+ return NULL;
+ }
}
static void
next reply other threads:[~2010-04-20 3:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-20 3:22 H.J. Lu [this message]
2010-04-20 18:43 ` H.J. Lu
2010-04-21 14:32 ` H.J. Lu
2010-04-21 19:38 ` Mark Kettenis
2010-04-21 20:18 ` H.J. Lu
2010-04-21 20:24 ` Mark Kettenis
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=20100420032234.GA10544@intel.com \
--to=hongjiu.lu@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=hjl.tools@gmail.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