From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6004 invoked by alias); 26 Nov 2002 02:00:55 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 5996 invoked from network); 26 Nov 2002 02:00:53 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 26 Nov 2002 02:00:53 -0000 Received: from int-mx2.corp.redhat.com (nat-pool-rdu-dmz.redhat.com [172.16.52.200]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id gAQ1aVP32381 for ; Mon, 25 Nov 2002 20:36:31 -0500 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gAQ20os04977; Mon, 25 Nov 2002 21:00:50 -0500 Received: from redhat.com (reddwarf.sfbay.redhat.com [172.16.24.50]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id gAQ20nM14752; Mon, 25 Nov 2002 18:00:49 -0800 Message-ID: <3DE2D5D1.57780D1D@redhat.com> Date: Mon, 25 Nov 2002 18:00:00 -0000 From: Michael Snyder Organization: Red Hat, Inc. X-Accept-Language: en MIME-Version: 1.0 To: Daniel Jacobowitz CC: Andrew Cagney , kettenis@gnu.org, gdb@sources.redhat.com Subject: Re: [Fwd: Re: gdb/725: Crash using debug target and regcaches (in 5.3 branch?)] References: <3DDD6150.10407@redhat.com> <20021122001447.GA7884@nevyn.them.org> <3DDD7D8E.2010407@redhat.com> <20021122023724.GA13441@nevyn.them.org> <20021126014155.GA29683@nevyn.them.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-11/txt/msg00363.txt.bz2 Daniel Jacobowitz wrote: > > On Thu, Nov 21, 2002 at 09:37:24PM -0500, Daniel Jacobowitz wrote: > > 2002-11-21 Daniel Jacobowitz > > > > Fix PR gdb/725 > > * lin-lwp.c (lin_lwp_fetch_registers): Remove. > > (lin_lwp_store_registers): Remove. > > (init_lin_lwp_ops): Use fetch_inferior_registers > > and store_inferior_registers directly. > > * sparc-nat.c (fetch_inferior_registers): Honor LWP ID. > > (store_inferior_registers): Likewise. > > Any comments on this patch? If you like it, feel free to commit it for > 5.3 - I'll be out of town this week. Seems like the spirit is in the right place. Mark is probably in a better position than I am to comment on the implementation. > > > > > Index: lin-lwp.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/lin-lwp.c,v > > retrieving revision 1.36 > > diff -u -p -r1.36 lin-lwp.c > > --- lin-lwp.c 31 Oct 2002 21:00:08 -0000 1.36 > > +++ lin-lwp.c 22 Nov 2002 02:35:31 -0000 > > @@ -1343,32 +1343,6 @@ lin_lwp_mourn_inferior (void) > > child_ops.to_mourn_inferior (); > > } > > > > -static void > > -lin_lwp_fetch_registers (int regno) > > -{ > > - struct cleanup *old_chain = save_inferior_ptid (); > > - > > - if (is_lwp (inferior_ptid)) > > - inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid)); > > - > > - fetch_inferior_registers (regno); > > - > > - do_cleanups (old_chain); > > -} > > - > > -static void > > -lin_lwp_store_registers (int regno) > > -{ > > - struct cleanup *old_chain = save_inferior_ptid (); > > - > > - if (is_lwp (inferior_ptid)) > > - inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid)); > > - > > - store_inferior_registers (regno); > > - > > - do_cleanups (old_chain); > > -} > > - > > static int > > lin_lwp_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, > > struct mem_attrib *attrib, > > @@ -1426,8 +1400,10 @@ init_lin_lwp_ops (void) > > lin_lwp_ops.to_detach = lin_lwp_detach; > > lin_lwp_ops.to_resume = lin_lwp_resume; > > lin_lwp_ops.to_wait = lin_lwp_wait; > > - lin_lwp_ops.to_fetch_registers = lin_lwp_fetch_registers; > > - lin_lwp_ops.to_store_registers = lin_lwp_store_registers; > > + /* fetch_inferior_registers and store_inferior_registers will > > + honor the LWP id, so we can use them directly. */ > > + lin_lwp_ops.to_fetch_registers = fetch_inferior_registers; > > + lin_lwp_ops.to_store_registers = store_inferior_registers; > > lin_lwp_ops.to_xfer_memory = lin_lwp_xfer_memory; > > lin_lwp_ops.to_kill = lin_lwp_kill; > > lin_lwp_ops.to_create_inferior = lin_lwp_create_inferior; > > Index: sparc-nat.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/sparc-nat.c,v > > retrieving revision 1.15 > > diff -u -p -r1.15 sparc-nat.c > > --- sparc-nat.c 14 Nov 2002 20:37:29 -0000 1.15 > > +++ sparc-nat.c 22 Nov 2002 02:35:31 -0000 > > @@ -1,5 +1,6 @@ > > /* Functions specific to running gdb native on a SPARC running SunOS4. > > - Copyright 1989, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000, 2001 > > + Copyright 1989, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000, 2001, > > + 2002 > > Free Software Foundation, Inc. > > > > This file is part of GDB. > > @@ -58,6 +59,11 @@ fetch_inferior_registers (int regno) > > struct regs inferior_registers; > > struct fp_status inferior_fp_registers; > > int i; > > + int fetch_pid; > > + > > + fetch_pid = TIDGET (inferior_ptid); > > + if (fetch_pid == 0) > > + fetch_pid = PIDGET (inferior_ptid); > > > > /* We should never be called with deferred stores, because a prerequisite > > for writing regs is to have fetched them all (PREPARE_TO_STORE), sigh. */ > > @@ -75,7 +81,7 @@ fetch_inferior_registers (int regno) > > || regno >= Y_REGNUM > > || (!deprecated_register_valid[SP_REGNUM] && regno < I7_REGNUM)) > > { > > - if (0 != ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid), > > + if (0 != ptrace (PTRACE_GETREGS, fetch_pid, > > (PTRACE_ARG3_TYPE) & inferior_registers, 0)) > > perror ("ptrace_getregs"); > > > > @@ -108,7 +114,7 @@ fetch_inferior_registers (int regno) > > regno == FPS_REGNUM || > > (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 31)) > > { > > - if (0 != ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid), > > + if (0 != ptrace (PTRACE_GETFPREGS, fetch_pid, > > (PTRACE_ARG3_TYPE) & inferior_fp_registers, > > 0)) > > perror ("ptrace_getfpregs"); > > @@ -153,6 +159,11 @@ store_inferior_registers (int regno) > > struct regs inferior_registers; > > struct fp_status inferior_fp_registers; > > int wanna_store = INT_REGS + STACK_REGS + FP_REGS; > > + int store_pid; > > + > > + store_pid = TIDGET (inferior_ptid); > > + if (store_pid == 0) > > + store_pid = PIDGET (inferior_ptid); > > > > /* First decide which pieces of machine-state we need to modify. > > Default for regno == -1 case is all pieces. */ > > @@ -236,7 +247,7 @@ store_inferior_registers (int regno) > > inferior_registers.r_y = > > *(int *) &deprecated_registers[REGISTER_BYTE (Y_REGNUM)]; > > > > - if (0 != ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid), > > + if (0 != ptrace (PTRACE_SETREGS, store_pid, > > (PTRACE_ARG3_TYPE) & inferior_registers, 0)) > > perror ("ptrace_setregs"); > > } > > @@ -252,7 +263,7 @@ store_inferior_registers (int regno) > > &deprecated_registers[REGISTER_BYTE (FPS_REGNUM)], > > sizeof (FPU_FSR_TYPE)); > > if (0 != > > - ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid), > > + ptrace (PTRACE_SETFPREGS, store_pid, > > (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0)) > > perror ("ptrace_setfpregs"); > > } > > > > -- > Daniel Jacobowitz > MontaVista Software Debian GNU/Linux Developer