diff options
author | Andrew Cagney <cagney@redhat.com> | 2002-12-04 03:20:30 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2002-12-04 03:20:30 +0000 |
commit | 02ae777101c4e5debdf1277352997702fd1d4961 (patch) | |
tree | dd5fbd5968f3db95edc66ff3bb46552a483206d7 /gdb | |
parent | 92806416b350aebd596e9a779b4d762430b2fb0a (diff) | |
download | gdb-02ae777101c4e5debdf1277352997702fd1d4961.zip gdb-02ae777101c4e5debdf1277352997702fd1d4961.tar.gz gdb-02ae777101c4e5debdf1277352997702fd1d4961.tar.bz2 |
2002-12-03 Andrew Cagney <ac131313@redhat.com>
* sparc-nat.c (fetch_inferior_registers)
(store_inferior_registers): Add comment on problem of LWP vs
threads.
From 2002-11-21 Daniel Jacobowitz <drow@mvista.com>
* 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.
Fix PR gdb/725.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/lin-lwp.c | 32 | ||||
-rw-r--r-- | gdb/sparc-nat.c | 37 |
3 files changed, 51 insertions, 33 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e23b20e..12d6a0f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,20 @@ 2002-12-03 Andrew Cagney <ac131313@redhat.com> + * sparc-nat.c (fetch_inferior_registers) + (store_inferior_registers): Add comment on problem of LWP vs + threads. + + From 2002-11-21 Daniel Jacobowitz <drow@mvista.com> + * 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. + Fix PR gdb/725. + +2002-12-03 Andrew Cagney <ac131313@redhat.com> + * frame.h (get_frame_id): Convert to a function. (null_frame_id, frame_id_p): Declare. (frame_id_eq, frame_id_inner): Declare. diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c index 88a10d8..444c221 100644 --- a/gdb/lin-lwp.c +++ b/gdb/lin-lwp.c @@ -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, @@ -1428,8 +1402,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; diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c index b2c6d41..5970b5a 100644 --- a/gdb/sparc-nat.c +++ b/gdb/sparc-nat.c @@ -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,25 @@ fetch_inferior_registers (int regno) struct regs inferior_registers; struct fp_status inferior_fp_registers; int i; + int fetch_pid; + + /* NOTE: cagney/2002-12-03: This code assumes that the currently + selected light weight processes' registers can be written + directly into the selected thread's register cache. This works + fine when given an 1:1 LWP:thread model (such as found on + GNU/Linux) but will, likely, have problems when used on an N:1 + (userland threads) or N:M (userland multiple LWP) model. In the + case of the latter two, the LWP's registers do not necessarily + belong to the selected thread (the LWP could be in the middle of + executing the thread switch code). + + These functions should instead be paramaterized with an explicit + object (struct regcache, struct thread_info?) into which the LWPs + registers can be written. */ + + 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 +95,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 +128,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 +173,13 @@ 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; + + /* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers + about threaded assumptions. */ + 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 +263,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 +279,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"); } |