Fix 32-bit thread debugging on x86_64

From: Daniel Jacobowitz (drow_at_false.org)
Date: 07/31/05

  • Next message: Rafael J. Wysocki: "Re: revert yenta free_irq on suspend"
    Date:	Sun, 31 Jul 2005 16:05:58 -0400
    To: Andi Kleen <ak@suse.de>
    
    

    The IA32 ptrace emulation currently returns the wrong registers for
    fs/gs; it's returning what x86_64 calls gs_base. We need regs.gsindex
    in order for GDB to correctly locate the TLS area. Without this patch,
    the 32-bit GDB testsuite bombs on a 64-bit kernel. With it, results
    look about like I'd expect, although there are still a handful of
    kernel-related failures (vsyscall related?).

    Signed-off-by: Daniel Jacobowitz <dan@codesourcery.com>

    diff -r -p -u z/linux-2.6.11/arch/x86_64/ia32/ptrace32.c linux-2.6.11/arch/x86_64/ia32/ptrace32.c
    --- linux-2.6.12.3.orig/arch/x86_64/ia32/ptrace32.c 2005-03-02 02:37:52.000000000 -0500
    +++ linux-2.6.12.3/arch/x86_64/ia32/ptrace32.c 2005-07-31 15:29:48.000000000 -0400
    @@ -43,11 +43,11 @@ static int putreg32(struct task_struct *
             switch (regno) {
             case offsetof(struct user32, regs.fs):
                     if (val && (val & 3) != 3) return -EIO;
    - child->thread.fs = val & 0xffff;
    + child->thread.fsindex = val & 0xffff;
                     break;
             case offsetof(struct user32, regs.gs):
                     if (val && (val & 3) != 3) return -EIO;
    - child->thread.gs = val & 0xffff;
    + child->thread.gsindex = val & 0xffff;
                     break;
             case offsetof(struct user32, regs.ds):
                     if (val && (val & 3) != 3) return -EIO;
    @@ -138,10 +138,10 @@ static int getreg32(struct task_struct *
     
             switch (regno) {
             case offsetof(struct user32, regs.fs):
    - *val = child->thread.fs;
    + *val = child->thread.fsindex;
                     break;
             case offsetof(struct user32, regs.gs):
    - *val = child->thread.gs;
    + *val = child->thread.gsindex;
                     break;
             case offsetof(struct user32, regs.ds):
                     *val = child->thread.ds;

    -- 
    Daniel Jacobowitz
    CodeSourcery, LLC
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Rafael J. Wysocki: "Re: revert yenta free_irq on suspend"

    Relevant Pages

    • Re: clone() <-> getpid() bug in 2.6?
      ... Well, there was no gdb on that machine, compiling it now. ... For example how do I set a bp to trigger when getpid() is called? ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: 2.6.13-rc3-mm3
      ... > I've attached gdb to it and its stuck in memcpy. ... > of the trace is junk as glibc's arm memcpy implementation will have ... Or is there some hardware fault ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: PPC KGDB changes and some help?
      ... >>There is a real danger of passing signal info back to gdb as it will want ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • Re: [Fastboot] kexec+kdump testing with 2.6.12-rc3-mm3
      ... But do we really need this if we instead have a suite of gdb ... > scripts and other user-space analyzers that can find the requested ... That's right, we should try to do minimum stuff at the time of crash, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Whats in this vaddr segment 0xffffe000-0xfffff000 ---p ?
      ... >to a buffer from this virtual address seems to work fine i.e if I do ... permission bits are ---. ... start gdb and read the memory out using gdb (which will use ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)