- 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. */
- if (deferred_stores)
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
-
- DO_DEFERRED_STORES;
-
- /* Global and Out regs are fetched directly, as well as the control
- registers. If we're getting one of the in or local regs,
- and the stack pointer has not yet been fetched,
- we have to do that first, since they're found in memory relative
- to the stack pointer. */
- if (regno < O7_REGNUM /* including -1 */
- || regno >= Y_REGNUM
- || (!deprecated_register_valid[SP_REGNUM] && regno < I7_REGNUM))
- {
- if (0 != ptrace (PTRACE_GETREGS, fetch_pid,
- (PTRACE_ARG3_TYPE) & inferior_registers, 0))
- perror ("ptrace_getregs");
-
- deprecated_registers[DEPRECATED_REGISTER_BYTE (0)] = 0;
- memcpy (&deprecated_registers[DEPRECATED_REGISTER_BYTE (1)],
- &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G0_REGNUM));
- *(int *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (PS_REGNUM)]
- = inferior_registers.r_ps;
- *(int *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (PC_REGNUM)]
- = inferior_registers.r_pc;
- *(int *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (NPC_REGNUM)]
- = inferior_registers.r_npc;
- *(int *) &deprecated_registers[DEPRECATED_REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y;
-
- for (i = G0_REGNUM; i <= O7_REGNUM; i++)
- deprecated_register_valid[i] = 1;
- deprecated_register_valid[Y_REGNUM] = 1;
- deprecated_register_valid[PS_REGNUM] = 1;
- deprecated_register_valid[PC_REGNUM] = 1;
- deprecated_register_valid[NPC_REGNUM] = 1;
- /* If we don't set these valid, read_register_bytes() rereads
- all the regs every time it is called! FIXME. */
- deprecated_register_valid[WIM_REGNUM] = 1; /* Not true yet, FIXME */
- deprecated_register_valid[TBR_REGNUM] = 1; /* Not true yet, FIXME */
- deprecated_register_valid[CPS_REGNUM] = 1; /* Not true yet, FIXME */
- }