1 /* OBSOLETE /* Convex host-dependent code for GDB. */
2 /* OBSOLETE Copyright 1990, 1991, 1992 Free Software Foundation, Inc. */
4 /* OBSOLETE This file is part of GDB. */
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. */
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. */
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/ */
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" */
28 /* OBSOLETE #include <signal.h> */
29 /* OBSOLETE #include <fcntl.h> */
30 /* OBSOLETE #include "gdbcore.h" */
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> */
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> */
49 /* OBSOLETE /* Per-thread data, read from the inferior at each stop and written */
50 /* OBSOLETE back at each resume. *x/ */
52 /* OBSOLETE /* Number of active threads. */
53 /* OBSOLETE Tables are valid for thread numbers less than this. *x/ */
55 /* OBSOLETE static int n_threads; */
57 /* OBSOLETE #define MAXTHREADS 8 */
59 /* OBSOLETE /* Thread state. The remaining data is valid only if this is PI_TALIVE. *x/ */
61 /* OBSOLETE static int thread_state[MAXTHREADS]; */
63 /* OBSOLETE /* Stop pc, signal, signal subcode *x/ */
65 /* OBSOLETE static int thread_pc[MAXTHREADS]; */
66 /* OBSOLETE static int thread_signal[MAXTHREADS]; */
67 /* OBSOLETE static int thread_sigcode[MAXTHREADS]; */
69 /* OBSOLETE /* Thread registers. */
70 /* OBSOLETE If thread is selected, the regs are in registers[] instead. *x/ */
72 /* OBSOLETE static char thread_regs[MAXTHREADS][REGISTER_BYTES]; */
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/ */
78 /* OBSOLETE static char thread_is_in_kernel[MAXTHREADS]; */
80 /* OBSOLETE /* The currently selected thread's number. *x/ */
82 /* OBSOLETE static int inferior_thread; */
84 /* OBSOLETE /* Inferior process's file handle and a process control block */
85 /* OBSOLETE to feed args to ioctl with. *x/ */
87 /* OBSOLETE static int inferior_fd; */
88 /* OBSOLETE static struct pcntl ps; */
90 /* OBSOLETE /* SOFF file headers for exec or core file. *x/ */
92 /* OBSOLETE static FILEHDR filehdr; */
93 /* OBSOLETE static OPTHDR opthdr; */
94 /* OBSOLETE static SCNHDR scnhdr; */
96 /* OBSOLETE /* Address maps constructed from section headers of exec and core files. */
97 /* OBSOLETE Defines process address -> file address translation. *x/ */
99 /* OBSOLETE struct pmap */
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/ */
109 /* OBSOLETE static int n_exec, n_core; */
110 /* OBSOLETE static struct pmap exec_map[100]; */
111 /* OBSOLETE static struct pmap core_map[100]; */
113 /* OBSOLETE /* Offsets in the core file of core_context and core_tcontext blocks. *x/ */
115 /* OBSOLETE static int context_offset; */
116 /* OBSOLETE static int tcontext_offset[MAXTHREADS]; */
118 /* OBSOLETE /* Core file control blocks. *x/ */
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; */
127 /* OBSOLETE /* Vector and communication registers from core dump or from inferior. */
128 /* OBSOLETE These are read on demand, ie, not normally valid. *x/ */
130 /* OBSOLETE static struct vecst vector_registers; */
131 /* OBSOLETE static struct creg_ctx comm_registers; */
133 /* OBSOLETE /* Flag, set on a vanilla CONT command and cleared when the inferior */
134 /* OBSOLETE is continued. *x/ */
136 /* OBSOLETE static int all_continue; */
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/ */
141 /* OBSOLETE static int thread_switch_ok; */
143 /* OBSOLETE /* Stack of signals recieved from threads but not yet delivered to gdb. *x/ */
145 /* OBSOLETE struct threadpid */
147 /* OBSOLETE int pid; */
148 /* OBSOLETE int thread; */
149 /* OBSOLETE int signo; */
150 /* OBSOLETE int subsig; */
151 /* OBSOLETE int pc; */
154 /* OBSOLETE static struct threadpid signal_stack_bot[100]; */
155 /* OBSOLETE static struct threadpid *signal_stack = signal_stack_bot; */
157 /* OBSOLETE /* How to detect empty stack -- bottom frame is all zero. *x/ */
159 /* OBSOLETE #define signal_stack_is_empty() (signal_stack->pid == 0) */
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/ */
164 /* OBSOLETE static int sequential = 0; */
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/ */
171 /* OBSOLETE static int parallel = 1; */
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/ */
177 /* OBSOLETE static int output_radix = 0; */
179 /* OBSOLETE /* Signal subcode at last thread stop. *x/ */
181 /* OBSOLETE static int stop_sigcode; */
183 /* OBSOLETE /* Hack, see wait() below. *x/ */
185 /* OBSOLETE static int exec_trap_timer; */
187 /* OBSOLETE #include "gdbcmd.h" */
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 (); */
206 /* OBSOLETE /* Execute ptrace. Convex V7 replaced ptrace with pattach. */
207 /* OBSOLETE Allow ptrace (0) as a no-op. *x/ */
210 /* OBSOLETE call_ptrace (request, pid, procaddr, buf) */
211 /* OBSOLETE int request, pid; */
212 /* OBSOLETE PTRACE_ARG3_TYPE procaddr; */
213 /* OBSOLETE int buf; */
215 /* OBSOLETE if (request == 0) */
216 /* OBSOLETE return; */
217 /* OBSOLETE error ("no ptrace"); */
220 /* OBSOLETE /* Replacement for system execle routine. */
221 /* OBSOLETE Convert it to an equivalent exect, which pattach insists on. *x/ */
223 /* OBSOLETE execle (name, argv) */
224 /* OBSOLETE char *name, *argv; */
226 /* OBSOLETE char ***envp = (char ***) &argv; */
227 /* OBSOLETE while (*envp++) ; */
229 /* OBSOLETE signal (SIGTRAP, sig_noop); */
230 /* OBSOLETE exect (name, &argv, *envp); */
233 /* OBSOLETE /* Stupid handler for stupid trace trap that otherwise causes */
234 /* OBSOLETE startup to stupidly hang. *x/ */
236 /* OBSOLETE static sig_noop () */
239 /* OBSOLETE /* Read registers from inferior into registers[] array. */
240 /* OBSOLETE For convex, they are already there, read in when the inferior stops. *x/ */
243 /* OBSOLETE fetch_inferior_registers (regno) */
244 /* OBSOLETE int regno; */
248 /* OBSOLETE /* Store our register values back into the inferior. */
249 /* OBSOLETE For Convex, do this only once, right before resuming inferior. *x/ */
252 /* OBSOLETE store_inferior_registers (regno) */
253 /* OBSOLETE int regno; */
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/ */
263 /* OBSOLETE read_inferior_memory (memaddr, myaddr, len) */
264 /* OBSOLETE CORE_ADDR memaddr; */
265 /* OBSOLETE char *myaddr; */
266 /* OBSOLETE int len; */
268 /* OBSOLETE errno = 0; */
269 /* OBSOLETE while (len > 0) */
271 /* OBSOLETE /* little-known undocumented max request size *x/ */
272 /* OBSOLETE int i = (len < 12288) ? len : 12288; */
274 /* OBSOLETE lseek (inferior_fd, memaddr, 0); */
275 /* OBSOLETE read (inferior_fd, myaddr, i); */
277 /* OBSOLETE memaddr += i; */
278 /* OBSOLETE myaddr += i; */
279 /* OBSOLETE len -= i; */
281 /* OBSOLETE if (errno) */
282 /* OBSOLETE memset (myaddr, '\0', len); */
283 /* OBSOLETE return errno; */
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/ */
291 /* OBSOLETE write_inferior_memory (memaddr, myaddr, len) */
292 /* OBSOLETE CORE_ADDR memaddr; */
293 /* OBSOLETE char *myaddr; */
294 /* OBSOLETE int len; */
296 /* OBSOLETE errno = 0; */
297 /* OBSOLETE lseek (inferior_fd, memaddr, 0); */
298 /* OBSOLETE write (inferior_fd, myaddr, len); */
299 /* OBSOLETE return errno; */
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. */
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/ */
310 /* OBSOLETE create_inferior_hook (pid) */
311 /* OBSOLETE int pid; */
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; */
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; */
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); */
333 /* OBSOLETE /* Attach process PID for debugging. *x/ */
335 /* OBSOLETE attach (pid) */
336 /* OBSOLETE int pid; */
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); */
345 /* OBSOLETE setpgrp (pid, pid); */
347 /* OBSOLETE inferior_fd = fd; */
348 /* OBSOLETE inferior_thread = 0; */
349 /* OBSOLETE return pid; */
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/ */
357 /* OBSOLETE detach (signal) */
358 /* OBSOLETE int signal; */
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; */
368 /* OBSOLETE /* Kill off the inferior process. *x/ */
370 /* OBSOLETE kill_inferior () */
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 (); */
379 /* OBSOLETE /* Read vector register REG, and return a pointer to the value. *x/ */
381 /* OBSOLETE static long * */
382 /* OBSOLETE read_vector_register (reg) */
383 /* OBSOLETE int reg; */
385 /* OBSOLETE if (have_inferior_p ()) */
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); */
396 /* OBSOLETE else if (corechan >= 0) */
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; */
412 /* OBSOLETE return read_vector_register_1 (reg); */
415 /* OBSOLETE /* Return a pointer to vector register REG, which must already have been */
416 /* OBSOLETE fetched from the inferior or core file. *x/ */
418 /* OBSOLETE static long * */
419 /* OBSOLETE read_vector_register_1 (reg) */
420 /* OBSOLETE int reg; */
422 /* OBSOLETE switch (reg) */
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]; */
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/ */
439 /* OBSOLETE static void */
440 /* OBSOLETE write_vector_register (reg, element, val) */
441 /* OBSOLETE int reg, element; */
442 /* OBSOLETE ULONGEST val; */
444 /* OBSOLETE if (have_inferior_p ()) */
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; */
452 /* OBSOLETE ioctl (inferior_fd, PIXRDVREGS, &ps); */
454 /* OBSOLETE switch (reg) */
456 /* OBSOLETE case VL_REGNUM: */
457 /* OBSOLETE vector_registers.vls = */
458 /* OBSOLETE (vector_registers.vls & 0xffffffff00000000LL) */
459 /* OBSOLETE + (unsigned long) val; */
460 /* OBSOLETE break; */
462 /* OBSOLETE case VS_REGNUM: */
463 /* OBSOLETE vector_registers.vls = */
464 /* OBSOLETE (val << 32) + (unsigned long) vector_registers.vls; */
465 /* OBSOLETE break; */
467 /* OBSOLETE default: */
468 /* OBSOLETE vector_registers.vr[reg].el[element] = val; */
469 /* OBSOLETE break; */
472 /* OBSOLETE ioctl (inferior_fd, PIXWRVREGS, &ps); */
474 /* OBSOLETE if (errno) */
475 /* OBSOLETE perror_with_name ("writing vector register"); */
479 /* OBSOLETE /* Return the contents of communication register NUM. *x/ */
481 /* OBSOLETE static ULONGEST */
482 /* OBSOLETE read_comm_register (num) */
483 /* OBSOLETE int num; */
485 /* OBSOLETE if (have_inferior_p ()) */
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); */
493 /* OBSOLETE return comm_registers.crreg.r4[num]; */
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/ */
500 /* OBSOLETE static void */
501 /* OBSOLETE write_comm_register (num, val) */
502 /* OBSOLETE int num; */
503 /* OBSOLETE ULONGEST val; */
505 /* OBSOLETE if (have_inferior_p ()) */
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); */
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/ */
522 /* OBSOLETE resume (step, signal) */
523 /* OBSOLETE int step; */
524 /* OBSOLETE int signal; */
526 /* OBSOLETE errno = 0; */
527 /* OBSOLETE if (step || signal) */
528 /* OBSOLETE thread_continue (inferior_thread, step, signal); */
530 /* OBSOLETE thread_continue (-1, 0, 0); */
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. */
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. */
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/ */
545 /* OBSOLETE static void */
546 /* OBSOLETE thread_continue (thread, step, signal) */
547 /* OBSOLETE int thread, step, signal; */
549 /* OBSOLETE int n; */
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/ */
554 /* OBSOLETE if (thread < 0 && ! all_continue) */
555 /* OBSOLETE thread = inferior_thread; */
557 /* OBSOLETE /* If we are not stepping, we have now executed the continue part */
558 /* OBSOLETE of a CONTINUE command. *x/ */
560 /* OBSOLETE if (! step) */
561 /* OBSOLETE all_continue = 0; */
563 /* OBSOLETE /* Allow wait() to switch threads if this is an all-out continue. *x/ */
565 /* OBSOLETE thread_switch_ok = thread < 0; */
567 /* OBSOLETE /* If there are threads queued up, don't resume. *x/ */
569 /* OBSOLETE if (thread_switch_ok && ! signal_stack_is_empty ()) */
570 /* OBSOLETE return; */
572 /* OBSOLETE /* OK, do it. *x/ */
574 /* OBSOLETE for (n = 0; n < n_threads; n++) */
575 /* OBSOLETE if (thread_state[n] == PI_TALIVE) */
577 /* OBSOLETE select_thread (n); */
579 /* OBSOLETE if ((thread < 0 || n == thread) && ! thread_is_in_kernel[n]) */
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); */
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"); */
600 /* OBSOLETE if (thread < 0 || n == thread) */
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"); */
609 /* OBSOLETE if (ioctl (inferior_fd, PIXRUN, &ps) < 0) */
610 /* OBSOLETE perror_with_name ("PIXRUN"); */
613 /* OBSOLETE /* Replacement for system wait routine. */
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. */
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/ */
625 /* OBSOLETE wait (w) */
626 /* OBSOLETE union wait *w; */
628 /* OBSOLETE int pid; */
630 /* OBSOLETE if (!w) */
631 /* OBSOLETE return wait3 (0, 0, 0); */
633 /* OBSOLETE /* Do a real wait if we were told to, or if there are no queued threads. *x/ */
635 /* OBSOLETE if (! thread_switch_ok || signal_stack_is_empty ()) */
637 /* OBSOLETE int thread; */
639 /* OBSOLETE pid = wait3 (w, 0, 0); */
641 /* OBSOLETE if (!WIFSTOPPED (*w) || pid != inferior_pid) */
642 /* OBSOLETE return pid; */
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/ */
647 /* OBSOLETE if (ioctl (inferior_fd, PIXGETTHCOUNT, &ps) < 0) */
648 /* OBSOLETE perror_with_name ("PIXGETTHCOUNT"); */
650 /* OBSOLETE n_threads = ps.pi_othdcnt; */
651 /* OBSOLETE for (thread = 0; thread < n_threads; thread++) */
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; */
658 /* OBSOLETE if (ps.pi_otstate == PI_TALIVE) */
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"); */
668 /* OBSOLETE registers_fetched (); */
670 /* OBSOLETE thread_pc[thread] = read_pc (); */
671 /* OBSOLETE thread_signal[thread] = ps.pi_osigno; */
672 /* OBSOLETE thread_sigcode[thread] = ps.pi_osigcode; */
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/ */
679 /* OBSOLETE thread_is_in_kernel[thread] = */
680 /* OBSOLETE ((read_register (PS_REGNUM) >> 25) & 3) == 0; */
682 /* OBSOLETE /* Signals push an extended frame and then fault */
683 /* OBSOLETE with a ridiculous pc. Pop the frame. *x/ */
685 /* OBSOLETE if (thread_pc[thread] > STACK_END_ADDR) */
687 /* OBSOLETE POP_FRAME; */
688 /* OBSOLETE if (is_break_pc (thread_pc[thread])) */
689 /* OBSOLETE thread_pc[thread] = read_pc () - 2; */
691 /* OBSOLETE thread_pc[thread] = read_pc (); */
692 /* OBSOLETE write_register (PC_REGNUM, thread_pc[thread]); */
695 /* OBSOLETE if (ps.pi_osigno || ps.pi_osigcode) */
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]; */
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/ */
713 /* OBSOLETE if (ps.pi_osigno == 5 && ps.pi_osigcode == 4) */
714 /* OBSOLETE exec_trap_timer = 1; */
716 /* OBSOLETE exec_trap_timer--; */
718 /* OBSOLETE if (ps.pi_osigno == 5 && exec_trap_timer == 0) */
719 /* OBSOLETE set_fixed_scheduling (pid, parallel == 2); */
723 /* OBSOLETE if (signal_stack_is_empty ()) */
724 /* OBSOLETE error ("no active threads?!"); */
727 /* OBSOLETE /* Select the thread that stopped, and return *w saying why. *x/ */
729 /* OBSOLETE select_thread (signal_stack->thread); */
731 /* OBSOLETE FIXME: need to convert from host sig. */
732 /* OBSOLETE stop_signal = signal_stack->signo; */
733 /* OBSOLETE stop_sigcode = signal_stack->subsig; */
735 /* OBSOLETE WSETSTOP (*w, signal_stack->signo); */
736 /* OBSOLETE w->w_thread = signal_stack->thread; */
737 /* OBSOLETE return (signal_stack--)->pid; */
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/ */
744 /* OBSOLETE static void */
745 /* OBSOLETE select_thread (thread) */
746 /* OBSOLETE int thread; */
748 /* OBSOLETE if (thread == inferior_thread) */
749 /* OBSOLETE return; */
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); */
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/ */
762 /* OBSOLETE static void */
763 /* OBSOLETE scan_stack (bit, val) */
764 /* OBSOLETE long bit, val; */
766 /* OBSOLETE long ps = read_register (PS_REGNUM); */
767 /* OBSOLETE long fp; */
768 /* OBSOLETE if (val ? !(ps & bit) : (ps & bit)) */
770 /* OBSOLETE ps ^= bit; */
771 /* OBSOLETE write_register (PS_REGNUM, ps); */
773 /* OBSOLETE fp = read_register (FP_REGNUM); */
774 /* OBSOLETE while (fp & 0x80000000) */
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); */
786 /* OBSOLETE /* Set fixed scheduling (alliant mode) of process PID to ARG (0 or 1). *x/ */
788 /* OBSOLETE static void */
789 /* OBSOLETE set_fixed_scheduling (pid, arg) */
790 /* OBSOLETE int arg; */
792 /* OBSOLETE struct pattributes pattr; */
793 /* OBSOLETE getpattr (pid, &pattr); */
794 /* OBSOLETE pattr.pattr_pfixed = arg; */
795 /* OBSOLETE setpattr (pid, &pattr); */
799 /* OBSOLETE core_file_command (filename, from_tty) */
800 /* OBSOLETE char *filename; */
801 /* OBSOLETE int from_tty; */
803 /* OBSOLETE int n; */
805 /* OBSOLETE /* Discard all vestiges of any previous core file */
806 /* OBSOLETE and mark data and stack spaces as empty. *x/ */
808 /* OBSOLETE if (corefile) */
809 /* OBSOLETE xfree (corefile); */
810 /* OBSOLETE corefile = 0; */
812 /* OBSOLETE if (corechan >= 0) */
813 /* OBSOLETE close (corechan); */
814 /* OBSOLETE corechan = -1; */
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; */
822 /* OBSOLETE /* Now, if a new core file was specified, open it and digest it. *x/ */
824 /* OBSOLETE if (filename) */
826 /* OBSOLETE filename = tilde_expand (filename); */
827 /* OBSOLETE make_cleanup (xfree, filename); */
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); */
835 /* OBSOLETE if (myread (corechan, &filehdr, sizeof filehdr) < 0) */
836 /* OBSOLETE perror_with_name (filename); */
838 /* OBSOLETE if (!IS_CORE_SOFF_MAGIC (filehdr.h_magic)) */
839 /* OBSOLETE error ("%s: not a core file.\n", filename); */
841 /* OBSOLETE if (myread (corechan, &opthdr, filehdr.h_opthdr) < 0) */
842 /* OBSOLETE perror_with_name (filename); */
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/ */
849 /* OBSOLETE lseek (corechan, (long) filehdr.h_scnptr, 0); */
851 /* OBSOLETE n_threads = 0; */
852 /* OBSOLETE for (n = 0; n < filehdr.h_nscns; n++) */
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) */
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; */
871 /* OBSOLETE core_map[n_core].thread = core_map[n_core-1].thread + 1; */
872 /* OBSOLETE n_core++; */
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; */
880 /* OBSOLETE /* Read the context block, struct user, struct proc, */
881 /* OBSOLETE and the comm regs. *x/ */
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; */
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/ */
897 /* OBSOLETE if (filename[0] == '/') */
898 /* OBSOLETE corefile = savestring (filename, strlen (filename)); */
900 /* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */
902 /* OBSOLETE printf_filtered ("Program %s ", u.u_comm); */
904 /* OBSOLETE /* Read the thread registers and fill in the thread_xxx[] data. *x/ */
906 /* OBSOLETE for (n = 0; n < n_threads; n++) */
908 /* OBSOLETE select_thread (n); */
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); */
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); */
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 (); */
926 /* OBSOLETE if (thread_pc[n] > STACK_END_ADDR) */
928 /* OBSOLETE POP_FRAME; */
929 /* OBSOLETE if (is_break_pc (thread_pc[n])) */
930 /* OBSOLETE thread_pc[n] = read_pc () - 2; */
932 /* OBSOLETE thread_pc[n] = read_pc (); */
933 /* OBSOLETE write_register (PC_REGNUM, thread_pc[n]); */
936 /* OBSOLETE printf_filtered ("thread %d received signal %d, %s\n", */
937 /* OBSOLETE n, thread_signal[n], */
938 /* OBSOLETE safe_strsignal (thread_signal[n])); */
941 /* OBSOLETE /* Select an interesting thread -- also-rans died with SIGKILL, */
942 /* OBSOLETE so find one that didn't. *x/ */
944 /* OBSOLETE for (n = 0; n < n_threads; n++) */
945 /* OBSOLETE if (thread_signal[n] != 0 && thread_signal[n] != SIGKILL) */
947 /* OBSOLETE select_thread (n); */
948 /* OBSOLETE stop_signal = thread_signal[n]; */
949 /* OBSOLETE stop_sigcode = thread_sigcode[n]; */
950 /* OBSOLETE break; */
953 /* OBSOLETE core_aouthdr.a_magic = 0; */
955 /* OBSOLETE flush_cached_frames (); */
956 /* OBSOLETE select_frame (get_current_frame (), 0); */
957 /* OBSOLETE validate_files (); */
959 /* OBSOLETE print_stack_frame (selected_frame, selected_frame_level, -1); */
961 /* OBSOLETE else if (from_tty) */
962 /* OBSOLETE printf_filtered ("No core file now.\n"); */
This page took 0.048775 seconds and 4 git commands to generate.