1 <<<<<<< 2.6 is dead
>>>>>>>
2 /* Native-dependent code for Lynx running on i386's, for GDB.
3 Copyright 1988, 1989, 1991, 1992, 1993
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
27 #include <sys/ptrace.h>
28 #include "/usr/include/sys/wait.h"
30 /* these values indicate the offset of the named register in the econtext
48 /* Currently these are not being used. So set them to 0 */
53 /* this table must line up with REGISTER_NAMES in m-i386.h */
54 static unsigned int regmap
[] =
62 /* Return the address in the core dump or inferior of register REGNO.
63 BLOCKEND is the address of the econtext structure */
66 register_addr (regno
, blockend
)
69 if (regno
< 0 || regno
>= NUM_REGS
)
70 error ("Invalid register number %d.", regno
);
72 return (blockend
+ regmap
[regno
] * sizeof (long));
75 /* Fetch one register. */
78 fetch_register (regno
, offset
, bpid
)
83 char buf
[MAX_REGISTER_RAW_SIZE
];
84 char mess
[128]; /* For messages */
87 regaddr
= register_addr (regno
, offset
);
88 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof (int))
91 *(int *) &buf
[i
] = ptrace (PTRACE_PEEKTHREAD
, bpid
,
92 (PTRACE_ARG3_TYPE
) regaddr
, 0);
93 regaddr
+= sizeof (int);
96 sprintf (mess
, "reading register %s (#%d)", reg_names
[regno
], regno
);
97 perror_with_name (mess
);
100 supply_register (regno
, buf
);
103 /* Store our register values back into the inferior.
104 If REGNO is -1, do this for all registers.
105 Otherwise, REGNO specifies which register (so we can save time). */
108 store_register (regno
, offset
, bpid
)
112 unsigned int regaddr
;
114 extern char registers
[];
117 regaddr
= register_addr (regno
, offset
);
118 for (i
= 0; i
< REGISTER_RAW_SIZE (regno
); i
+= sizeof(int))
121 ptrace (PTRACE_POKEUSER
, bpid
, (PTRACE_ARG3_TYPE
) regaddr
,
122 *(int *) ®isters
[REGISTER_BYTE (regno
) + i
]);
125 sprintf (mess
, "writing register number %d(%d)", regno
, i
);
126 perror_with_name (mess
);
128 regaddr
+= sizeof(int);
132 /* return an offset for use with register_addr() */
139 unsigned int specpage_off
, offset
= (char *) &s
.ecp
- (char *) &s
;
142 specpage_off
= ptrace (PTRACE_THREADUSER
, pid
, (PTRACE_ARG3_TYPE
) 0, 0);
144 perror_with_name ("ptrace");
146 offset
= ptrace (PTRACE_PEEKTHREAD
, pid
, (PTRACE_ARG3_TYPE
) offset
, 0)
149 perror_with_name ("ptrace");
153 /* Fetch all registers, or just one, from the child process. */
156 fetch_inferior_registers (regno
)
159 unsigned int offset
= fetch_offset (inferior_pid
);
163 for (regno
= 0; regno
< NUM_REGS
; regno
++)
164 fetch_register (regno
, offset
, inferior_pid
);
167 fetch_register (regno
, offset
, inferior_pid
);
170 /* Store all registers, or just one, to the child process. */
173 store_inferior_registers (regno
)
176 unsigned int offset
= fetch_offset (inferior_pid
);
180 for (regno
= 0; regno
< NUM_REGS
; regno
++)
181 store_register (regno
, offset
, inferior_pid
);
184 store_register (regno
, offset
, inferior_pid
);
187 /* Wait for child to do something. Return pid of child, or -1 in case
188 of error; store status through argument pointer STATUS. */
191 child_wait (pid
, status
)
203 set_sigint_trap(); /* Causes SIGINT to be passed on to the
213 if (save_errno
== EINTR
)
215 fprintf_unfiltered (gdb_stderr
, "Child process unexpectedly missing: %s.\n",
216 safe_strerror (save_errno
));
217 *status
= 42; /* Claim it exited with signal 42 */
221 if (pid
!= PIDGET (inferior_pid
)) /* Some other process?!? */
224 /* thread = WIFTID (*status);*/
225 thread
= *status
>> 16;
227 /* Initial thread value can only be acquired via wait, so we have to
228 resort to this hack. */
230 if (TIDGET (inferior_pid
) == 0)
232 inferior_pid
= BUILDPID (inferior_pid
, thread
);
233 add_thread (inferior_pid
);
236 pid
= BUILDPID (pid
, thread
);
242 /* Convert a Lynx process ID to a string. Returns the string in a static
246 i386lynx_pid_to_str (pid
)
251 sprintf (buf
, "process %d thread %d", PIDGET (pid
), TIDGET (pid
));
256 /* Extract the register values out of the core file and store
257 them where `read_register' will find them.
259 CORE_REG_SECT points to the register values themselves, read into memory.
260 CORE_REG_SIZE is the size of that area.
261 WHICH says which set of registers we are handling (0 = int, 2 = float
262 on machines where they are discontiguous).
263 REG_ADDR is the offset from u.u_ar0 to the register values relative to
264 core_reg_sect. This is used with old-fashioned core files to
265 locate the registers in a large upage-plus-stack ".reg" section.
266 Original upage address X is at location core_reg_sect+x+reg_addr.
270 fetch_core_registers (core_reg_sect
, core_reg_size
, which
, reg_addr
)
272 unsigned core_reg_size
;
277 unsigned int regno
, addr
;
279 for (regno
= 0; regno
< NUM_REGS
; regno
++)
281 addr
= register_addr (regno
, (char *) &s
.ec
- (char *) &s
);
282 supply_register (regno
, core_reg_sect
+ addr
);
This page took 0.034479 seconds and 4 git commands to generate.