Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: hui_zhu@mentor.com
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix interrupt.exp fails with m32 in x86_64
Date: Mon, 21 Apr 2014 18:27:00 -0000	[thread overview]
Message-ID: <201404211827.s3LIRL6a007871@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <53554475.3010201@mentor.com> (message from Hui Zhu on Tue, 22	Apr 2014 00:16:53 +0800)

> Date: Tue, 22 Apr 2014 00:16:53 +0800
> From: Hui Zhu <hui_zhu@mentor.com>
> 
> 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  <hui@codesourcery.com>
> 
>      * 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);
> +        }
>       }
>       }
>   }
> 
> 


  reply	other threads:[~2014-04-21 18:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 16:17 Hui Zhu
2014-04-21 18:27 ` Mark Kettenis [this message]
2014-04-22 13:09   ` Hui Zhu
2014-04-29 15:57   ` Hui Zhu
2014-04-29 17:05     ` Pedro Alves

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=201404211827.s3LIRL6a007871@glazunov.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=gdb-patches@sourceware.org \
    --cc=hui_zhu@mentor.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