This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: alpha-linux access to thread unique value
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: rth at redhat dot com
- Date: Fri, 31 Jan 2003 11:37:57 -0500
- Subject: Re: alpha-linux access to thread unique value
- References: <20030121005215.GA26880@redhat.com>
On Mon, Jan 20, 2003 at 04:52:15PM -0800, Richard Henderson wrote:
> The thread unique value is stored in the thread's Process Control Block,
> and is accessed programatically via the rduniq/wruniq PAL calls. This
> value is interesting because it's used as the thread base pointer. We'll
> need this value in order to be able to debug threads properly on Alpha.
>
> The ptrace and core file bits require recent patches to the linux kernel.
> If the support is not present, the unique value will read as zero and
> have writes ignored.
>
> Ok to commit?
I think Andrew just approved this; if I'm misinterpreting him, then I will
myself. Since we don't have an Alpha gdbserver port this is all that
you need to do.
Please check this in.
>
>
> r~
>
>
> * alpha-nat.c (REGISTER_PTRACE_ADDR): Merge into ...
> (register_addr): ... here. Support ALPHA_UNIQUE_REGNUM.
> (fetch_elf_core_registers): Support ALPHA_UNIQUE_REGNUM.
> * alpha-tdep.c (alpha_register_name): Add "unique".
> * alpha-tdep.h (ALPHA_NUM_REGS): Increment.
> (ALPHA_UNIQUE_REGNUM): New.
> * config/alpha/nm-linux.h (ALPHA_UNIQUE_PTRACE_ADDR): New.
>
> Index: alpha-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/alpha-nat.c,v
> retrieving revision 1.14
> diff -c -p -d -p -r1.14 alpha-nat.c
> *** alpha-nat.c 6 Dec 2002 16:59:05 -0000 1.14
> --- alpha-nat.c 20 Jan 2003 23:13:04 -0000
> *************** fetch_elf_core_registers (char *core_reg
> *** 149,173 ****
> memset (&deprecated_registers[REGISTER_BYTE (ALPHA_ZERO_REGNUM)], 0, 8);
> memset (&deprecated_register_valid[ALPHA_V0_REGNUM], 1, 32);
> deprecated_register_valid[PC_REGNUM] = 1;
> }
> }
>
>
> /* Map gdb internal register number to a ptrace ``address''.
> ! These ``addresses'' are defined in <sys/ptrace.h> */
> !
> ! #define REGISTER_PTRACE_ADDR(regno) \
> ! (regno < FP0_REGNUM ? GPR_BASE + (regno) \
> ! : regno == PC_REGNUM ? PC \
> ! : regno >= FP0_REGNUM ? FPR_BASE + ((regno) - FP0_REGNUM) \
> ! : 0)
>
> ! /* Return the ptrace ``address'' of register REGNO. */
>
> CORE_ADDR
> register_addr (int regno, CORE_ADDR blockend)
> {
> ! return REGISTER_PTRACE_ADDR (regno);
> }
>
> int
> --- 149,184 ----
> memset (&deprecated_registers[REGISTER_BYTE (ALPHA_ZERO_REGNUM)], 0, 8);
> memset (&deprecated_register_valid[ALPHA_V0_REGNUM], 1, 32);
> deprecated_register_valid[PC_REGNUM] = 1;
> +
> + if (core_reg_size >= 33 * 8)
> + {
> + memcpy (&deprecated_registers[REGISTER_BYTE (ALPHA_UNIQUE_REGNUM)],
> + core_reg_sect + 32 * 8, 8);
> + deprecated_register_valid[ALPHA_UNIQUE_REGNUM] = 1;
> + }
> }
> }
>
>
> /* Map gdb internal register number to a ptrace ``address''.
> ! These ``addresses'' are defined in <sys/ptrace.h>, with
> ! the exception of ALPHA_UNIQUE_PTRACE_ADDR. */
>
> ! #ifndef ALPHA_UNIQUE_PTRACE_ADDR
> ! #define ALPHA_UNIQUE_PTRACE_ADDR 0
> ! #endif
>
> CORE_ADDR
> register_addr (int regno, CORE_ADDR blockend)
> {
> ! if (regno == PC_REGNUM)
> ! return PC;
> ! if (regno == ALPHA_UNIQUE_REGNUM)
> ! return ALPHA_UNIQUE_PTRACE_ADDR;
> ! if (regno < FP0_REGNUM)
> ! return GPR_BASE + regno;
> ! else
> ! return FPR_BASE + regno - FP0_REGNUM;
> }
>
> int
> Index: alpha-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
> retrieving revision 1.59
> diff -c -p -d -p -r1.59 alpha-tdep.c
> *** alpha-tdep.c 8 Jan 2003 17:21:26 -0000 1.59
> --- alpha-tdep.c 20 Jan 2003 23:13:05 -0000
> *************** alpha_register_name (int regno)
> *** 288,294 ****
> "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
> "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
> "f24", "f25", "f26", "f27", "f28", "f29", "f30", "fpcr",
> ! "pc", "vfp",
> };
>
> if (regno < 0)
> --- 288,294 ----
> "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
> "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
> "f24", "f25", "f26", "f27", "f28", "f29", "f30", "fpcr",
> ! "pc", "vfp", "unique",
> };
>
> if (regno < 0)
> Index: alpha-tdep.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/alpha-tdep.h,v
> retrieving revision 1.9
> diff -c -p -d -p -r1.9 alpha-tdep.h
> *** alpha-tdep.h 4 Jan 2003 23:38:44 -0000 1.9
> --- alpha-tdep.h 20 Jan 2003 23:13:05 -0000
> ***************
> *** 28,34 ****
> #define ALPHA_REGISTER_SIZE 8
>
> /* Number of machine registers. */
> ! #define ALPHA_NUM_REGS 66
>
> /* Total amount of space needed to store our copies of the machine's
> register state. */
> --- 28,34 ----
> #define ALPHA_REGISTER_SIZE 8
>
> /* Number of machine registers. */
> ! #define ALPHA_NUM_REGS 67
>
> /* Total amount of space needed to store our copies of the machine's
> register state. */
> ***************
> *** 61,66 ****
> --- 61,67 ----
> #define ALPHA_FPCR_REGNUM 63 /* Floating point control register */
> #define ALPHA_PC_REGNUM 64 /* Contains program counter */
> #define ALPHA_FP_REGNUM 65 /* Virtual frame pointer */
> + #define ALPHA_UNIQUE_REGNUM 66 /* PAL_rduniq value */
>
> /* The alpha has two different virtual pointers for arguments and locals.
>
> Index: config/alpha/nm-linux.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/alpha/nm-linux.h,v
> retrieving revision 1.12
> diff -c -p -d -p -r1.12 nm-linux.h
> *** config/alpha/nm-linux.h 18 Oct 2002 19:34:39 -0000 1.12
> --- config/alpha/nm-linux.h 20 Jan 2003 23:13:06 -0000
> ***************
> *** 45,48 ****
> --- 45,51 ----
> pointer to the first register. */
> #define ALPHA_REGSET_BASE(regsetp) ((long *) (regsetp))
>
> + /* The address of UNIQUE for ptrace. */
> + #define ALPHA_UNIQUE_PTRACE_ADDR 65
> +
> #endif /* NM_LINUX_H */
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer