1 /* Convex stuff for GDB.
2 Copyright (C) 1990 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
34 #include <sys/param.h>
37 #include <sys/ioctl.h>
38 #include <sys/pcntl.h>
39 #include <sys/thread.h>
45 #include <convex/vmparam.h>
46 #include <convex/filehdr.h>
47 #include <convex/opthdr.h>
48 #include <convex/scnhdr.h>
49 #include <convex/core.h>
51 /* Per-thread data, read from the inferior at each stop and written
52 back at each resume. */
54 /* Number of active threads.
55 Tables are valid for thread numbers less than this. */
61 /* Thread state. The remaining data is valid only if this is PI_TALIVE. */
63 static int thread_state
[MAXTHREADS
];
65 /* Stop pc, signal, signal subcode */
67 static int thread_pc
[MAXTHREADS
];
68 static int thread_signal
[MAXTHREADS
];
69 static int thread_sigcode
[MAXTHREADS
];
72 If thread is selected, the regs are in registers[] instead. */
74 static char thread_regs
[MAXTHREADS
][REGISTER_BYTES
];
76 /* 1 if the top frame on the thread's stack was a context frame,
77 meaning that the kernel is up to something and we should not
78 touch the thread at all except to resume it. */
80 static char thread_is_in_kernel
[MAXTHREADS
];
82 /* The currently selected thread's number. */
84 static int inferior_thread
;
86 /* Inferior process's file handle and a process control block
87 to feed args to ioctl with. */
89 static int inferior_fd
;
90 static struct pcntl ps
;
92 /* SOFF file headers for exec or core file. */
94 static FILEHDR filehdr
;
98 /* Address maps constructed from section headers of exec and core files.
99 Defines process address -> file address translation. */
103 long mem_addr
; /* process start address */
104 long mem_end
; /* process end+1 address */
105 long file_addr
; /* file start address */
106 long thread
; /* -1 shared; 0,1,... thread-local */
107 long type
; /* S_TEXT S_DATA S_BSS S_TBSS etc */
108 long which
; /* used to sort map for info files */
111 static int n_exec
, n_core
;
112 static struct pmap exec_map
[100];
113 static struct pmap core_map
[100];
115 /* Offsets in the core file of core_context and core_tcontext blocks. */
117 static int context_offset
;
118 static int tcontext_offset
[MAXTHREADS
];
120 /* Core file control blocks. */
122 static struct core_context_v70 c
;
123 static struct core_tcontext_v70 tc
;
124 static struct user u
;
128 /* The registers of the currently selected thread. */
130 extern char registers
[REGISTER_BYTES
];
132 /* Vector and communication registers from core dump or from inferior.
133 These are read on demand, ie, not normally valid. */
135 static struct vecst vector_registers
;
136 static struct creg_ctx comm_registers
;
138 /* Flag, set on a vanilla CONT command and cleared when the inferior
141 static int all_continue
;
143 /* Flag, set when the inferior is continued by a vanilla CONT command,
144 cleared if it is continued for any other purpose. */
146 static int thread_switch_ok
;
148 /* Stack of signals recieved from threads but not yet delivered to gdb. */
159 static struct threadpid signal_stack_bot
[100];
160 static struct threadpid
*signal_stack
= signal_stack_bot
;
162 /* How to detect empty stack -- bottom frame is all zero. */
164 #define signal_stack_is_empty() (signal_stack->pid == 0)
166 /* Mode controlled by SET PIPE command, controls the psw SEQ bit
167 which forces each instruction to complete before the next one starts. */
169 static int sequential
= 0;
171 /* Mode controlled by the SET PARALLEL command. Values are:
172 0 concurrency limit 1 thread, dynamic scheduling
173 1 no concurrency limit, dynamic scheduling
174 2 no concurrency limit, fixed scheduling */
176 static int parallel
= 1;
178 /* Mode controlled by SET BASE command, output radix for unformatted
179 integer typeout, as in argument lists, aggregates, and so on.
180 Zero means guess whether it's an address (hex) or not (decimal). */
182 static int output_radix
= 0;
184 /* Signal subcode at last thread stop. */
186 static int stop_sigcode
;
188 /* Hack, see wait() below. */
190 static int exec_trap_timer
;
192 /* Chain containing all defined commands. */
194 extern struct cmd_list_element
*cmdlist
;
196 /* Chain containing all defined set subcommands */
198 extern struct cmd_list_element
*setlist
;
200 /* Hook for `exec_file_command' command to call. */
202 extern void (*exec_file_display_hook
) ();
204 /* File names of core file and executable file. */
206 extern char *corefile
;
207 extern char *execfile
;
209 /* Descriptors on which core file and executable file are open.
210 Note that the execchan is closed when an inferior is created
211 and reopened if the inferior dies or is killed. */
216 /* Last modification time of executable file.
217 Also used in source.c to compare against mtime of a source file. */
219 extern int exec_mtime
;
221 /* Virtual addresses of bounds of the two areas of memory in the core file.
222 NB: These variables are set to plausible but useless values on convex. */
224 extern CORE_ADDR data_start
;
225 extern CORE_ADDR data_end
;
226 extern CORE_ADDR stack_start
;
227 extern CORE_ADDR stack_end
;
229 /* Virtual addresses of bounds of two areas of memory in the exec file.
230 NB: Only text_start and text_end have meaningful values on convex. */
232 extern CORE_ADDR text_start
;
233 extern CORE_ADDR text_end
;
235 extern CORE_ADDR exec_data_start
;
236 extern CORE_ADDR exec_data_end
;
238 /* Address in executable file of start of text area data. */
240 extern int text_offset
;
242 /* Address in executable file of start of data area data. */
244 extern int exec_data_offset
;
246 /* Address in core file of start of data area data. */
248 extern int data_offset
;
250 /* Address in core file of start of stack area data. */
252 extern int stack_offset
;
254 /* a.out header saved in core file. */
256 extern struct exec core_aouthdr
;
258 /* a.out header of exec file. */
260 extern struct exec exec_aouthdr
;
262 /* Routine to check for exec-core mismatch. */
264 extern void validate_files ();
266 /* Nonzero if we are debugging an attached outside process
267 rather than an inferior. */
269 extern int attach_flag
;
273 static struct type
*vector_type ();
274 static long *read_vector_register ();
275 static long *read_vector_register_1 ();
276 static void write_vector_register ();
277 static REGISTER_TYPE
read_comm_register ();
278 static void write_comm_register ();
279 static void convex_cont_command ();
280 static void thread_continue ();
281 static void select_thread ();
282 static void scan_stack ();
283 static void set_fixed_scheduling ();
284 static char *subsig_name ();
285 static void psw_info ();
289 extern char *sys_siglist
[];
292 /* Execute ptrace. Convex V7 replaced ptrace with pattach.
293 Allow ptrace (0) as a no-op. */
296 call_ptrace (request
, pid
, procaddr
, buf
)
297 int request
, pid
, procaddr
, buf
;
304 /* Replacement for system execle routine.
305 Convert it to an equivalent exect, which pattach insists on. */
310 char ***envp
= (char ***) &argv
;
313 signal (SIGTRAP
, sig_noop
);
314 exect (name
, &argv
, *envp
);
317 /* Stupid handler for stupid trace trap that otherwise causes
318 startup to stupidly hang. */
323 /* Read registers from inferior into registers[] array.
324 For convex, they are already there, read in when the inferior stops. */
327 fetch_inferior_registers ()
331 /* Store our register values back into the inferior.
332 For Convex, do this only once, right before resuming inferior. */
334 store_inferior_registers (regno
)
339 /* Copy LEN bytes from inferior's memory starting at MEMADDR
340 to debugger memory starting at MYADDR.
341 On failure (cannot read from inferior, usually because address is out
342 of bounds) returns the value of errno. */
345 read_inferior_memory (memaddr
, myaddr
, len
)
353 /* little-known undocumented max request size */
354 int i
= (len
< 12288) ? len
: 12288;
356 lseek (inferior_fd
, memaddr
, 0);
357 read (inferior_fd
, myaddr
, i
);
368 /* Copy LEN bytes of data from debugger memory at MYADDR
369 to inferior's memory at MEMADDR.
370 Returns errno on failure (cannot write the inferior) */
373 write_inferior_memory (memaddr
, myaddr
, len
)
379 lseek (inferior_fd
, memaddr
, 0);
380 write (inferior_fd
, myaddr
, len
);
384 /* Here from create_inferior when the inferior process has been created
385 and started up. We must do a pattach to grab it for debugging.
387 Also, intercept the CONT command by altering its dispatch address. */
389 create_inferior_hook (pid
)
392 static char cont
[] = "cont";
393 static char cont1
[] = "c";
395 char *linep1
= cont1
;
396 char **line
= &linep
;
397 char **line1
= &linep1
;
398 struct cmd_list_element
*c
;
400 c
= lookup_cmd (line
, cmdlist
, "", 0);
401 c
->function
= convex_cont_command
;
402 c
= lookup_cmd (line1
, cmdlist
, "", 0);
403 c
->function
= convex_cont_command
;
405 inferior_fd
= pattach (pid
, O_EXCL
);
407 perror_with_name ("pattach");
409 set_fixed_scheduling (pid
, parallel
== 2);
412 /* Attach process PID for debugging. */
417 int fd
= pattach (pid
, O_EXCL
);
419 perror_with_name ("pattach");
421 /* wait for strange kernel reverberations to go away */
431 /* Stop debugging the process whose number is PID
432 and continue it with signal number SIGNAL.
433 SIGNAL = 0 means just continue it. */
439 signal_stack
= signal_stack_bot
;
440 thread_continue (-1, 0, signal
);
441 ioctl (inferior_fd
, PIXDETACH
, &ps
);
447 /* Kill off the inferior process. */
451 if (remote_debugging
)
453 if (inferior_pid
== 0)
455 ioctl (inferior_fd
, PIXTERMINATE
, 0);
460 /* This is used when GDB is exiting. It gives less chance of error.*/
462 kill_inferior_fast ()
464 if (remote_debugging
)
466 if (inferior_pid
== 0)
468 ioctl (inferior_fd
, PIXTERMINATE
, 0);
472 /* Read vector register REG, and return a pointer to the value. */
475 read_vector_register (reg
)
478 if (have_inferior_p ())
481 ps
.pi_buffer
= (char *) &vector_registers
;
482 ps
.pi_nbytes
= sizeof vector_registers
;
484 ps
.pi_thread
= inferior_thread
;
485 ioctl (inferior_fd
, PIXRDVREGS
, &ps
);
487 bzero (&vector_registers
, sizeof vector_registers
);
489 else if (corechan
>= 0)
491 lseek (corechan
, tcontext_offset
[inferior_thread
], 0);
492 if (myread (corechan
, &tc
, sizeof tc
) < 0)
493 perror_with_name (corefile
);
494 lseek (corechan
, tc
.core_thread_p
, 0);
495 if (myread (corechan
, &th
, sizeof th
) < 0)
496 perror_with_name (corefile
);
497 lseek (corechan
, tc
.core_vregs_p
, 0);
498 if (myread (corechan
, &vector_registers
, 16*128) < 0)
499 perror_with_name (corefile
);
500 vector_registers
.vm
[0] = th
.t_vect_ctx
.vc_vm
[0];
501 vector_registers
.vm
[1] = th
.t_vect_ctx
.vc_vm
[1];
502 vector_registers
.vls
= th
.t_vect_ctx
.vc_vls
;
505 return read_vector_register_1 (reg
);
508 /* Return a pointer to vector register REG, which must already have been
509 fetched from the inferior or core file. */
512 read_vector_register_1 (reg
)
518 return (long *) vector_registers
.vm
;
520 return (long *) &vector_registers
.vls
;
522 return 1 + (long *) &vector_registers
.vls
;
524 return (long *) &vector_registers
.vr
[reg
];
528 /* Write vector register REG, element ELEMENT, new value VAL.
529 NB: must use read-modify-write on the entire vector state,
530 since pattach does not do offsetted writes correctly. */
533 write_vector_register (reg
, element
, val
)
537 if (have_inferior_p ())
540 ps
.pi_thread
= inferior_thread
;
542 ps
.pi_buffer
= (char *) &vector_registers
;
543 ps
.pi_nbytes
= sizeof vector_registers
;
545 ioctl (inferior_fd
, PIXRDVREGS
, &ps
);
550 vector_registers
.vls
=
551 (vector_registers
.vls
& 0xffffffff00000000LL
)
552 + (unsigned long) val
;
556 vector_registers
.vls
=
557 (val
<< 32) + (unsigned long) vector_registers
.vls
;
561 vector_registers
.vr
[reg
].el
[element
] = val
;
565 ioctl (inferior_fd
, PIXWRVREGS
, &ps
);
568 perror_with_name ("writing vector register");
572 /* Return the contents of communication register NUM. */
575 read_comm_register (num
)
578 if (have_inferior_p ())
580 ps
.pi_buffer
= (char *) &comm_registers
;
581 ps
.pi_nbytes
= sizeof comm_registers
;
583 ps
.pi_thread
= inferior_thread
;
584 ioctl (inferior_fd
, PIXRDCREGS
, &ps
);
586 return comm_registers
.crreg
.r4
[num
];
589 /* Store a new value VAL into communication register NUM.
590 NB: Must use read-modify-write on the whole comm register set
591 since pattach does not do offsetted writes correctly. */
594 write_comm_register (num
, val
)
598 if (have_inferior_p ())
600 ps
.pi_buffer
= (char *) &comm_registers
;
601 ps
.pi_nbytes
= sizeof comm_registers
;
603 ps
.pi_thread
= inferior_thread
;
604 ioctl (inferior_fd
, PIXRDCREGS
, &ps
);
605 comm_registers
.crreg
.r4
[num
] = val
;
606 ioctl (inferior_fd
, PIXWRCREGS
, &ps
);
610 /* Resume execution of the inferior process.
611 If STEP is nonzero, single-step it.
612 If SIGNAL is nonzero, give it that signal. */
615 resume (step
, signal
)
620 if (remote_debugging
)
621 remote_resume (step
, signal
);
624 thread_continue (inferior_thread
, step
, signal
);
626 thread_continue (-1, 0, 0);
629 /* Maybe resume some threads.
630 THREAD is which thread to resume, or -1 to resume them all.
631 STEP and SIGNAL are as in resume.
633 Global variable ALL_CONTINUE is set when we are here to do a
634 `cont' command; otherwise we may be doing `finish' or a call or
635 something else that will not tolerate an automatic thread switch.
637 If there are stopped threads waiting to deliver signals, and
638 ALL_CONTINUE, do not actually resume anything. gdb will do a wait
639 and see one of the stopped threads in the queue. */
642 thread_continue (thread
, step
, signal
)
643 int thread
, step
, signal
;
647 /* If we are to continue all threads, but not for the CONTINUE command,
648 pay no attention and continue only the selected thread. */
650 if (thread
< 0 && ! all_continue
)
651 thread
= inferior_thread
;
653 /* If we are not stepping, we have now executed the continue part
654 of a CONTINUE command. */
659 /* Allow wait() to switch threads if this is an all-out continue. */
661 thread_switch_ok
= thread
< 0;
663 /* If there are threads queued up, don't resume. */
665 if (thread_switch_ok
&& ! signal_stack_is_empty ())
670 for (n
= 0; n
< n_threads
; n
++)
671 if (thread_state
[n
] == PI_TALIVE
)
675 if ((thread
< 0 || n
== thread
) && ! thread_is_in_kernel
[n
])
677 /* Blam the trace bits in the stack's saved psws to match
678 the desired step mode. This is required so that
679 single-stepping a return doesn't restore a psw with a
680 clear trace bit and fly away, and conversely,
681 proceeding through a return in a routine that was
682 stepped into doesn't cause a phantom break by restoring
683 a psw with the trace bit set. */
684 scan_stack (PSW_T_BIT
, step
);
685 scan_stack (PSW_S_BIT
, sequential
);
688 ps
.pi_buffer
= registers
;
689 ps
.pi_nbytes
= REGISTER_BYTES
;
692 if (! thread_is_in_kernel
[n
])
693 if (ioctl (inferior_fd
, PIXWRREGS
, &ps
))
694 perror_with_name ("PIXWRREGS");
696 if (thread
< 0 || n
== thread
)
699 ps
.pi_signo
= signal
;
700 if (ioctl (inferior_fd
, step
? PIXSTEP
: PIXCONTINUE
, &ps
) < 0)
701 perror_with_name ("PIXCONTINUE");
705 if (ioctl (inferior_fd
, PIXRUN
, &ps
) < 0)
706 perror_with_name ("PIXRUN");
709 /* Replacement for system wait routine.
711 The system wait returns with one or more threads stopped by
712 signals. Put stopped threads on a stack and return them one by
713 one, so that it appears that wait returns one thread at a time.
715 Global variable THREAD_SWITCH_OK is set when gdb can tolerate wait
716 returning a new thread. If it is false, then only one thread is
717 running; we will do a real wait, the thread will do something, and
718 we will return that. */
727 return wait3 (0, 0, 0);
729 /* Do a real wait if we were told to, or if there are no queued threads. */
731 if (! thread_switch_ok
|| signal_stack_is_empty ())
735 pid
= wait3 (w
, 0, 0);
737 if (!WIFSTOPPED (*w
) || pid
!= inferior_pid
)
740 /* The inferior has done something and stopped. Read in all the
741 threads' registers, and queue up any signals that happened. */
743 if (ioctl (inferior_fd
, PIXGETTHCOUNT
, &ps
) < 0)
744 perror_with_name ("PIXGETTHCOUNT");
746 n_threads
= ps
.pi_othdcnt
;
747 for (thread
= 0; thread
< n_threads
; thread
++)
749 ps
.pi_thread
= thread
;
750 if (ioctl (inferior_fd
, PIXGETSUBCODE
, &ps
) < 0)
751 perror_with_name ("PIXGETSUBCODE");
752 thread_state
[thread
] = ps
.pi_otstate
;
754 if (ps
.pi_otstate
== PI_TALIVE
)
756 select_thread (thread
);
757 ps
.pi_buffer
= registers
;
758 ps
.pi_nbytes
= REGISTER_BYTES
;
760 ps
.pi_thread
= thread
;
761 if (ioctl (inferior_fd
, PIXRDREGS
, &ps
) < 0)
762 perror_with_name ("PIXRDREGS");
764 thread_pc
[thread
] = read_pc ();
765 thread_signal
[thread
] = ps
.pi_osigno
;
766 thread_sigcode
[thread
] = ps
.pi_osigcode
;
768 /* If the thread's stack has a context frame
769 on top, something fucked is going on. I do not
770 know what, but do I know this: the only thing you
771 can do with such a thread is continue it. */
773 thread_is_in_kernel
[thread
] =
774 ((read_register (PS_REGNUM
) >> 25) & 3) == 0;
776 /* Signals push an extended frame and then fault
777 with a ridiculous pc. Pop the frame. */
779 if (thread_pc
[thread
] > STACK_END_ADDR
)
782 if (is_break_pc (thread_pc
[thread
]))
783 thread_pc
[thread
] = read_pc () - 2;
785 thread_pc
[thread
] = read_pc ();
786 write_register (PC_REGNUM
, thread_pc
[thread
]);
789 if (ps
.pi_osigno
|| ps
.pi_osigcode
)
792 signal_stack
->pid
= pid
;
793 signal_stack
->thread
= thread
;
794 signal_stack
->signo
= thread_signal
[thread
];
795 signal_stack
->subsig
= thread_sigcode
[thread
];
796 signal_stack
->pc
= thread_pc
[thread
];
799 /* The following hackery is caused by a unix 7.1 feature:
800 the inferior's fixed scheduling mode is cleared when
801 it execs the shell (since the shell is not a parallel
802 program). So, note the 5.4 trap we get when
803 the shell does its exec, then catch the 5.0 trap
804 that occurs when the debuggee starts, and set fixed
805 scheduling mode properly. */
807 if (ps
.pi_osigno
== 5 && ps
.pi_osigcode
== 4)
812 if (ps
.pi_osigno
== 5 && exec_trap_timer
== 0)
813 set_fixed_scheduling (pid
, parallel
== 2);
817 if (signal_stack_is_empty ())
818 error ("no active threads?!");
821 /* Select the thread that stopped, and return *w saying why. */
823 select_thread (signal_stack
->thread
);
825 stop_signal
= signal_stack
->signo
;
826 stop_sigcode
= signal_stack
->subsig
;
828 WSETSTOP (*w
, signal_stack
->signo
);
829 w
->w_thread
= signal_stack
->thread
;
830 return (signal_stack
--)->pid
;
833 /* Select thread THREAD -- its registers, stack, per-thread memory.
834 This is the only routine that may assign to inferior_thread
838 select_thread (thread
)
841 if (thread
== inferior_thread
)
844 bcopy (registers
, thread_regs
[inferior_thread
], REGISTER_BYTES
);
845 ps
.pi_thread
= inferior_thread
= thread
;
846 if (have_inferior_p ())
847 ioctl (inferior_fd
, PISETRWTID
, &ps
);
848 bcopy (thread_regs
[thread
], registers
, REGISTER_BYTES
);
851 /* Routine to set or clear a psw bit in the psw and also all psws
852 saved on the stack. Quits when we get to a frame in which the
853 saved psw is correct. */
856 scan_stack (bit
, val
)
859 long ps
= read_register (PS_REGNUM
);
861 if (val
? !(ps
& bit
) : (ps
& bit
))
864 write_register (PS_REGNUM
, ps
);
866 fp
= read_register (FP_REGNUM
);
867 while (fp
& 0x80000000)
869 ps
= read_memory_integer (fp
+ 4, 4);
870 if (val
? (ps
& bit
) : !(ps
& bit
))
873 write_memory (fp
+ 4, &ps
, 4);
874 fp
= read_memory_integer (fp
+ 8, 4);
879 /* Set fixed scheduling (alliant mode) of process PID to ARG (0 or 1). */
882 set_fixed_scheduling (pid
, arg
)
885 struct pattributes pattr
;
886 getpattr (pid
, &pattr
);
887 pattr
.pattr_pfixed
= arg
;
888 setpattr (pid
, &pattr
);
891 core_file_command (filename
, from_tty
)
897 /* Discard all vestiges of any previous core file
898 and mark data and stack spaces as empty. */
910 stack_start
= STACK_END_ADDR
;
911 stack_end
= STACK_END_ADDR
;
914 /* Now, if a new core file was specified, open it and digest it. */
918 filename
= tilde_expand (filename
);
919 make_cleanup (free
, filename
);
921 if (have_inferior_p ())
922 error ("To look at a core file, you must kill the inferior with \"kill\".");
923 corechan
= open (filename
, O_RDONLY
, 0);
925 perror_with_name (filename
);
927 if (myread (corechan
, &filehdr
, sizeof filehdr
) < 0)
928 perror_with_name (filename
);
930 if (!IS_CORE_SOFF_MAGIC (filehdr
.h_magic
))
931 error ("%s: not a core file.\n", filename
);
933 if (myread (corechan
, &opthdr
, filehdr
.h_opthdr
) < 0)
934 perror_with_name (filename
);
936 /* Read through the section headers.
937 For text, data, etc, record an entry in the core file map.
938 For context and tcontext, record the file address of
939 the context blocks. */
941 lseek (corechan
, (long) filehdr
.h_scnptr
, 0);
944 for (n
= 0; n
< filehdr
.h_nscns
; n
++)
946 if (myread (corechan
, &scnhdr
, sizeof scnhdr
) < 0)
947 perror_with_name (filename
);
948 if ((scnhdr
.s_flags
& S_TYPMASK
) >= S_TEXT
949 && (scnhdr
.s_flags
& S_TYPMASK
) <= S_COMON
)
951 core_map
[n_core
].mem_addr
= scnhdr
.s_vaddr
;
952 core_map
[n_core
].mem_end
= scnhdr
.s_vaddr
+ scnhdr
.s_size
;
953 core_map
[n_core
].file_addr
= scnhdr
.s_scnptr
;
954 core_map
[n_core
].type
= scnhdr
.s_flags
& S_TYPMASK
;
955 if (core_map
[n_core
].type
!= S_TBSS
956 && core_map
[n_core
].type
!= S_TDATA
957 && core_map
[n_core
].type
!= S_TTEXT
)
958 core_map
[n_core
].thread
= -1;
960 || core_map
[n_core
-1].mem_addr
!= scnhdr
.s_vaddr
)
961 core_map
[n_core
].thread
= 0;
963 core_map
[n_core
].thread
= core_map
[n_core
-1].thread
+ 1;
966 else if ((scnhdr
.s_flags
& S_TYPMASK
) == S_CONTEXT
)
967 context_offset
= scnhdr
.s_scnptr
;
968 else if ((scnhdr
.s_flags
& S_TYPMASK
) == S_TCONTEXT
)
969 tcontext_offset
[n_threads
++] = scnhdr
.s_scnptr
;
972 /* Read the context block, struct user, struct proc,
973 and the comm regs. */
975 lseek (corechan
, context_offset
, 0);
976 if (myread (corechan
, &c
, sizeof c
) < 0)
977 perror_with_name (filename
);
978 lseek (corechan
, c
.core_user_p
, 0);
979 if (myread (corechan
, &u
, sizeof u
) < 0)
980 perror_with_name (filename
);
981 lseek (corechan
, c
.core_proc_p
, 0);
982 if (myread (corechan
, &pr
, sizeof pr
) < 0)
983 perror_with_name (filename
);
984 comm_registers
= pr
.p_creg
;
986 /* Core file apparently is really there. Make it really exist
987 for xfer_core_file so we can do read_memory on it. */
989 if (filename
[0] == '/')
990 corefile
= savestring (filename
, strlen (filename
));
992 corefile
= concat (current_directory
, "/", filename
);
994 printf_filtered ("Program %s ", u
.u_comm
);
996 /* Read the thread registers and fill in the thread_xxx[] data. */
998 for (n
= 0; n
< n_threads
; n
++)
1002 lseek (corechan
, tcontext_offset
[n
], 0);
1003 if (myread (corechan
, &tc
, sizeof tc
) < 0)
1004 perror_with_name (corefile
);
1005 lseek (corechan
, tc
.core_thread_p
, 0);
1006 if (myread (corechan
, &th
, sizeof th
) < 0)
1007 perror_with_name (corefile
);
1009 lseek (corechan
, tc
.core_syscall_context_p
, 0);
1010 if (myread (corechan
, registers
, REGISTER_BYTES
) < 0)
1011 perror_with_name (corefile
);
1013 thread_signal
[n
] = th
.t_cursig
;
1014 thread_sigcode
[n
] = th
.t_code
;
1015 thread_state
[n
] = th
.t_state
;
1016 thread_pc
[n
] = read_pc ();
1018 if (thread_pc
[n
] > STACK_END_ADDR
)
1021 if (is_break_pc (thread_pc
[n
]))
1022 thread_pc
[n
] = read_pc () - 2;
1024 thread_pc
[n
] = read_pc ();
1025 write_register (PC_REGNUM
, thread_pc
[n
]);
1028 printf_filtered ("thread %d received signal %d, %s\n",
1029 n
, thread_signal
[n
],
1030 thread_signal
[n
] < NSIG
1031 ? sys_siglist
[thread_signal
[n
]]
1032 : "(undocumented)");
1035 /* Select an interesting thread -- also-rans died with SIGKILL,
1036 so find one that didn't. */
1038 for (n
= 0; n
< n_threads
; n
++)
1039 if (thread_signal
[n
] != 0 && thread_signal
[n
] != SIGKILL
)
1042 stop_signal
= thread_signal
[n
];
1043 stop_sigcode
= thread_sigcode
[n
];
1047 core_aouthdr
.a_magic
= 0;
1049 flush_cached_frames ();
1050 set_current_frame (create_new_frame (read_register (FP_REGNUM
),
1052 select_frame (get_current_frame (), 0);
1055 print_sel_frame (1);
1058 printf_filtered ("No core file now.\n");
1061 exec_file_command (filename
, from_tty
)
1067 struct stat st_exec
;
1069 /* Eliminate all traces of old exec file.
1070 Mark text segment as empty. */
1079 exec_data_start
= 0;
1087 /* Now open and digest the file the user requested, if any. */
1091 filename
= tilde_expand (filename
);
1092 make_cleanup (free
, filename
);
1094 execchan
= openp (getenv ("PATH"), 1, filename
, O_RDONLY
, 0,
1097 perror_with_name (filename
);
1099 if (myread (execchan
, &filehdr
, sizeof filehdr
) < 0)
1100 perror_with_name (filename
);
1102 if (! IS_SOFF_MAGIC (filehdr
.h_magic
))
1103 error ("%s: not an executable file.", filename
);
1105 if (myread (execchan
, &opthdr
, filehdr
.h_opthdr
) <= 0)
1106 perror_with_name (filename
);
1108 /* Read through the section headers.
1109 For text, data, etc, record an entry in the exec file map.
1110 Record text_start and text_end. */
1112 lseek (execchan
, (long) filehdr
.h_scnptr
, 0);
1114 for (n
= 0; n
< filehdr
.h_nscns
; n
++)
1116 if (myread (execchan
, &scnhdr
, sizeof scnhdr
) < 0)
1117 perror_with_name (filename
);
1119 if ((scnhdr
.s_flags
& S_TYPMASK
) >= S_TEXT
1120 && (scnhdr
.s_flags
& S_TYPMASK
) <= S_COMON
)
1122 exec_map
[n_exec
].mem_addr
= scnhdr
.s_vaddr
;
1123 exec_map
[n_exec
].mem_end
= scnhdr
.s_vaddr
+ scnhdr
.s_size
;
1124 exec_map
[n_exec
].file_addr
= scnhdr
.s_scnptr
;
1125 exec_map
[n_exec
].type
= scnhdr
.s_flags
& S_TYPMASK
;
1128 if ((scnhdr
.s_flags
& S_TYPMASK
) == S_TEXT
)
1130 text_start
= scnhdr
.s_vaddr
;
1131 text_end
= scnhdr
.s_vaddr
+ scnhdr
.s_size
;
1136 fstat (execchan
, &st_exec
);
1137 exec_mtime
= st_exec
.st_mtime
;
1142 printf_filtered ("No exec file now.\n");
1144 /* Tell display code (if any) about the changed file name. */
1145 if (exec_file_display_hook
)
1146 (*exec_file_display_hook
) (filename
);
1149 /* Read data from SOFF exec or core file.
1150 Return 0 on success, 1 if address could not be read. */
1153 xfer_core_file (memaddr
, myaddr
, len
)
1171 /* Determine which file the next bunch of addresses reside in,
1172 and where in the file. Set the file's read/write pointer
1173 to point at the proper place for the desired address
1174 and set xferfile and xferchan for the correct file.
1175 If desired address is nonexistent, leave them zero.
1176 i is set to the number of bytes that can be handled
1177 along with the next address. */
1181 for (n
= 0; n
< n_core
; n
++)
1183 if (memaddr
>= core_map
[n
].mem_addr
&& memaddr
< core_map
[n
].mem_end
1184 && (core_map
[n
].thread
== -1
1185 || core_map
[n
].thread
== inferior_thread
))
1187 i
= min (len
, core_map
[n
].mem_end
- memaddr
);
1188 fileptr
= core_map
[n
].file_addr
+ memaddr
- core_map
[n
].mem_addr
;
1189 if (core_map
[n
].file_addr
)
1191 xferfile
= &corefile
;
1192 xferchan
= corechan
;
1196 else if (core_map
[n
].mem_addr
>= memaddr
1197 && core_map
[n
].mem_addr
< memaddr
+ i
)
1198 i
= core_map
[n
].mem_addr
- memaddr
;
1202 for (n
= 0; n
< n_exec
; n
++)
1204 if (memaddr
>= exec_map
[n
].mem_addr
1205 && memaddr
< exec_map
[n
].mem_end
)
1207 i
= min (len
, exec_map
[n
].mem_end
- memaddr
);
1208 fileptr
= exec_map
[n
].file_addr
+ memaddr
1209 - exec_map
[n
].mem_addr
;
1210 if (exec_map
[n
].file_addr
)
1212 xferfile
= &execfile
;
1213 xferchan
= execchan
;
1217 else if (exec_map
[n
].mem_addr
>= memaddr
1218 && exec_map
[n
].mem_addr
< memaddr
+ i
)
1219 i
= exec_map
[n
].mem_addr
- memaddr
;
1222 /* Now we know which file to use.
1223 Set up its pointer and transfer the data. */
1227 if (xferfile
== &execfile
)
1228 error ("No program file to examine.");
1230 error ("No core dump file or running program to examine.");
1231 val
= lseek (xferchan
, fileptr
, 0);
1233 perror_with_name (*xferfile
);
1234 val
= myread (xferchan
, myaddr
, i
);
1236 perror_with_name (*xferfile
);
1238 /* If this address is for nonexistent memory,
1239 read zeros if reading, or do nothing if writing. */
1254 /* Here from info files command to print an address map. */
1258 struct pmap ptrs
[200];
1261 /* ID strings for core and executable file sections */
1263 static char *idstr
[] =
1265 "0", "text", "data", "tdata", "bss", "tbss",
1266 "common", "ttext", "ctx", "tctx", "10", "11", "12",
1269 for (n
= 0; n
< n_core
; n
++)
1271 core_map
[n
].which
= 0;
1272 ptrs
[n
] = core_map
[n
];
1274 for (n
= 0; n
< n_exec
; n
++)
1276 exec_map
[n
].which
= 1;
1277 ptrs
[n_core
+n
] = exec_map
[n
];
1280 qsort (ptrs
, n_core
+ n_exec
, sizeof *ptrs
, ptr_cmp
);
1282 for (n
= 0; n
< n_core
+ n_exec
; n
++)
1284 struct pmap
*p
= &ptrs
[n
];
1287 if (p
->mem_addr
< ptrs
[n
-1].mem_end
)
1288 p
->mem_addr
= ptrs
[n
-1].mem_end
;
1289 if (p
->mem_addr
>= p
->mem_end
)
1292 printf_filtered ("%08x .. %08x %-6s %s\n",
1293 p
->mem_addr
, p
->mem_end
, idstr
[p
->type
],
1294 p
->which
? execfile
: corefile
);
1298 /* Compare routine to put file sections in order.
1299 Sort into increasing order on address, and put core file sections
1300 before exec file sections if both files contain the same addresses. */
1302 static ptr_cmp (a
, b
)
1305 if (a
->mem_addr
!= b
->mem_addr
) return a
->mem_addr
- b
->mem_addr
;
1306 return a
->which
- b
->which
;
1309 /* Trapped internal variables are used to handle special registers.
1310 A trapped i.v. calls a hook here every time it is dereferenced,
1311 to provide a new value for the variable, and it calls a hook here
1312 when a new value is assigned, to do something with the value.
1314 The vector registers are $vl, $vs, $vm, $vN, $VN (N in 0..7).
1315 The communication registers are $cN, $CN (N in 0..63).
1316 They not handled as regular registers because it's expensive to
1317 read them, and their size varies, and they have too many names. */
1320 /* Return 1 if NAME is a trapped internal variable, else 0. */
1323 is_trapped_internalvar (name
)
1326 if ((name
[0] == 'c' || name
[0] == 'C')
1327 && name
[1] >= '0' && name
[1] <= '9'
1329 || (name
[2] >= '0' && name
[2] <= '9'
1330 && name
[3] == '\0' && name
[1] != '0'))
1331 && atoi (&name
[1]) < 64) return 1;
1333 if ((name
[0] == 'v' || name
[0] == 'V')
1334 && (((name
[1] & -8) == '0' && name
[2] == '\0')
1335 || !strcmp (name
, "vl")
1336 || !strcmp (name
, "vs")
1337 || !strcmp (name
, "vm")))
1342 /* Return the value of trapped internal variable VAR */
1345 value_of_trapped_internalvar (var
)
1346 struct internalvar
*var
;
1348 char *name
= var
->name
;
1351 long len
= *read_vector_register (VL_REGNUM
);
1352 if (len
<= 0 || len
> 128) len
= 128;
1354 if (!strcmp (name
, "vl"))
1356 val
= value_from_long (builtin_type_int
,
1357 (LONGEST
) *read_vector_register_1 (VL_REGNUM
));
1359 else if (!strcmp (name
, "vs"))
1361 val
= value_from_long (builtin_type_int
,
1362 (LONGEST
) *read_vector_register_1 (VS_REGNUM
));
1364 else if (!strcmp (name
, "vm"))
1368 bcopy (read_vector_register_1 (VM_REGNUM
), vm
, sizeof vm
);
1369 type
= vector_type (builtin_type_int
, len
);
1370 val
= allocate_value (type
);
1371 p
= (long *) VALUE_CONTENTS (val
);
1372 for (i
= 0; i
< len
; i
++)
1373 *p
++ = !! (vm
[3 - (i
>> 5)] & (1 << (i
& 037)));
1375 else if (name
[0] == 'V')
1377 type
= vector_type (builtin_type_long_long
, len
);
1378 val
= allocate_value (type
);
1379 bcopy (read_vector_register_1 (name
[1] - '0'),
1380 VALUE_CONTENTS (val
), TYPE_LENGTH (type
));
1382 else if (name
[0] == 'v')
1385 type
= vector_type (builtin_type_long
, len
);
1386 val
= allocate_value (type
);
1387 p1
= read_vector_register_1 (name
[1] - '0');
1388 p2
= (long *) VALUE_CONTENTS (val
);
1389 while (--len
>= 0) {p1
++; *p2
++ = *p1
++;}
1392 else if (name
[0] == 'c')
1393 val
= value_from_long (builtin_type_int
,
1394 read_comm_register (atoi (&name
[1])));
1395 else if (name
[0] == 'C')
1396 val
= value_from_long (builtin_type_long_long
,
1397 read_comm_register (atoi (&name
[1])));
1399 VALUE_LVAL (val
) = lval_internalvar
;
1400 VALUE_INTERNALVAR (val
) = var
;
1404 /* Construct the type for a vector register's value --
1405 array[LENGTH] of ELEMENT_TYPE. */
1407 static struct type
*
1408 vector_type (element_type
, length
)
1409 struct type
*element_type
;
1412 struct type
*type
= (struct type
*) xmalloc (sizeof (struct type
));
1413 bzero (type
, sizeof type
);
1414 TYPE_CODE (type
) = TYPE_CODE_ARRAY
;
1415 TYPE_TARGET_TYPE (type
) = element_type
;
1416 TYPE_LENGTH (type
) = length
* TYPE_LENGTH (TYPE_TARGET_TYPE (type
));
1420 /* Handle a new value assigned to a trapped internal variable */
1423 set_trapped_internalvar (var
, val
, bitpos
, bitsize
, offset
)
1424 struct internalvar
*var
;
1426 int bitpos
, bitsize
, offset
;
1428 char *name
= var
->name
;
1429 long long newval
= value_as_long (val
);
1431 if (!strcmp (name
, "vl"))
1432 write_vector_register (VL_REGNUM
, 0, newval
);
1433 else if (!strcmp (name
, "vs"))
1434 write_vector_register (VS_REGNUM
, 0, newval
);
1435 else if (name
[0] == 'c' || name
[0] == 'C')
1436 write_comm_register (atoi (&name
[1]), newval
);
1437 else if (!strcmp (name
, "vm"))
1438 error ("can't assign to $vm");
1441 offset
/= bitsize
/ 8;
1442 write_vector_register (name
[1] - '0', offset
, newval
);
1446 /* Print an integer value when no format was specified. gdb normally
1447 prints these values in decimal, but the the leading 0x80000000 of
1448 pointers produces intolerable 10-digit negative numbers.
1449 If it looks like an address, print it in hex instead. */
1451 decout (stream
, type
, val
)
1458 switch (output_radix
)
1461 if ((lv
== val
|| (unsigned) lv
== val
)
1462 && ((lv
& 0xf0000000) == 0x80000000
1463 || ((lv
& 0xf0000000) == 0xf0000000 && lv
< STACK_END_ADDR
)))
1465 fprintf_filtered (stream
, "%#x", lv
);
1470 fprintf_filtered (stream
, TYPE_UNSIGNED (type
) ? "%llu" : "%lld", val
);
1474 if (TYPE_LENGTH (type
) <= sizeof lv
)
1475 fprintf_filtered (stream
, "%#o", lv
);
1477 fprintf_filtered (stream
, "%#llo", val
);
1481 if (TYPE_LENGTH (type
) <= sizeof lv
)
1482 fprintf_filtered (stream
, "%#x", lv
);
1484 fprintf_filtered (stream
, "%#llx", val
);
1489 /* Change the default output radix to 10 or 16, or set it to 0 (heuristic).
1490 This command is mostly obsolete now that the print command allows
1491 formats to apply to aggregates, but is still handy occasionally. */
1494 set_base_command (arg
)
1503 new_radix
= atoi (arg
);
1504 if (new_radix
!= 10 && new_radix
!= 16 && new_radix
!= 8)
1505 error ("base must be 8, 10 or 16, or null");
1506 else output_radix
= new_radix
;
1510 /* Turn pipelining on or off in the inferior. */
1513 set_pipelining_command (arg
)
1518 sequential
= !sequential
;
1519 printf_filtered ("%s\n", sequential
? "off" : "on");
1521 else if (!strcmp (arg
, "on"))
1523 else if (!strcmp (arg
, "off"))
1525 else error ("valid args are `on', to allow instructions to overlap, or\n\
1526 `off', to prevent it and thereby pinpoint exceptions.");
1529 /* Enable, disable, or force parallel execution in the inferior. */
1532 set_parallel_command (arg
)
1536 int prevparallel
= parallel
;
1538 if (!strncmp (arg
, "fixed", strlen (arg
)))
1540 else if (!strcmp (arg
, "on"))
1542 else if (!strcmp (arg
, "off"))
1544 else error ("valid args are `on', to allow multiple threads, or\n\
1545 `fixed', to force multiple threads, or\n\
1546 `off', to run with one thread only.");
1548 if ((prevparallel
== 0) != (parallel
== 0) && inferior_pid
)
1549 printf_filtered ("will take effect at next run.\n");
1551 getrlimit (RLIMIT_CONCUR
, &rl
);
1552 rl
.rlim_cur
= parallel
? rl
.rlim_max
: 1;
1553 setrlimit (RLIMIT_CONCUR
, &rl
);
1556 set_fixed_scheduling (inferior_pid
, parallel
== 2);
1559 /* Add a new name for an existing command. */
1565 static char *aliaserr
= "usage is `alias NEW OLD', no args allowed";
1566 char *newname
= arg
;
1567 struct cmd_list_element
*new, *old
;
1570 error_no_arg ("newname oldname");
1572 new = lookup_cmd (&arg
, cmdlist
, "", -1);
1573 if (new && !strncmp (newname
, new->name
, strlen (new->name
)))
1575 newname
= new->name
;
1577 || (*arg
>= 'a' && *arg
<= 'z')
1578 || (*arg
>= 'A' && *arg
<= 'Z')
1579 || (*arg
>= '0' && *arg
<= '9')))
1586 || (*arg
>= 'a' && *arg
<= 'z')
1587 || (*arg
>= 'A' && *arg
<= 'Z')
1588 || (*arg
>= '0' && *arg
<= '9'))
1590 if (*arg
!= ' ' && *arg
!= '\t')
1596 old
= lookup_cmd (&arg
, cmdlist
, "", 0);
1601 if (new && !strncmp (newname
, new->name
, strlen (new->name
)))
1604 if (new->class == (int) class_user
|| new->class == (int) class_alias
)
1605 tem
= "Redefine command \"%s\"? ";
1607 tem
= "Really redefine built-in command \"%s\"? ";
1608 if (!query (tem
, new->name
))
1609 error ("Command \"%s\" not redefined.", new->name
);
1612 add_com (newname
, class_alias
, old
->function
, old
->doc
);
1617 /* Print the current thread number, and any threads with signals in the
1622 struct threadpid
*p
;
1624 if (have_inferior_p ())
1626 ps
.pi_buffer
= (char *) &comm_registers
;
1627 ps
.pi_nbytes
= sizeof comm_registers
;
1629 ps
.pi_thread
= inferior_thread
;
1630 ioctl (inferior_fd
, PIXRDCREGS
, &ps
);
1633 printf_filtered ("Current thread %d stopped with signal %d.%d (%s).\n",
1634 inferior_thread
, stop_signal
, stop_sigcode
,
1635 subsig_name (stop_signal
, stop_sigcode
));
1637 for (p
= signal_stack
; p
->pid
; p
--)
1638 printf_filtered ("Thread %d stopped with signal %d.%d (%s).\n",
1639 p
->thread
, p
->signo
, p
->subsig
,
1640 subsig_name (p
->signo
, p
->subsig
));
1642 if (iscrlbit (comm_registers
.crctl
.lbits
.cc
, 64+13))
1643 printf_filtered ("New thread start pc %#x\n",
1644 (long) (comm_registers
.crreg
.pcpsw
>> 32));
1647 /* Return string describing a signal.subcode number */
1650 subsig_name (signo
, subcode
)
1653 static char *subsig4
[] = {
1654 "error exit", "privileged instruction", "unknown",
1655 "unknown", "undefined opcode",
1657 static char *subsig5
[] = {0,
1658 "breakpoint", "single step", "fork trap", "exec trap", "pfork trap",
1659 "join trap", "idle trap", "last thread", "wfork trap",
1660 "process breakpoint", "trap instruction",
1662 static char *subsig8
[] = {0,
1663 "int overflow", "int divide check", "float overflow",
1664 "float divide check", "float underflow", "reserved operand",
1665 "sqrt error", "exp error", "ln error", "sin error", "cos error",
1667 static char *subsig10
[] = {0,
1668 "invalid inward ring address", "invalid outward ring call",
1669 "invalid inward ring return", "invalid syscall gate",
1670 "invalid rtn frame length", "invalid comm reg address",
1671 "invalid trap gate",
1673 static char *subsig11
[] = {0,
1674 "read access denied", "write access denied", "execute access denied",
1675 "segment descriptor fault", "page table fault", "data reference fault",
1676 "i/o access denied", "levt pte invalid",
1679 static char **subsig_list
[] =
1680 {0, 0, 0, 0, subsig4
, subsig5
, 0, 0, subsig8
, 0, subsig10
, subsig11
, 0};
1683 char *p
= signo
< NSIG
? sys_siglist
[signo
] : "unknown";
1685 if (signo
>= (sizeof subsig_list
/ sizeof *subsig_list
)
1686 || !subsig_list
[signo
])
1688 for (i
= 1; subsig_list
[signo
][i
]; i
++)
1690 return subsig_list
[signo
][subcode
];
1695 /* Print a compact display of thread status, essentially x/i $pc
1696 for all active threads. */
1703 for (t
= 0; t
< n_threads
; t
++)
1704 if (thread_state
[t
] == PI_TALIVE
)
1706 printf_filtered ("%d%c %08x%c %d.%d ", t
,
1707 (t
== inferior_thread
? '*' : ' '), thread_pc
[t
],
1708 (thread_is_in_kernel
[t
] ? '#' : ' '),
1709 thread_signal
[t
], thread_sigcode
[t
]);
1710 print_insn (thread_pc
[t
], stdout
);
1711 printf_filtered ("\n");
1715 /* Change the current thread to ARG. */
1717 set_thread_command (arg
)
1728 thread
= parse_and_eval_address (arg
);
1730 if (thread
< 0 || thread
> n_threads
|| thread_state
[thread
] != PI_TALIVE
)
1731 error ("no such thread.");
1733 select_thread (thread
);
1735 stop_pc
= read_pc ();
1736 flush_cached_frames ();
1737 set_current_frame (create_new_frame (read_register (FP_REGNUM
),
1739 select_frame (get_current_frame (), 0);
1740 print_sel_frame (1);
1743 /* Here on CONT command; gdb's dispatch address is changed to come here.
1744 Set global variable ALL_CONTINUE to tell resume() that it should
1745 start up all threads, and that a thread switch will not blow gdb's
1749 convex_cont_command (proc_count_exp
, from_tty
)
1750 char *proc_count_exp
;
1754 cont_command (proc_count_exp
, from_tty
);
1757 /* Here on 1CONT command. Resume only the current thread. */
1759 one_cont_command (proc_count_exp
, from_tty
)
1760 char *proc_count_exp
;
1763 cont_command (proc_count_exp
, from_tty
);
1766 /* Print the contents and lock bits of all communication registers,
1767 or just register ARG if ARG is a communication register,
1768 or the 3-word resource structure in memory at address ARG. */
1770 comm_registers_info (arg
)
1777 if (sscanf (arg
, "0x%x", ®num
) == 1
1778 || sscanf (argc
, "%d", ®num
) == 1)
1783 else if (sscanf (arg
, "$c%d", ®num
) == 1)
1785 else if (sscanf (arg
, "$C%d", ®num
) == 1)
1788 regnum
= parse_and_eval_address (arg
);
1791 error ("%s: invalid register name.", arg
);
1793 /* if we got a (user) address, examine the resource struct there */
1798 read_memory (regnum
, buf
, sizeof buf
);
1799 printf_filtered ("%08x %08x%08x%s\n", regnum
, buf
[1], buf
[2],
1800 buf
[0] & 0xff ? " locked" : "");
1805 ps
.pi_buffer
= (char *) &comm_registers
;
1806 ps
.pi_nbytes
= sizeof comm_registers
;
1808 ps
.pi_thread
= inferior_thread
;
1809 ioctl (inferior_fd
, PIXRDCREGS
, &ps
);
1811 for (i
= 0; i
< 64; i
++)
1812 if (!arg
|| i
== regnum
)
1813 printf_filtered ("%2d 0x8%03x %016llx%s\n", i
, i
,
1814 comm_registers
.crreg
.r4
[i
],
1815 (iscrlbit (comm_registers
.crctl
.lbits
.cc
, i
)
1832 static struct pswbit pswbit
[] =
1834 { 0x80000000, -1, "A carry" },
1835 { 0x40000000, -1, "A integer overflow" },
1836 { 0x20000000, -1, "A zero divide" },
1837 { 0x10000000, -1, "Integer overflow enable" },
1838 { 0x08000000, -1, "Trace" },
1839 { 0x06000000, 25, "Frame length" },
1840 { 0x01000000, -1, "Sequential" },
1841 { 0x00800000, -1, "S carry" },
1842 { 0x00400000, -1, "S integer overflow" },
1843 { 0x00200000, -1, "S zero divide" },
1844 { 0x00100000, -1, "Zero divide enable" },
1845 { 0x00080000, -1, "Floating underflow" },
1846 { 0x00040000, -1, "Floating overflow" },
1847 { 0x00020000, -1, "Floating reserved operand" },
1848 { 0x00010000, -1, "Floating zero divide" },
1849 { 0x00008000, -1, "Floating error enable" },
1850 { 0x00004000, -1, "Floating underflow enable" },
1851 { 0x00002000, -1, "IEEE" },
1852 { 0x00001000, -1, "Sequential stores" },
1853 { 0x00000800, -1, "Intrinsic error" },
1854 { 0x00000400, -1, "Intrinsic error enable" },
1855 { 0x00000200, -1, "Trace thread creates" },
1856 { 0x00000100, -1, "Thread init trap" },
1857 { 0x000000e0, 5, "Reserved" },
1858 { 0x0000001f, 0, "Intrinsic error code" },
1866 psw
= parse_and_eval_address (arg
);
1868 psw
= read_register (PS_REGNUM
);
1870 for (p
= pswbit
; p
->bit
; p
++)
1873 printf_filtered ("%08x %s %s\n", p
->bit
,
1874 (psw
& p
->bit
) ? "yes" : "no ", p
->text
);
1876 printf_filtered ("%08x %3d %s\n", p
->bit
,
1877 (psw
& p
->bit
) >> p
->pos
, p
->text
);
1881 _initialize_convex_dep ()
1883 add_com ("alias", class_support
, alias_command
,
1884 "Add a new name for an existing command.");
1886 add_cmd ("base", class_vars
, set_base_command
,
1887 "Change the integer output radix to 8, 10 or 16\n\
1888 or use just `set base' with no args to return to the ad-hoc default,\n\
1889 which is 16 for integers that look like addresses, 10 otherwise.",
1892 add_cmd ("pipeline", class_run
, set_pipelining_command
,
1893 "Enable or disable overlapped execution of instructions.\n\
1894 With `set pipe off', exceptions are reported with\n\
1895 $pc pointing at the instruction after the faulting one.\n\
1896 The default is `set pipe on', which runs faster.",
1899 add_cmd ("parallel", class_run
, set_parallel_command
,
1900 "Enable or disable multi-threaded execution of parallel code.\n\
1901 `set parallel off' means run the program on a single CPU.\n\
1902 `set parallel fixed' means run the program with all CPUs assigned to it.\n\
1903 `set parallel on' means run the program on any CPUs that are available.",
1906 add_com ("1cont", class_run
, one_cont_command
,
1907 "Continue the program, activating only the current thread.\n\
1908 Args are the same as the `cont' command.");
1910 add_com ("thread", class_run
, set_thread_command
,
1911 "Change the current thread, the one under scrutiny and control.\n\
1912 With no arg, show the active threads, the current one marked with *.");
1914 add_info ("threads", thread_info
,
1915 "List status of active threads.");
1917 add_info ("comm-registers", comm_registers_info
,
1918 "List communication registers and their contents.\n\
1919 A communication register name as argument means describe only that register.\n\
1920 An address as argument means describe the resource structure at that address.\n\
1921 `Locked' means that the register has been sent to but not yet received from.");
1923 add_info ("psw", psw_info
,
1924 "Display $ps, the processor status word, bit by bit.\n\
1925 An argument means display that value's interpretation as a psw.");
1927 add_cmd ("convex", no_class
, 0, "Convex-specific commands.\n\
1928 32-bit registers $pc $ps $sp $ap $fp $a1-5 $s0-7 $v0-7 $vl $vs $vm $c0-63\n\
1929 64-bit registers $S0-7 $V0-7 $C0-63\n\
1931 info threads display info on stopped threads waiting to signal\n\
1932 thread display list of active threads\n\
1933 thread N select thread N (its registers, stack, memory, etc.)\n\
1934 step, next, etc step selected thread only\n\
1935 1cont continue selected thread only\n\
1936 cont continue all threads\n\
1937 info comm-registers display contents of comm register(s) or a resource struct\n\
1938 info psw display processor status word $ps\n\
1939 set base N change integer radix used by `print' without a format\n\
1940 set pipeline off exceptions are precise, $pc points after the faulting insn\n\
1941 set pipeline on normal mode, $pc is somewhere ahead of faulting insn\n\
1942 set parallel off program runs on a single CPU\n\
1943 set parallel fixed all CPUs are assigned to the program\n\
1944 set parallel on normal mode, parallel execution on random available CPUs\n\