Change defn of LOCAL_LABEL_PREFIX to ""
[external/binutils.git] / gdb / convex-xdep.c
1 /* OBSOLETE /* Convex host-dependent code for GDB. */
2 /* OBSOLETE    Copyright 1990, 1991, 1992 Free Software Foundation, Inc. */
3 /* OBSOLETE  */
4 /* OBSOLETE This file is part of GDB. */
5 /* OBSOLETE  */
6 /* OBSOLETE This program is free software; you can redistribute it and/or modify */
7 /* OBSOLETE it under the terms of the GNU General Public License as published by */
8 /* OBSOLETE the Free Software Foundation; either version 2 of the License, or */
9 /* OBSOLETE (at your option) any later version. */
10 /* OBSOLETE  */
11 /* OBSOLETE This program is distributed in the hope that it will be useful, */
12 /* OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
14 /* OBSOLETE GNU General Public License for more details. */
15 /* OBSOLETE  */
16 /* OBSOLETE You should have received a copy of the GNU General Public License */
17 /* OBSOLETE along with this program; if not, write to the Free Software */
18 /* OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  *x/ */
19 /* OBSOLETE  */
20 /* OBSOLETE #include "defs.h" */
21 /* OBSOLETE #include "command.h" */
22 /* OBSOLETE #include "symtab.h" */
23 /* OBSOLETE #include "value.h" */
24 /* OBSOLETE #include "frame.h" */
25 /* OBSOLETE #include "inferior.h" */
26 /* OBSOLETE #include "gdb_wait.h" */
27 /* OBSOLETE  */
28 /* OBSOLETE #include <signal.h> */
29 /* OBSOLETE #include <fcntl.h> */
30 /* OBSOLETE #include "gdbcore.h" */
31 /* OBSOLETE  */
32 /* OBSOLETE #include <sys/param.h> */
33 /* OBSOLETE #include <sys/dir.h> */
34 /* OBSOLETE #include <sys/user.h> */
35 /* OBSOLETE #include <sys/ioctl.h> */
36 /* OBSOLETE #include <sys/pcntl.h> */
37 /* OBSOLETE #include <sys/thread.h> */
38 /* OBSOLETE #include <sys/proc.h> */
39 /* OBSOLETE #include <sys/file.h> */
40 /* OBSOLETE #include "gdb_stat.h" */
41 /* OBSOLETE #include <sys/mman.h> */
42 /* OBSOLETE  */
43 /* OBSOLETE #include <convex/vmparam.h> */
44 /* OBSOLETE #include <convex/filehdr.h> */
45 /* OBSOLETE #include <convex/opthdr.h> */
46 /* OBSOLETE #include <convex/scnhdr.h> */
47 /* OBSOLETE #include <convex/core.h> */
48 /* OBSOLETE  */
49 /* OBSOLETE /* Per-thread data, read from the inferior at each stop and written */
50 /* OBSOLETE    back at each resume.  *x/ */
51 /* OBSOLETE  */
52 /* OBSOLETE /* Number of active threads. */
53 /* OBSOLETE    Tables are valid for thread numbers less than this.  *x/ */
54 /* OBSOLETE  */
55 /* OBSOLETE static int n_threads; */
56 /* OBSOLETE  */
57 /* OBSOLETE #define MAXTHREADS 8 */
58 /* OBSOLETE              */
59 /* OBSOLETE /* Thread state.  The remaining data is valid only if this is PI_TALIVE.  *x/ */
60 /* OBSOLETE  */
61 /* OBSOLETE static int thread_state[MAXTHREADS]; */
62 /* OBSOLETE  */
63 /* OBSOLETE /* Stop pc, signal, signal subcode *x/ */
64 /* OBSOLETE  */
65 /* OBSOLETE static int thread_pc[MAXTHREADS]; */
66 /* OBSOLETE static int thread_signal[MAXTHREADS]; */
67 /* OBSOLETE static int thread_sigcode[MAXTHREADS];       */
68 /* OBSOLETE  */
69 /* OBSOLETE /* Thread registers. */
70 /* OBSOLETE    If thread is selected, the regs are in registers[] instead.  *x/ */
71 /* OBSOLETE  */
72 /* OBSOLETE static char thread_regs[MAXTHREADS][REGISTER_BYTES]; */
73 /* OBSOLETE  */
74 /* OBSOLETE /* 1 if the top frame on the thread's stack was a context frame, */
75 /* OBSOLETE    meaning that the kernel is up to something and we should not */
76 /* OBSOLETE    touch the thread at all except to resume it.  *x/ */
77 /* OBSOLETE  */
78 /* OBSOLETE static char thread_is_in_kernel[MAXTHREADS]; */
79 /* OBSOLETE  */
80 /* OBSOLETE /* The currently selected thread's number.  *x/ */
81 /* OBSOLETE  */
82 /* OBSOLETE static int inferior_thread; */
83 /* OBSOLETE  */
84 /* OBSOLETE /* Inferior process's file handle and a process control block */
85 /* OBSOLETE    to feed args to ioctl with.  *x/ */
86 /* OBSOLETE  */
87 /* OBSOLETE static int inferior_fd; */
88 /* OBSOLETE static struct pcntl ps; */
89 /* OBSOLETE  */
90 /* OBSOLETE /* SOFF file headers for exec or core file.  *x/ */
91 /* OBSOLETE  */
92 /* OBSOLETE static FILEHDR filehdr; */
93 /* OBSOLETE static OPTHDR opthdr; */
94 /* OBSOLETE static SCNHDR scnhdr; */
95 /* OBSOLETE  */
96 /* OBSOLETE /* Address maps constructed from section headers of exec and core files. */
97 /* OBSOLETE    Defines process address -> file address translation.  *x/ */
98 /* OBSOLETE  */
99 /* OBSOLETE struct pmap  */
100 /* OBSOLETE { */
101 /* OBSOLETE     long mem_addr;          /* process start address *x/ */
102 /* OBSOLETE     long mem_end;           /* process end+1 address *x/ */
103 /* OBSOLETE     long file_addr;         /* file start address *x/ */
104 /* OBSOLETE     long thread;            /* -1 shared; 0,1,... thread-local *x/ */
105 /* OBSOLETE     long type;                      /* S_TEXT S_DATA S_BSS S_TBSS etc *x/ */
106 /* OBSOLETE     long which;                     /* used to sort map for info files *x/ */
107 /* OBSOLETE }; */
108 /* OBSOLETE  */
109 /* OBSOLETE static int n_exec, n_core; */
110 /* OBSOLETE static struct pmap exec_map[100]; */
111 /* OBSOLETE static struct pmap core_map[100]; */
112 /* OBSOLETE  */
113 /* OBSOLETE /* Offsets in the core file of core_context and core_tcontext blocks.  *x/ */
114 /* OBSOLETE  */
115 /* OBSOLETE static int context_offset; */
116 /* OBSOLETE static int tcontext_offset[MAXTHREADS]; */
117 /* OBSOLETE  */
118 /* OBSOLETE /* Core file control blocks.  *x/ */
119 /* OBSOLETE  */
120 /* OBSOLETE static struct core_context_v70 c; */
121 /* OBSOLETE static struct core_tcontext_v70 tc; */
122 /* OBSOLETE static struct user u; */
123 /* OBSOLETE static thread_t th; */
124 /* OBSOLETE static proc_t pr; */
125 /* OBSOLETE  */
126 /* OBSOLETE  */
127 /* OBSOLETE /* Vector and communication registers from core dump or from inferior. */
128 /* OBSOLETE    These are read on demand, ie, not normally valid.  *x/ */
129 /* OBSOLETE  */
130 /* OBSOLETE static struct vecst vector_registers; */
131 /* OBSOLETE static struct creg_ctx comm_registers; */
132 /* OBSOLETE  */
133 /* OBSOLETE /* Flag, set on a vanilla CONT command and cleared when the inferior */
134 /* OBSOLETE    is continued.  *x/ */
135 /* OBSOLETE  */
136 /* OBSOLETE static int all_continue; */
137 /* OBSOLETE  */
138 /* OBSOLETE /* Flag, set when the inferior is continued by a vanilla CONT command, */
139 /* OBSOLETE    cleared if it is continued for any other purpose.  *x/ */
140 /* OBSOLETE  */
141 /* OBSOLETE static int thread_switch_ok; */
142 /* OBSOLETE  */
143 /* OBSOLETE /* Stack of signals recieved from threads but not yet delivered to gdb.  *x/ */
144 /* OBSOLETE  */
145 /* OBSOLETE struct threadpid  */
146 /* OBSOLETE { */
147 /* OBSOLETE     int pid; */
148 /* OBSOLETE     int thread; */
149 /* OBSOLETE     int signo; */
150 /* OBSOLETE     int subsig; */
151 /* OBSOLETE     int pc; */
152 /* OBSOLETE }; */
153 /* OBSOLETE  */
154 /* OBSOLETE static struct threadpid signal_stack_bot[100]; */
155 /* OBSOLETE static struct threadpid *signal_stack = signal_stack_bot; */
156 /* OBSOLETE  */
157 /* OBSOLETE /* How to detect empty stack -- bottom frame is all zero.  *x/ */
158 /* OBSOLETE  */
159 /* OBSOLETE #define signal_stack_is_empty() (signal_stack->pid == 0) */
160 /* OBSOLETE  */
161 /* OBSOLETE /* Mode controlled by SET PIPE command, controls the psw SEQ bit */
162 /* OBSOLETE    which forces each instruction to complete before the next one starts.  *x/ */
163 /* OBSOLETE  */
164 /* OBSOLETE static int sequential = 0; */
165 /* OBSOLETE  */
166 /* OBSOLETE /* Mode controlled by the SET PARALLEL command.  Values are: */
167 /* OBSOLETE    0  concurrency limit 1 thread, dynamic scheduling */
168 /* OBSOLETE    1  no concurrency limit, dynamic scheduling */
169 /* OBSOLETE    2  no concurrency limit, fixed scheduling  *x/ */
170 /* OBSOLETE  */
171 /* OBSOLETE static int parallel = 1; */
172 /* OBSOLETE  */
173 /* OBSOLETE /* Mode controlled by SET BASE command, output radix for unformatted */
174 /* OBSOLETE    integer typeout, as in argument lists, aggregates, and so on. */
175 /* OBSOLETE    Zero means guess whether it's an address (hex) or not (decimal).  *x/ */
176 /* OBSOLETE  */
177 /* OBSOLETE static int output_radix = 0; */
178 /* OBSOLETE  */
179 /* OBSOLETE /* Signal subcode at last thread stop.  *x/ */
180 /* OBSOLETE  */
181 /* OBSOLETE static int stop_sigcode; */
182 /* OBSOLETE  */
183 /* OBSOLETE /* Hack, see wait() below.  *x/ */
184 /* OBSOLETE  */
185 /* OBSOLETE static int exec_trap_timer; */
186 /* OBSOLETE  */
187 /* OBSOLETE #include "gdbcmd.h" */
188 /* OBSOLETE  */
189 /* OBSOLETE static struct type *vector_type (); */
190 /* OBSOLETE static long *read_vector_register (); */
191 /* OBSOLETE static long *read_vector_register_1 (); */
192 /* OBSOLETE static void write_vector_register (); */
193 /* OBSOLETE static ULONGEST read_comm_register (); */
194 /* OBSOLETE static void write_comm_register (); */
195 /* OBSOLETE static void convex_cont_command (); */
196 /* OBSOLETE static void thread_continue (); */
197 /* OBSOLETE static void select_thread (); */
198 /* OBSOLETE static void scan_stack (); */
199 /* OBSOLETE static void set_fixed_scheduling (); */
200 /* OBSOLETE static char *subsig_name (); */
201 /* OBSOLETE static void psw_info (); */
202 /* OBSOLETE static sig_noop (); */
203 /* OBSOLETE static ptr_cmp (); */
204 /* OBSOLETE  */
205 /* OBSOLETE \f */
206 /* OBSOLETE /* Execute ptrace.  Convex V7 replaced ptrace with pattach. */
207 /* OBSOLETE    Allow ptrace (0) as a no-op.  *x/ */
208 /* OBSOLETE  */
209 /* OBSOLETE int */
210 /* OBSOLETE call_ptrace (request, pid, procaddr, buf) */
211 /* OBSOLETE      int request, pid; */
212 /* OBSOLETE      PTRACE_ARG3_TYPE procaddr; */
213 /* OBSOLETE      int buf; */
214 /* OBSOLETE { */
215 /* OBSOLETE   if (request == 0) */
216 /* OBSOLETE     return; */
217 /* OBSOLETE   error ("no ptrace"); */
218 /* OBSOLETE } */
219 /* OBSOLETE  */
220 /* OBSOLETE /* Replacement for system execle routine. */
221 /* OBSOLETE    Convert it to an equivalent exect, which pattach insists on.  *x/ */
222 /* OBSOLETE  */
223 /* OBSOLETE execle (name, argv) */
224 /* OBSOLETE      char *name, *argv; */
225 /* OBSOLETE { */
226 /* OBSOLETE   char ***envp = (char ***) &argv; */
227 /* OBSOLETE   while (*envp++) ; */
228 /* OBSOLETE  */
229 /* OBSOLETE   signal (SIGTRAP, sig_noop); */
230 /* OBSOLETE   exect (name, &argv, *envp); */
231 /* OBSOLETE } */
232 /* OBSOLETE  */
233 /* OBSOLETE /* Stupid handler for stupid trace trap that otherwise causes */
234 /* OBSOLETE    startup to stupidly hang.  *x/ */
235 /* OBSOLETE  */
236 /* OBSOLETE static sig_noop ()  */
237 /* OBSOLETE {} */
238 /* OBSOLETE  */
239 /* OBSOLETE /* Read registers from inferior into registers[] array. */
240 /* OBSOLETE    For convex, they are already there, read in when the inferior stops.  *x/ */
241 /* OBSOLETE  */
242 /* OBSOLETE void */
243 /* OBSOLETE fetch_inferior_registers (regno) */
244 /* OBSOLETE      int regno; */
245 /* OBSOLETE { */
246 /* OBSOLETE } */
247 /* OBSOLETE  */
248 /* OBSOLETE /* Store our register values back into the inferior. */
249 /* OBSOLETE    For Convex, do this only once, right before resuming inferior.  *x/ */
250 /* OBSOLETE  */
251 /* OBSOLETE void */
252 /* OBSOLETE store_inferior_registers (regno) */
253 /* OBSOLETE      int regno; */
254 /* OBSOLETE { */
255 /* OBSOLETE } */
256 /* OBSOLETE  */
257 /* OBSOLETE /* Copy LEN bytes from inferior's memory starting at MEMADDR */
258 /* OBSOLETE    to debugger memory starting at MYADDR.  */
259 /* OBSOLETE    On failure (cannot read from inferior, usually because address is out */
260 /* OBSOLETE    of bounds) returns the value of errno. *x/ */
261 /* OBSOLETE  */
262 /* OBSOLETE int */
263 /* OBSOLETE read_inferior_memory (memaddr, myaddr, len) */
264 /* OBSOLETE      CORE_ADDR memaddr; */
265 /* OBSOLETE      char *myaddr; */
266 /* OBSOLETE      int len; */
267 /* OBSOLETE { */
268 /* OBSOLETE   errno = 0; */
269 /* OBSOLETE   while (len > 0) */
270 /* OBSOLETE     { */
271 /* OBSOLETE       /* little-known undocumented max request size *x/ */
272 /* OBSOLETE       int i = (len < 12288) ? len : 12288; */
273 /* OBSOLETE  */
274 /* OBSOLETE       lseek (inferior_fd, memaddr, 0); */
275 /* OBSOLETE       read (inferior_fd, myaddr, i); */
276 /* OBSOLETE  */
277 /* OBSOLETE       memaddr += i; */
278 /* OBSOLETE       myaddr += i; */
279 /* OBSOLETE       len -= i; */
280 /* OBSOLETE     } */
281 /* OBSOLETE   if (errno)  */
282 /* OBSOLETE     memset (myaddr, '\0', len); */
283 /* OBSOLETE   return errno; */
284 /* OBSOLETE } */
285 /* OBSOLETE  */
286 /* OBSOLETE /* Copy LEN bytes of data from debugger memory at MYADDR */
287 /* OBSOLETE    to inferior's memory at MEMADDR. */
288 /* OBSOLETE    Returns errno on failure (cannot write the inferior) *x/ */
289 /* OBSOLETE  */
290 /* OBSOLETE int */
291 /* OBSOLETE write_inferior_memory (memaddr, myaddr, len) */
292 /* OBSOLETE      CORE_ADDR memaddr; */
293 /* OBSOLETE      char *myaddr; */
294 /* OBSOLETE      int len; */
295 /* OBSOLETE { */
296 /* OBSOLETE   errno = 0; */
297 /* OBSOLETE   lseek (inferior_fd, memaddr, 0); */
298 /* OBSOLETE   write (inferior_fd, myaddr, len); */
299 /* OBSOLETE   return errno; */
300 /* OBSOLETE } */
301 /* OBSOLETE  */
302 /* OBSOLETE /* Here from create_inferior when the inferior process has been created */
303 /* OBSOLETE    and started up.  We must do a pattach to grab it for debugging. */
304 /* OBSOLETE  */
305 /* OBSOLETE    Also, intercept the CONT command by altering its dispatch address.  *x/ */
306 /* OBSOLETE /* FIXME: This used to be called from a macro CREATE_INFERIOR_HOOK. */
307 /* OBSOLETE    But now init_trace_fun is in the same place.  So re-write this to */
308 /* OBSOLETE    use the init_trace_fun (making convex a debugging target).  *x/ */
309 /* OBSOLETE  */
310 /* OBSOLETE create_inferior_hook (pid) */
311 /* OBSOLETE     int pid; */
312 /* OBSOLETE { */
313 /* OBSOLETE   static char cont[] = "cont"; */
314 /* OBSOLETE   static char cont1[] = "c"; */
315 /* OBSOLETE   char *linep = cont; */
316 /* OBSOLETE   char *linep1 = cont1; */
317 /* OBSOLETE   char **line = &linep; */
318 /* OBSOLETE   char **line1 = &linep1; */
319 /* OBSOLETE   struct cmd_list_element *c; */
320 /* OBSOLETE  */
321 /* OBSOLETE   c = lookup_cmd (line, cmdlist, "", 0); */
322 /* OBSOLETE   c->function = convex_cont_command; */
323 /* OBSOLETE   c = lookup_cmd (line1, cmdlist, "", 0); */
324 /* OBSOLETE   c->function = convex_cont_command; */
325 /* OBSOLETE  */
326 /* OBSOLETE   inferior_fd = pattach (pid, O_EXCL); */
327 /* OBSOLETE   if (inferior_fd < 0) */
328 /* OBSOLETE     perror_with_name ("pattach"); */
329 /* OBSOLETE   inferior_thread = 0; */
330 /* OBSOLETE   set_fixed_scheduling (pid, parallel == 2); */
331 /* OBSOLETE } */
332 /* OBSOLETE  */
333 /* OBSOLETE /* Attach process PID for debugging.  *x/ */
334 /* OBSOLETE  */
335 /* OBSOLETE attach (pid) */
336 /* OBSOLETE     int pid; */
337 /* OBSOLETE { */
338 /* OBSOLETE   int fd = pattach (pid, O_EXCL); */
339 /* OBSOLETE   if (fd < 0) */
340 /* OBSOLETE     perror_with_name ("pattach"); */
341 /* OBSOLETE   attach_flag = 1; */
342 /* OBSOLETE   /* wait for strange kernel reverberations to go away *x/ */
343 /* OBSOLETE   sleep (1); */
344 /* OBSOLETE  */
345 /* OBSOLETE   setpgrp (pid, pid); */
346 /* OBSOLETE  */
347 /* OBSOLETE   inferior_fd = fd; */
348 /* OBSOLETE   inferior_thread = 0; */
349 /* OBSOLETE   return pid; */
350 /* OBSOLETE } */
351 /* OBSOLETE  */
352 /* OBSOLETE /* Stop debugging the process whose number is PID */
353 /* OBSOLETE    and continue it with signal number SIGNAL. */
354 /* OBSOLETE    SIGNAL = 0 means just continue it.  *x/ */
355 /* OBSOLETE  */
356 /* OBSOLETE void */
357 /* OBSOLETE detach (signal) */
358 /* OBSOLETE      int signal; */
359 /* OBSOLETE { */
360 /* OBSOLETE   signal_stack = signal_stack_bot; */
361 /* OBSOLETE   thread_continue (-1, 0, signal); */
362 /* OBSOLETE   ioctl (inferior_fd, PIXDETACH, &ps); */
363 /* OBSOLETE   close (inferior_fd); */
364 /* OBSOLETE   inferior_fd = 0; */
365 /* OBSOLETE   attach_flag = 0; */
366 /* OBSOLETE } */
367 /* OBSOLETE  */
368 /* OBSOLETE /* Kill off the inferior process.  *x/ */
369 /* OBSOLETE  */
370 /* OBSOLETE kill_inferior () */
371 /* OBSOLETE { */
372 /* OBSOLETE   if (inferior_pid == 0) */
373 /* OBSOLETE     return; */
374 /* OBSOLETE   ioctl (inferior_fd, PIXTERMINATE, 0); */
375 /* OBSOLETE   wait (0); */
376 /* OBSOLETE   target_mourn_inferior (); */
377 /* OBSOLETE } */
378 /* OBSOLETE  */
379 /* OBSOLETE /* Read vector register REG, and return a pointer to the value.  *x/ */
380 /* OBSOLETE  */
381 /* OBSOLETE static long * */
382 /* OBSOLETE read_vector_register (reg) */
383 /* OBSOLETE     int reg; */
384 /* OBSOLETE { */
385 /* OBSOLETE   if (have_inferior_p ()) */
386 /* OBSOLETE     { */
387 /* OBSOLETE       errno = 0; */
388 /* OBSOLETE       ps.pi_buffer = (char *) &vector_registers; */
389 /* OBSOLETE       ps.pi_nbytes = sizeof vector_registers; */
390 /* OBSOLETE       ps.pi_offset = 0; */
391 /* OBSOLETE       ps.pi_thread = inferior_thread; */
392 /* OBSOLETE       ioctl (inferior_fd, PIXRDVREGS, &ps); */
393 /* OBSOLETE       if (errno) */
394 /* OBSOLETE     memset (&vector_registers, '\0', sizeof vector_registers); */
395 /* OBSOLETE     } */
396 /* OBSOLETE   else if (corechan >= 0) */
397 /* OBSOLETE     { */
398 /* OBSOLETE       lseek (corechan, tcontext_offset[inferior_thread], 0); */
399 /* OBSOLETE       if (myread (corechan, &tc, sizeof tc) < 0) */
400 /* OBSOLETE     perror_with_name (corefile); */
401 /* OBSOLETE       lseek (corechan, tc.core_thread_p, 0); */
402 /* OBSOLETE       if (myread (corechan, &th, sizeof th) < 0) */
403 /* OBSOLETE     perror_with_name (corefile); */
404 /* OBSOLETE       lseek (corechan, tc.core_vregs_p, 0); */
405 /* OBSOLETE       if (myread (corechan, &vector_registers, 16*128) < 0) */
406 /* OBSOLETE     perror_with_name (corefile); */
407 /* OBSOLETE       vector_registers.vm[0] = th.t_vect_ctx.vc_vm[0]; */
408 /* OBSOLETE       vector_registers.vm[1] = th.t_vect_ctx.vc_vm[1]; */
409 /* OBSOLETE       vector_registers.vls = th.t_vect_ctx.vc_vls; */
410 /* OBSOLETE     } */
411 /* OBSOLETE  */
412 /* OBSOLETE   return read_vector_register_1 (reg); */
413 /* OBSOLETE } */
414 /* OBSOLETE  */
415 /* OBSOLETE /* Return a pointer to vector register REG, which must already have been */
416 /* OBSOLETE    fetched from the inferior or core file.  *x/ */
417 /* OBSOLETE  */
418 /* OBSOLETE static long * */
419 /* OBSOLETE read_vector_register_1 (reg)  */
420 /* OBSOLETE     int reg; */
421 /* OBSOLETE { */
422 /* OBSOLETE   switch (reg) */
423 /* OBSOLETE     { */
424 /* OBSOLETE     case VM_REGNUM: */
425 /* OBSOLETE       return (long *) vector_registers.vm; */
426 /* OBSOLETE     case VS_REGNUM: */
427 /* OBSOLETE       return (long *) &vector_registers.vls; */
428 /* OBSOLETE     case VL_REGNUM: */
429 /* OBSOLETE       return 1 + (long *) &vector_registers.vls; */
430 /* OBSOLETE     default: */
431 /* OBSOLETE       return (long *) &vector_registers.vr[reg]; */
432 /* OBSOLETE     } */
433 /* OBSOLETE } */
434 /* OBSOLETE  */
435 /* OBSOLETE /* Write vector register REG, element ELEMENT, new value VAL. */
436 /* OBSOLETE    NB: must use read-modify-write on the entire vector state, */
437 /* OBSOLETE    since pattach does not do offsetted writes correctly.  *x/ */
438 /* OBSOLETE  */
439 /* OBSOLETE static void */
440 /* OBSOLETE write_vector_register (reg, element, val) */
441 /* OBSOLETE     int reg, element; */
442 /* OBSOLETE     ULONGEST val; */
443 /* OBSOLETE { */
444 /* OBSOLETE   if (have_inferior_p ()) */
445 /* OBSOLETE     { */
446 /* OBSOLETE       errno = 0; */
447 /* OBSOLETE       ps.pi_thread = inferior_thread; */
448 /* OBSOLETE       ps.pi_offset = 0; */
449 /* OBSOLETE       ps.pi_buffer = (char *) &vector_registers; */
450 /* OBSOLETE       ps.pi_nbytes = sizeof vector_registers; */
451 /* OBSOLETE  */
452 /* OBSOLETE       ioctl (inferior_fd, PIXRDVREGS, &ps); */
453 /* OBSOLETE  */
454 /* OBSOLETE       switch (reg) */
455 /* OBSOLETE     { */
456 /* OBSOLETE     case VL_REGNUM: */
457 /* OBSOLETE       vector_registers.vls = */
458 /* OBSOLETE         (vector_registers.vls & 0xffffffff00000000LL) */
459 /* OBSOLETE           + (unsigned long) val; */
460 /* OBSOLETE       break; */
461 /* OBSOLETE  */
462 /* OBSOLETE     case VS_REGNUM: */
463 /* OBSOLETE       vector_registers.vls = */
464 /* OBSOLETE         (val << 32) + (unsigned long) vector_registers.vls; */
465 /* OBSOLETE       break; */
466 /* OBSOLETE          */
467 /* OBSOLETE     default: */
468 /* OBSOLETE       vector_registers.vr[reg].el[element] = val; */
469 /* OBSOLETE       break; */
470 /* OBSOLETE     } */
471 /* OBSOLETE  */
472 /* OBSOLETE       ioctl (inferior_fd, PIXWRVREGS, &ps); */
473 /* OBSOLETE  */
474 /* OBSOLETE       if (errno) */
475 /* OBSOLETE     perror_with_name ("writing vector register"); */
476 /* OBSOLETE     } */
477 /* OBSOLETE } */
478 /* OBSOLETE  */
479 /* OBSOLETE /* Return the contents of communication register NUM.  *x/  */
480 /* OBSOLETE  */
481 /* OBSOLETE static ULONGEST  */
482 /* OBSOLETE read_comm_register (num) */
483 /* OBSOLETE      int num; */
484 /* OBSOLETE { */
485 /* OBSOLETE   if (have_inferior_p ()) */
486 /* OBSOLETE     { */
487 /* OBSOLETE       ps.pi_buffer = (char *) &comm_registers; */
488 /* OBSOLETE       ps.pi_nbytes = sizeof comm_registers; */
489 /* OBSOLETE       ps.pi_offset = 0; */
490 /* OBSOLETE       ps.pi_thread = inferior_thread; */
491 /* OBSOLETE       ioctl (inferior_fd, PIXRDCREGS, &ps); */
492 /* OBSOLETE     } */
493 /* OBSOLETE   return comm_registers.crreg.r4[num]; */
494 /* OBSOLETE } */
495 /* OBSOLETE  */
496 /* OBSOLETE /* Store a new value VAL into communication register NUM.   */
497 /* OBSOLETE    NB: Must use read-modify-write on the whole comm register set */
498 /* OBSOLETE    since pattach does not do offsetted writes correctly.  *x/ */
499 /* OBSOLETE  */
500 /* OBSOLETE static void */
501 /* OBSOLETE write_comm_register (num, val) */
502 /* OBSOLETE      int num; */
503 /* OBSOLETE      ULONGEST val; */
504 /* OBSOLETE { */
505 /* OBSOLETE   if (have_inferior_p ()) */
506 /* OBSOLETE     { */
507 /* OBSOLETE       ps.pi_buffer = (char *) &comm_registers; */
508 /* OBSOLETE       ps.pi_nbytes = sizeof comm_registers; */
509 /* OBSOLETE       ps.pi_offset = 0; */
510 /* OBSOLETE       ps.pi_thread = inferior_thread; */
511 /* OBSOLETE       ioctl (inferior_fd, PIXRDCREGS, &ps); */
512 /* OBSOLETE       comm_registers.crreg.r4[num] = val; */
513 /* OBSOLETE       ioctl (inferior_fd, PIXWRCREGS, &ps); */
514 /* OBSOLETE     } */
515 /* OBSOLETE } */
516 /* OBSOLETE  */
517 /* OBSOLETE /* Resume execution of the inferior process. */
518 /* OBSOLETE    If STEP is nonzero, single-step it. */
519 /* OBSOLETE    If SIGNAL is nonzero, give it that signal.  *x/ */
520 /* OBSOLETE  */
521 /* OBSOLETE void */
522 /* OBSOLETE resume (step, signal) */
523 /* OBSOLETE      int step; */
524 /* OBSOLETE      int signal; */
525 /* OBSOLETE { */
526 /* OBSOLETE   errno = 0; */
527 /* OBSOLETE   if (step || signal) */
528 /* OBSOLETE     thread_continue (inferior_thread, step, signal); */
529 /* OBSOLETE   else */
530 /* OBSOLETE     thread_continue (-1, 0, 0); */
531 /* OBSOLETE } */
532 /* OBSOLETE  */
533 /* OBSOLETE /* Maybe resume some threads. */
534 /* OBSOLETE    THREAD is which thread to resume, or -1 to resume them all. */
535 /* OBSOLETE    STEP and SIGNAL are as in resume. */
536 /* OBSOLETE  */
537 /* OBSOLETE    Global variable ALL_CONTINUE is set when we are here to do a */
538 /* OBSOLETE    `cont' command; otherwise we may be doing `finish' or a call or */
539 /* OBSOLETE    something else that will not tolerate an automatic thread switch. */
540 /* OBSOLETE  */
541 /* OBSOLETE    If there are stopped threads waiting to deliver signals, and */
542 /* OBSOLETE    ALL_CONTINUE, do not actually resume anything.  gdb will do a wait */
543 /* OBSOLETE    and see one of the stopped threads in the queue.  *x/ */
544 /* OBSOLETE  */
545 /* OBSOLETE static void */
546 /* OBSOLETE thread_continue (thread, step, signal) */
547 /* OBSOLETE      int thread, step, signal; */
548 /* OBSOLETE { */
549 /* OBSOLETE   int n; */
550 /* OBSOLETE  */
551 /* OBSOLETE   /* If we are to continue all threads, but not for the CONTINUE command, */
552 /* OBSOLETE      pay no attention and continue only the selected thread.  *x/ */
553 /* OBSOLETE  */
554 /* OBSOLETE   if (thread < 0 && ! all_continue) */
555 /* OBSOLETE     thread = inferior_thread; */
556 /* OBSOLETE  */
557 /* OBSOLETE   /* If we are not stepping, we have now executed the continue part */
558 /* OBSOLETE      of a CONTINUE command.  *x/ */
559 /* OBSOLETE  */
560 /* OBSOLETE   if (! step) */
561 /* OBSOLETE     all_continue = 0; */
562 /* OBSOLETE  */
563 /* OBSOLETE   /* Allow wait() to switch threads if this is an all-out continue.  *x/ */
564 /* OBSOLETE  */
565 /* OBSOLETE   thread_switch_ok = thread < 0; */
566 /* OBSOLETE  */
567 /* OBSOLETE   /* If there are threads queued up, don't resume.  *x/ */
568 /* OBSOLETE  */
569 /* OBSOLETE   if (thread_switch_ok && ! signal_stack_is_empty ()) */
570 /* OBSOLETE     return; */
571 /* OBSOLETE  */
572 /* OBSOLETE   /* OK, do it.  *x/ */
573 /* OBSOLETE  */
574 /* OBSOLETE   for (n = 0; n < n_threads; n++) */
575 /* OBSOLETE     if (thread_state[n] == PI_TALIVE) */
576 /* OBSOLETE       { */
577 /* OBSOLETE     select_thread (n); */
578 /* OBSOLETE  */
579 /* OBSOLETE     if ((thread < 0 || n == thread) && ! thread_is_in_kernel[n]) */
580 /* OBSOLETE       { */
581 /* OBSOLETE         /* Blam the trace bits in the stack's saved psws to match  */
582 /* OBSOLETE            the desired step mode.  This is required so that */
583 /* OBSOLETE            single-stepping a return doesn't restore a psw with a */
584 /* OBSOLETE            clear trace bit and fly away, and conversely, */
585 /* OBSOLETE            proceeding through a return in a routine that was */
586 /* OBSOLETE            stepped into doesn't cause a phantom break by restoring */
587 /* OBSOLETE            a psw with the trace bit set. *x/ */
588 /* OBSOLETE         scan_stack (PSW_T_BIT, step); */
589 /* OBSOLETE         scan_stack (PSW_S_BIT, sequential); */
590 /* OBSOLETE       } */
591 /* OBSOLETE  */
592 /* OBSOLETE     ps.pi_buffer = registers; */
593 /* OBSOLETE     ps.pi_nbytes = REGISTER_BYTES; */
594 /* OBSOLETE     ps.pi_offset = 0; */
595 /* OBSOLETE     ps.pi_thread = n; */
596 /* OBSOLETE     if (! thread_is_in_kernel[n]) */
597 /* OBSOLETE       if (ioctl (inferior_fd, PIXWRREGS, &ps)) */
598 /* OBSOLETE         perror_with_name ("PIXWRREGS"); */
599 /* OBSOLETE  */
600 /* OBSOLETE     if (thread < 0 || n == thread) */
601 /* OBSOLETE       { */
602 /* OBSOLETE         ps.pi_pc = 1; */
603 /* OBSOLETE         ps.pi_signo = signal; */
604 /* OBSOLETE         if (ioctl (inferior_fd, step ? PIXSTEP : PIXCONTINUE, &ps) < 0) */
605 /* OBSOLETE           perror_with_name ("PIXCONTINUE"); */
606 /* OBSOLETE       } */
607 /* OBSOLETE       } */
608 /* OBSOLETE  */
609 /* OBSOLETE   if (ioctl (inferior_fd, PIXRUN, &ps) < 0) */
610 /* OBSOLETE     perror_with_name ("PIXRUN"); */
611 /* OBSOLETE } */
612 /* OBSOLETE  */
613 /* OBSOLETE /* Replacement for system wait routine.   */
614 /* OBSOLETE  */
615 /* OBSOLETE    The system wait returns with one or more threads stopped by */
616 /* OBSOLETE    signals.  Put stopped threads on a stack and return them one by */
617 /* OBSOLETE    one, so that it appears that wait returns one thread at a time. */
618 /* OBSOLETE  */
619 /* OBSOLETE    Global variable THREAD_SWITCH_OK is set when gdb can tolerate wait */
620 /* OBSOLETE    returning a new thread.  If it is false, then only one thread is */
621 /* OBSOLETE    running; we will do a real wait, the thread will do something, and */
622 /* OBSOLETE    we will return that.  *x/ */
623 /* OBSOLETE  */
624 /* OBSOLETE pid_t */
625 /* OBSOLETE wait (w) */
626 /* OBSOLETE     union wait *w; */
627 /* OBSOLETE { */
628 /* OBSOLETE   int pid; */
629 /* OBSOLETE  */
630 /* OBSOLETE   if (!w) */
631 /* OBSOLETE     return wait3 (0, 0, 0); */
632 /* OBSOLETE  */
633 /* OBSOLETE   /* Do a real wait if we were told to, or if there are no queued threads.  *x/ */
634 /* OBSOLETE  */
635 /* OBSOLETE   if (! thread_switch_ok || signal_stack_is_empty ()) */
636 /* OBSOLETE     { */
637 /* OBSOLETE       int thread; */
638 /* OBSOLETE  */
639 /* OBSOLETE       pid = wait3 (w, 0, 0); */
640 /* OBSOLETE  */
641 /* OBSOLETE       if (!WIFSTOPPED (*w) || pid != inferior_pid) */
642 /* OBSOLETE     return pid; */
643 /* OBSOLETE  */
644 /* OBSOLETE       /* The inferior has done something and stopped.  Read in all the */
645 /* OBSOLETE      threads' registers, and queue up any signals that happened.  *x/ */
646 /* OBSOLETE  */
647 /* OBSOLETE       if (ioctl (inferior_fd, PIXGETTHCOUNT, &ps) < 0) */
648 /* OBSOLETE     perror_with_name ("PIXGETTHCOUNT"); */
649 /* OBSOLETE        */
650 /* OBSOLETE       n_threads = ps.pi_othdcnt; */
651 /* OBSOLETE       for (thread = 0; thread < n_threads; thread++) */
652 /* OBSOLETE     { */
653 /* OBSOLETE       ps.pi_thread = thread; */
654 /* OBSOLETE       if (ioctl (inferior_fd, PIXGETSUBCODE, &ps) < 0) */
655 /* OBSOLETE         perror_with_name ("PIXGETSUBCODE"); */
656 /* OBSOLETE       thread_state[thread] = ps.pi_otstate; */
657 /* OBSOLETE  */
658 /* OBSOLETE       if (ps.pi_otstate == PI_TALIVE) */
659 /* OBSOLETE         { */
660 /* OBSOLETE           select_thread (thread); */
661 /* OBSOLETE           ps.pi_buffer = registers; */
662 /* OBSOLETE           ps.pi_nbytes = REGISTER_BYTES; */
663 /* OBSOLETE           ps.pi_offset = 0; */
664 /* OBSOLETE           ps.pi_thread = thread; */
665 /* OBSOLETE           if (ioctl (inferior_fd, PIXRDREGS, &ps) < 0) */
666 /* OBSOLETE             perror_with_name ("PIXRDREGS"); */
667 /* OBSOLETE  */
668 /* OBSOLETE           registers_fetched (); */
669 /* OBSOLETE  */
670 /* OBSOLETE           thread_pc[thread] = read_pc (); */
671 /* OBSOLETE           thread_signal[thread] = ps.pi_osigno; */
672 /* OBSOLETE           thread_sigcode[thread] = ps.pi_osigcode; */
673 /* OBSOLETE  */
674 /* OBSOLETE           /* If the thread's stack has a context frame */
675 /* OBSOLETE              on top, something fucked is going on.  I do not */
676 /* OBSOLETE              know what, but do I know this: the only thing you */
677 /* OBSOLETE              can do with such a thread is continue it.  *x/ */
678 /* OBSOLETE  */
679 /* OBSOLETE           thread_is_in_kernel[thread] =  */
680 /* OBSOLETE             ((read_register (PS_REGNUM) >> 25) & 3) == 0; */
681 /* OBSOLETE  */
682 /* OBSOLETE           /* Signals push an extended frame and then fault */
683 /* OBSOLETE              with a ridiculous pc.  Pop the frame.  *x/ */
684 /* OBSOLETE  */
685 /* OBSOLETE           if (thread_pc[thread] > STACK_END_ADDR) */
686 /* OBSOLETE             { */
687 /* OBSOLETE               POP_FRAME; */
688 /* OBSOLETE               if (is_break_pc (thread_pc[thread])) */
689 /* OBSOLETE                 thread_pc[thread] = read_pc () - 2; */
690 /* OBSOLETE               else */
691 /* OBSOLETE                 thread_pc[thread] = read_pc (); */
692 /* OBSOLETE               write_register (PC_REGNUM, thread_pc[thread]); */
693 /* OBSOLETE             } */
694 /* OBSOLETE            */
695 /* OBSOLETE           if (ps.pi_osigno || ps.pi_osigcode) */
696 /* OBSOLETE             { */
697 /* OBSOLETE               signal_stack++; */
698 /* OBSOLETE               signal_stack->pid = pid; */
699 /* OBSOLETE               signal_stack->thread = thread; */
700 /* OBSOLETE               signal_stack->signo = thread_signal[thread]; */
701 /* OBSOLETE               signal_stack->subsig = thread_sigcode[thread]; */
702 /* OBSOLETE               signal_stack->pc = thread_pc[thread]; */
703 /* OBSOLETE             } */
704 /* OBSOLETE  */
705 /* OBSOLETE           /* The following hackery is caused by a unix 7.1 feature: */
706 /* OBSOLETE              the inferior's fixed scheduling mode is cleared when */
707 /* OBSOLETE              it execs the shell (since the shell is not a parallel */
708 /* OBSOLETE              program).  So, note the 5.4 trap we get when */
709 /* OBSOLETE              the shell does its exec, then catch the 5.0 trap  */
710 /* OBSOLETE              that occurs when the debuggee starts, and set fixed */
711 /* OBSOLETE              scheduling mode properly.  *x/ */
712 /* OBSOLETE  */
713 /* OBSOLETE           if (ps.pi_osigno == 5 && ps.pi_osigcode == 4) */
714 /* OBSOLETE             exec_trap_timer = 1; */
715 /* OBSOLETE           else */
716 /* OBSOLETE             exec_trap_timer--; */
717 /* OBSOLETE            */
718 /* OBSOLETE           if (ps.pi_osigno == 5 && exec_trap_timer == 0) */
719 /* OBSOLETE             set_fixed_scheduling (pid, parallel == 2); */
720 /* OBSOLETE         } */
721 /* OBSOLETE     } */
722 /* OBSOLETE  */
723 /* OBSOLETE       if (signal_stack_is_empty ()) */
724 /* OBSOLETE     error ("no active threads?!"); */
725 /* OBSOLETE     } */
726 /* OBSOLETE  */
727 /* OBSOLETE   /* Select the thread that stopped, and return *w saying why.  *x/ */
728 /* OBSOLETE  */
729 /* OBSOLETE   select_thread (signal_stack->thread); */
730 /* OBSOLETE  */
731 /* OBSOLETE  FIXME: need to convert from host sig. */
732 /* OBSOLETE   stop_signal = signal_stack->signo; */
733 /* OBSOLETE   stop_sigcode = signal_stack->subsig; */
734 /* OBSOLETE  */
735 /* OBSOLETE   WSETSTOP (*w, signal_stack->signo); */
736 /* OBSOLETE   w->w_thread = signal_stack->thread; */
737 /* OBSOLETE   return (signal_stack--)->pid; */
738 /* OBSOLETE } */
739 /* OBSOLETE  */
740 /* OBSOLETE /* Select thread THREAD -- its registers, stack, per-thread memory. */
741 /* OBSOLETE    This is the only routine that may assign to inferior_thread */
742 /* OBSOLETE    or thread_regs[].  *x/ */
743 /* OBSOLETE  */
744 /* OBSOLETE static void */
745 /* OBSOLETE select_thread (thread) */
746 /* OBSOLETE      int thread; */
747 /* OBSOLETE { */
748 /* OBSOLETE   if (thread == inferior_thread) */
749 /* OBSOLETE     return; */
750 /* OBSOLETE  */
751 /* OBSOLETE   memcpy (thread_regs[inferior_thread], registers, REGISTER_BYTES); */
752 /* OBSOLETE   ps.pi_thread = inferior_thread = thread; */
753 /* OBSOLETE   if (have_inferior_p ()) */
754 /* OBSOLETE     ioctl (inferior_fd, PISETRWTID, &ps); */
755 /* OBSOLETE   memcpy (registers, thread_regs[thread], REGISTER_BYTES); */
756 /* OBSOLETE } */
757 /* OBSOLETE    */
758 /* OBSOLETE /* Routine to set or clear a psw bit in the psw and also all psws */
759 /* OBSOLETE    saved on the stack.  Quits when we get to a frame in which the */
760 /* OBSOLETE    saved psw is correct. *x/ */
761 /* OBSOLETE  */
762 /* OBSOLETE static void */
763 /* OBSOLETE scan_stack (bit, val) */
764 /* OBSOLETE     long bit, val; */
765 /* OBSOLETE { */
766 /* OBSOLETE   long ps = read_register (PS_REGNUM); */
767 /* OBSOLETE   long fp; */
768 /* OBSOLETE   if (val ? !(ps & bit) : (ps & bit)) */
769 /* OBSOLETE     {     */
770 /* OBSOLETE       ps ^= bit; */
771 /* OBSOLETE       write_register (PS_REGNUM, ps); */
772 /* OBSOLETE  */
773 /* OBSOLETE       fp = read_register (FP_REGNUM); */
774 /* OBSOLETE       while (fp & 0x80000000) */
775 /* OBSOLETE     { */
776 /* OBSOLETE       ps = read_memory_integer (fp + 4, 4); */
777 /* OBSOLETE       if (val ? (ps & bit) : !(ps & bit)) */
778 /* OBSOLETE         break; */
779 /* OBSOLETE       ps ^= bit; */
780 /* OBSOLETE       write_memory (fp + 4, &ps, 4); */
781 /* OBSOLETE       fp = read_memory_integer (fp + 8, 4); */
782 /* OBSOLETE     } */
783 /* OBSOLETE     } */
784 /* OBSOLETE } */
785 /* OBSOLETE  */
786 /* OBSOLETE /* Set fixed scheduling (alliant mode) of process PID to ARG (0 or 1).  *x/ */
787 /* OBSOLETE  */
788 /* OBSOLETE static void */
789 /* OBSOLETE set_fixed_scheduling (pid, arg) */
790 /* OBSOLETE       int arg; */
791 /* OBSOLETE { */
792 /* OBSOLETE   struct pattributes pattr; */
793 /* OBSOLETE   getpattr (pid, &pattr); */
794 /* OBSOLETE   pattr.pattr_pfixed = arg; */
795 /* OBSOLETE   setpattr (pid, &pattr); */
796 /* OBSOLETE } */
797 /* OBSOLETE \f */
798 /* OBSOLETE void */
799 /* OBSOLETE core_file_command (filename, from_tty) */
800 /* OBSOLETE      char *filename; */
801 /* OBSOLETE      int from_tty; */
802 /* OBSOLETE { */
803 /* OBSOLETE   int n; */
804 /* OBSOLETE  */
805 /* OBSOLETE   /* Discard all vestiges of any previous core file */
806 /* OBSOLETE      and mark data and stack spaces as empty.  *x/ */
807 /* OBSOLETE  */
808 /* OBSOLETE   if (corefile) */
809 /* OBSOLETE     xfree (corefile); */
810 /* OBSOLETE   corefile = 0; */
811 /* OBSOLETE  */
812 /* OBSOLETE   if (corechan >= 0) */
813 /* OBSOLETE     close (corechan); */
814 /* OBSOLETE   corechan = -1; */
815 /* OBSOLETE  */
816 /* OBSOLETE   data_start = 0; */
817 /* OBSOLETE   data_end = 0; */
818 /* OBSOLETE   stack_start = STACK_END_ADDR; */
819 /* OBSOLETE   stack_end = STACK_END_ADDR; */
820 /* OBSOLETE   n_core = 0; */
821 /* OBSOLETE  */
822 /* OBSOLETE   /* Now, if a new core file was specified, open it and digest it.  *x/ */
823 /* OBSOLETE  */
824 /* OBSOLETE   if (filename) */
825 /* OBSOLETE     { */
826 /* OBSOLETE       filename = tilde_expand (filename); */
827 /* OBSOLETE       make_cleanup (xfree, filename); */
828 /* OBSOLETE        */
829 /* OBSOLETE       if (have_inferior_p ()) */
830 /* OBSOLETE     error ("To look at a core file, you must kill the program with \"kill\"."); */
831 /* OBSOLETE       corechan = open (filename, O_RDONLY, 0); */
832 /* OBSOLETE       if (corechan < 0) */
833 /* OBSOLETE     perror_with_name (filename); */
834 /* OBSOLETE  */
835 /* OBSOLETE       if (myread (corechan, &filehdr, sizeof filehdr) < 0) */
836 /* OBSOLETE     perror_with_name (filename); */
837 /* OBSOLETE  */
838 /* OBSOLETE       if (!IS_CORE_SOFF_MAGIC (filehdr.h_magic)) */
839 /* OBSOLETE     error ("%s: not a core file.\n", filename); */
840 /* OBSOLETE  */
841 /* OBSOLETE       if (myread (corechan, &opthdr, filehdr.h_opthdr) < 0) */
842 /* OBSOLETE     perror_with_name (filename); */
843 /* OBSOLETE  */
844 /* OBSOLETE       /* Read through the section headers. */
845 /* OBSOLETE      For text, data, etc, record an entry in the core file map. */
846 /* OBSOLETE      For context and tcontext, record the file address of */
847 /* OBSOLETE      the context blocks.  *x/ */
848 /* OBSOLETE  */
849 /* OBSOLETE       lseek (corechan, (long) filehdr.h_scnptr, 0); */
850 /* OBSOLETE  */
851 /* OBSOLETE       n_threads = 0; */
852 /* OBSOLETE       for (n = 0; n < filehdr.h_nscns; n++) */
853 /* OBSOLETE     { */
854 /* OBSOLETE       if (myread (corechan, &scnhdr, sizeof scnhdr) < 0) */
855 /* OBSOLETE         perror_with_name (filename); */
856 /* OBSOLETE       if ((scnhdr.s_flags & S_TYPMASK) >= S_TEXT */
857 /* OBSOLETE           && (scnhdr.s_flags & S_TYPMASK) <= S_COMON) */
858 /* OBSOLETE         { */
859 /* OBSOLETE           core_map[n_core].mem_addr = scnhdr.s_vaddr; */
860 /* OBSOLETE           core_map[n_core].mem_end = scnhdr.s_vaddr + scnhdr.s_size; */
861 /* OBSOLETE           core_map[n_core].file_addr = scnhdr.s_scnptr; */
862 /* OBSOLETE           core_map[n_core].type = scnhdr.s_flags & S_TYPMASK; */
863 /* OBSOLETE           if (core_map[n_core].type != S_TBSS */
864 /* OBSOLETE               && core_map[n_core].type != S_TDATA */
865 /* OBSOLETE               && core_map[n_core].type != S_TTEXT) */
866 /* OBSOLETE             core_map[n_core].thread = -1; */
867 /* OBSOLETE           else if (n_core == 0 */
868 /* OBSOLETE                    || core_map[n_core-1].mem_addr != scnhdr.s_vaddr) */
869 /* OBSOLETE             core_map[n_core].thread = 0; */
870 /* OBSOLETE           else  */
871 /* OBSOLETE             core_map[n_core].thread = core_map[n_core-1].thread + 1; */
872 /* OBSOLETE           n_core++; */
873 /* OBSOLETE         } */
874 /* OBSOLETE       else if ((scnhdr.s_flags & S_TYPMASK) == S_CONTEXT) */
875 /* OBSOLETE         context_offset = scnhdr.s_scnptr; */
876 /* OBSOLETE       else if ((scnhdr.s_flags & S_TYPMASK) == S_TCONTEXT)  */
877 /* OBSOLETE         tcontext_offset[n_threads++] = scnhdr.s_scnptr; */
878 /* OBSOLETE     } */
879 /* OBSOLETE  */
880 /* OBSOLETE       /* Read the context block, struct user, struct proc, */
881 /* OBSOLETE      and the comm regs.  *x/ */
882 /* OBSOLETE  */
883 /* OBSOLETE       lseek (corechan, context_offset, 0); */
884 /* OBSOLETE       if (myread (corechan, &c, sizeof c) < 0) */
885 /* OBSOLETE     perror_with_name (filename); */
886 /* OBSOLETE       lseek (corechan, c.core_user_p, 0); */
887 /* OBSOLETE       if (myread (corechan, &u, sizeof u) < 0) */
888 /* OBSOLETE     perror_with_name (filename); */
889 /* OBSOLETE       lseek (corechan, c.core_proc_p, 0); */
890 /* OBSOLETE       if (myread (corechan, &pr, sizeof pr) < 0) */
891 /* OBSOLETE     perror_with_name (filename); */
892 /* OBSOLETE       comm_registers = pr.p_creg; */
893 /* OBSOLETE  */
894 /* OBSOLETE       /* Core file apparently is really there.  Make it really exist */
895 /* OBSOLETE      for xfer_core_file so we can do read_memory on it. *x/ */
896 /* OBSOLETE  */
897 /* OBSOLETE       if (filename[0] == '/') */
898 /* OBSOLETE     corefile = savestring (filename, strlen (filename)); */
899 /* OBSOLETE       else */
900 /* OBSOLETE     corefile = concat (current_directory, "/", filename, NULL); */
901 /* OBSOLETE  */
902 /* OBSOLETE       printf_filtered ("Program %s ", u.u_comm); */
903 /* OBSOLETE  */
904 /* OBSOLETE       /* Read the thread registers and fill in the thread_xxx[] data.  *x/ */
905 /* OBSOLETE  */
906 /* OBSOLETE       for (n = 0; n < n_threads; n++) */
907 /* OBSOLETE     { */
908 /* OBSOLETE       select_thread (n); */
909 /* OBSOLETE  */
910 /* OBSOLETE       lseek (corechan, tcontext_offset[n], 0); */
911 /* OBSOLETE       if (myread (corechan, &tc, sizeof tc) < 0) */
912 /* OBSOLETE         perror_with_name (corefile); */
913 /* OBSOLETE       lseek (corechan, tc.core_thread_p, 0); */
914 /* OBSOLETE       if (myread (corechan, &th, sizeof th) < 0) */
915 /* OBSOLETE         perror_with_name (corefile); */
916 /* OBSOLETE  */
917 /* OBSOLETE       lseek (corechan, tc.core_syscall_context_p, 0); */
918 /* OBSOLETE       if (myread (corechan, registers, REGISTER_BYTES) < 0) */
919 /* OBSOLETE         perror_with_name (corefile); */
920 /* OBSOLETE  */
921 /* OBSOLETE       thread_signal[n] = th.t_cursig; */
922 /* OBSOLETE       thread_sigcode[n] = th.t_code; */
923 /* OBSOLETE       thread_state[n] = th.t_state; */
924 /* OBSOLETE       thread_pc[n] = read_pc (); */
925 /* OBSOLETE  */
926 /* OBSOLETE       if (thread_pc[n] > STACK_END_ADDR) */
927 /* OBSOLETE         { */
928 /* OBSOLETE           POP_FRAME; */
929 /* OBSOLETE           if (is_break_pc (thread_pc[n])) */
930 /* OBSOLETE             thread_pc[n] = read_pc () - 2; */
931 /* OBSOLETE           else */
932 /* OBSOLETE             thread_pc[n] = read_pc (); */
933 /* OBSOLETE           write_register (PC_REGNUM, thread_pc[n]); */
934 /* OBSOLETE         } */
935 /* OBSOLETE  */
936 /* OBSOLETE       printf_filtered ("thread %d received signal %d, %s\n", */
937 /* OBSOLETE                        n, thread_signal[n], */
938 /* OBSOLETE                        safe_strsignal (thread_signal[n])); */
939 /* OBSOLETE     } */
940 /* OBSOLETE  */
941 /* OBSOLETE       /* Select an interesting thread -- also-rans died with SIGKILL, */
942 /* OBSOLETE      so find one that didn't.  *x/ */
943 /* OBSOLETE  */
944 /* OBSOLETE       for (n = 0; n < n_threads; n++) */
945 /* OBSOLETE     if (thread_signal[n] != 0 && thread_signal[n] != SIGKILL) */
946 /* OBSOLETE       { */
947 /* OBSOLETE         select_thread (n); */
948 /* OBSOLETE         stop_signal = thread_signal[n]; */
949 /* OBSOLETE         stop_sigcode = thread_sigcode[n]; */
950 /* OBSOLETE         break; */
951 /* OBSOLETE       } */
952 /* OBSOLETE  */
953 /* OBSOLETE       core_aouthdr.a_magic = 0; */
954 /* OBSOLETE  */
955 /* OBSOLETE       flush_cached_frames (); */
956 /* OBSOLETE       select_frame (get_current_frame (), 0); */
957 /* OBSOLETE       validate_files (); */
958 /* OBSOLETE  */
959 /* OBSOLETE       print_stack_frame (selected_frame, selected_frame_level, -1); */
960 /* OBSOLETE     } */
961 /* OBSOLETE   else if (from_tty) */
962 /* OBSOLETE     printf_filtered ("No core file now.\n"); */
963 /* OBSOLETE } */