From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: gdb-patches@sourceware.org
Subject: Fix %eflags register index on Solaris/amd64
Date: Tue, 07 Feb 2012 18:01:00 -0000 [thread overview]
Message-ID: <yddty32seuj.fsf@manam.CeBiTec.Uni-Bielefeld.DE> (raw)
[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]
When investigating a set of GCC testsuite failures on 64-bit Solaris 10/11
PR target/51753
Many gcc.dg/simultate-thread tests fail on Solaris 10+/x86
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51753
it turned out that they were cause by a gdb bug. The test boils down to
single-stepping the program under test under gdb, calling a function
before and after every single step:
gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.gdb
When I compared the execution trace between Solaris/x64 and
Linux/x86_64, I found that the Solaris gdb behaved completely
nonsensical: e.g. in this code snippet
ret = __atomic_exchange_n (&value, max, __ATOMIC_SEQ_CST);
if (ret != zero || value != max)
test_abort();
both conditions were false, still test_abort was entered, but left again
without doing anything. When I looked at %eflags in gdb, I found that
it was always shown as 0/empty, which makes no sense. Digging around in
gdb, I found the culprit: in both amd64-sol2-tdep.c
(amd64_sol2_gregset_reg_offset) and i386-sol2-nat.c
(amd64_sol2_gregset64_reg_offs, amd64_sol2_gregset32_reg_offs) the
offset for %eflags was wrong: <sys/regset.h> has
#define EFL 16
for the 32-bit case, but
#define REG_RFL 19
for 64-bit, while 16 in 64-bit is
#define REG_ERR 16
This explains what I was seeing: when printing $eflags, I was actually
seeing the %err value (always 0, it seems), and when restoring registers
after a call, %eflags was effectively cleared, explaining the
nonsensical control flow I was seeing.
The following patch fixes this and fixes all but one of the
gcc.dg/simulate-thread tests. I still have to investigate that last
one.
Ok for mainline?
Rainer
2012-02-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* amd64-sol2-tdep.c (amd64_sol2_gregset_reg_offset): Correct
%eflags offset.
* i386-sol2-nat.c (amd64_sol2_gregset64_reg_offs)
(amd64_sol2_gregset32_reg_offs): Likewise.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: solx64-eflags.patch --]
[-- Type: text/x-patch, Size: 968 bytes --]
--- amd64-sol2-tdep.c~ 2012-01-06 05:43:04.000000000 +0100
+++ amd64-sol2-tdep.c 2012-02-04 22:03:31.871802194 +0100
@@ -54,7 +54,7 @@ static int amd64_sol2_gregset_reg_offset
1 * 8,
0 * 8, /* ... %r15 */
17 * 8, /* %rip */
- 16 * 8, /* %eflags */
+ 19 * 8, /* %eflags */
18 * 8, /* %cs */
21 * 8, /* %ss */
25 * 8, /* %ds */
--- i386-sol2-nat.c~ 2012-01-06 05:43:15.000000000 +0100
+++ i386-sol2-nat.c 2012-02-04 22:04:27.661124884 +0100
@@ -68,7 +68,7 @@ static int amd64_sol2_gregset64_reg_offs
1 * 8,
0 * 8, /* ... %r15 */
17 * 8, /* %rip */
- 16 * 8, /* %eflags */
+ 19 * 8, /* %eflags */
18 * 8, /* %cs */
21 * 8, /* %ss */
25 * 8, /* %ds */
@@ -89,7 +89,7 @@ static int amd64_sol2_gregset32_reg_offs
9 * 8, /* %esi */
8 * 8, /* %edi */
17 * 8, /* %eip */
- 16 * 8, /* %eflags */
+ 19 * 8, /* %eflags */
18 * 8, /* %cs */
21 * 8, /* %ss */
25 * 8, /* %ds */
[-- Attachment #3: Type: text/plain, Size: 144 bytes --]
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
next reply other threads:[~2012-02-07 18:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-07 18:01 Rainer Orth [this message]
2012-02-07 19:36 ` Pedro Alves
2012-02-08 14:40 ` Rainer Orth
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=yddty32seuj.fsf@manam.CeBiTec.Uni-Bielefeld.DE \
--to=ro@cebitec.uni-bielefeld.de \
--cc=gdb-patches@sourceware.org \
/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