From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30171 invoked by alias); 7 Feb 2012 18:01:16 -0000 Received: (qmail 30147 invoked by uid 22791); 7 Feb 2012 18:01:12 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD,T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Feb 2012 18:00:56 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id EF614DC7 for ; Tue, 7 Feb 2012 19:00:54 +0100 (CET) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xTdEEoBlpihq for ; Tue, 7 Feb 2012 19:00:52 +0100 (CET) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 82E93DC6 for ; Tue, 7 Feb 2012 19:00:52 +0100 (CET) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id q17I0q4a006640; Tue, 7 Feb 2012 19:00:52 +0100 (MET) From: Rainer Orth To: gdb-patches@sourceware.org Subject: Fix %eflags register index on Solaris/amd64 Date: Tue, 07 Feb 2012 18:01:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00075.txt.bz2 --=-=-= Content-length: 1919 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: 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 * 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=solx64-eflags.patch Content-length: 968 --- 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 */ --=-=-= Content-length: 144 -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University --=-=-=--