From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27359 invoked by alias); 21 Apr 2014 18:27:31 -0000 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 Received: (qmail 27295 invoked by uid 89); 21 Apr 2014 18:27:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: glazunov.sibelius.xs4all.nl Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 21 Apr 2014 18:27:28 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id s3LIRLeI000316; Mon, 21 Apr 2014 20:27:21 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id s3LIRL6a007871; Mon, 21 Apr 2014 20:27:21 +0200 (CEST) Date: Mon, 21 Apr 2014 18:27:00 -0000 Message-Id: <201404211827.s3LIRL6a007871@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: hui_zhu@mentor.com CC: gdb-patches@sourceware.org In-reply-to: <53554475.3010201@mentor.com> (message from Hui Zhu on Tue, 22 Apr 2014 00:16:53 +0800) Subject: Re: [PATCH] Fix interrupt.exp fails with m32 in x86_64 References: <53554475.3010201@mentor.com> X-SW-Source: 2014-04/txt/msg00420.txt.bz2 > Date: Tue, 22 Apr 2014 00:16:53 +0800 > From: Hui Zhu > > I make a patch that let eax sign-extend in function > amd64_collect_native_gregset > that can handle this issue. > It can handle the issue and pass the regression test. > Please help me review it. I don't think the generic amd64 target code is the proper place to work around Linux kernel bugs. If you really want to work around this bug in GDB, it should probably be done in the Linux-specific i386/amd64 native code. Mark > 2014-04-21 Hui Zhu > > * amd64-nat.c(amd64_collect_native_gregset): Make %eax sign-extended. > --- a/gdb/amd64-nat.c > +++ b/gdb/amd64-nat.c > @@ -131,10 +131,12 @@ amd64_collect_native_gregset (const stru > { > num_regs = amd64_native_gregset32_num_regs; > > - /* Make sure %eax, %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and > + /* Make sure %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and > %eip get zero-extended to 64 bits. */ > for (i = 0; i <= I386_EIP_REGNUM; i++) > { > + if (i == I386_EAX_REGNUM) > + continue; > if (regnum == -1 || regnum == i) > memset (regs + amd64_native_gregset_reg_offset (gdbarch, i), > 0, 8); > } > @@ -156,7 +158,24 @@ amd64_collect_native_gregset (const stru > int offset = amd64_native_gregset_reg_offset (gdbarch, i); > > if (offset != -1) > - regcache_raw_collect (regcache, i, regs + offset); > + { > + if (i == I386_EAX_REGNUM > + && gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) > + { > + /* Make sure %eax get sign-extended to 64 bits. */ > + LONGEST val; > + > + regcache_raw_collect (regcache, I386_EAX_REGNUM, > + regs + offset); > + val = extract_signed_integer ((gdb_byte *)(regs + offset), > + 4, > + gdbarch_byte_order (gdbarch)); > + store_signed_integer ((gdb_byte *)(regs + offset), 8, > + gdbarch_byte_order (gdbarch), val); > + } > + else > + regcache_raw_collect (regcache, i, regs + offset); > + } > } > } > } > >