This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix interrupt.exp fails with m32 in x86_64


> 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);
> +        }
>       }
>       }
>   }
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]