1 /* Convex stuff for GDB.
2 Copyright (C) 1990, 1991, 1996 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program 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 2 of the License, or
9 (at your option) any later version.
11 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
32 #include <sys/param.h>
35 #include <sys/ioctl.h>
36 #include <sys/pcntl.h>
37 #include <sys/thread.h>
46 convex_skip_prologue (pc
)
50 op
= read_memory_integer (pc
, 2);
51 if ((op
& 0xffc7) == 0x5ac0)
53 else if (op
== 0x1580)
55 else if (op
== 0x15c0)
57 if ((read_memory_integer (pc
, 2) & 0xfff8) == 0x7c40
58 && (read_memory_integer (pc
+ 2, 2) & 0xfff8) == 0x1240
59 && (read_memory_integer (pc
+ 8, 2) & 0xfff8) == 0x7c48)
61 if (read_memory_integer (pc
, 2) == 0x1240)
65 op
= read_memory_integer (pc
, 2);
69 if ((op
& 0xfcc0) == 0x3000)
71 else if ((op
& 0xfcc0) == 0x3040)
73 else if ((op
& 0xfcc0) == 0x2800)
75 else if ((op
& 0xfcc0) == 0x2840)
84 convex_frameless_function_invocation (fi
)
85 struct frame_info
*fi
;
88 extern CORE_ADDR text_start
, text_end
;
89 CORE_ADDR call_addr
= SAVED_PC_AFTER_CALL (FI
);
90 frameless
= (call_addr
>= text_start
&& call_addr
< text_end
91 && read_memory_integer (call_addr
- 6, 1) == 0x22);
96 convex_frame_num_args (fi
)
97 struct frame_info
*fi
;
99 int numargs
= read_memory_integer (FRAME_ARGS_ADDRESS (fi
) - 4, 4);
100 if (numargs
< 0 || numargs
>= 256)
105 exec_file_command (filename
, from_tty
)
113 /* Eliminate all traces of old exec file.
114 Mark text segment as empty. */
131 /* Now open and digest the file the user requested, if any. */
135 filename
= tilde_expand (filename
);
136 make_cleanup (free
, filename
);
138 execchan
= openp (getenv ("PATH"), 1, filename
, O_RDONLY
, 0,
141 perror_with_name (filename
);
143 if (myread (execchan
, &filehdr
, sizeof filehdr
) < 0)
144 perror_with_name (filename
);
146 if (! IS_SOFF_MAGIC (filehdr
.h_magic
))
147 error ("%s: not an executable file.", filename
);
149 if (myread (execchan
, &opthdr
, filehdr
.h_opthdr
) <= 0)
150 perror_with_name (filename
);
152 /* Read through the section headers.
153 For text, data, etc, record an entry in the exec file map.
154 Record text_start and text_end. */
156 lseek (execchan
, (long) filehdr
.h_scnptr
, 0);
158 for (n
= 0; n
< filehdr
.h_nscns
; n
++)
160 if (myread (execchan
, &scnhdr
, sizeof scnhdr
) < 0)
161 perror_with_name (filename
);
163 if ((scnhdr
.s_flags
& S_TYPMASK
) >= S_TEXT
164 && (scnhdr
.s_flags
& S_TYPMASK
) <= S_COMON
)
166 exec_map
[n_exec
].mem_addr
= scnhdr
.s_vaddr
;
167 exec_map
[n_exec
].mem_end
= scnhdr
.s_vaddr
+ scnhdr
.s_size
;
168 exec_map
[n_exec
].file_addr
= scnhdr
.s_scnptr
;
169 exec_map
[n_exec
].type
= scnhdr
.s_flags
& S_TYPMASK
;
172 if ((scnhdr
.s_flags
& S_TYPMASK
) == S_TEXT
)
174 text_start
= scnhdr
.s_vaddr
;
175 text_end
= scnhdr
.s_vaddr
+ scnhdr
.s_size
;
180 fstat (execchan
, &st_exec
);
181 exec_mtime
= st_exec
.st_mtime
;
186 printf_filtered ("No executable file now.\n");
188 /* Tell display code (if any) about the changed file name. */
189 if (exec_file_display_hook
)
190 (*exec_file_display_hook
) (filename
);
194 /* Read data from SOFF exec or core file.
195 Return 0 on success, EIO if address out of bounds. */
198 xfer_core_file (memaddr
, myaddr
, len
)
216 /* Determine which file the next bunch of addresses reside in,
217 and where in the file. Set the file's read/write pointer
218 to point at the proper place for the desired address
219 and set xferfile and xferchan for the correct file.
220 If desired address is nonexistent, leave them zero.
221 i is set to the number of bytes that can be handled
222 along with the next address. */
226 for (n
= 0; n
< n_core
; n
++)
228 if (memaddr
>= core_map
[n
].mem_addr
&& memaddr
< core_map
[n
].mem_end
229 && (core_map
[n
].thread
== -1
230 || core_map
[n
].thread
== inferior_thread
))
232 i
= min (len
, core_map
[n
].mem_end
- memaddr
);
233 fileptr
= core_map
[n
].file_addr
+ memaddr
- core_map
[n
].mem_addr
;
234 if (core_map
[n
].file_addr
)
236 xferfile
= &corefile
;
241 else if (core_map
[n
].mem_addr
>= memaddr
242 && core_map
[n
].mem_addr
< memaddr
+ i
)
243 i
= core_map
[n
].mem_addr
- memaddr
;
247 for (n
= 0; n
< n_exec
; n
++)
249 if (memaddr
>= exec_map
[n
].mem_addr
250 && memaddr
< exec_map
[n
].mem_end
)
252 i
= min (len
, exec_map
[n
].mem_end
- memaddr
);
253 fileptr
= exec_map
[n
].file_addr
+ memaddr
254 - exec_map
[n
].mem_addr
;
255 if (exec_map
[n
].file_addr
)
257 xferfile
= &execfile
;
262 else if (exec_map
[n
].mem_addr
>= memaddr
263 && exec_map
[n
].mem_addr
< memaddr
+ i
)
264 i
= exec_map
[n
].mem_addr
- memaddr
;
267 /* Now we know which file to use.
268 Set up its pointer and transfer the data. */
272 if (xferfile
== &execfile
)
273 error ("No program file to examine.");
275 error ("No core dump file or running program to examine.");
276 val
= lseek (xferchan
, fileptr
, 0);
278 perror_with_name (*xferfile
);
279 val
= myread (xferchan
, myaddr
, i
);
281 perror_with_name (*xferfile
);
283 /* If this address is for nonexistent memory,
284 read zeros if reading, or do nothing if writing. */
287 memset (myaddr
, '\0', i
);
299 /* Here from info files command to print an address map. */
303 struct pmap ptrs
[200];
306 /* ID strings for core and executable file sections */
308 static char *idstr
[] =
310 "0", "text", "data", "tdata", "bss", "tbss",
311 "common", "ttext", "ctx", "tctx", "10", "11", "12",
314 for (n
= 0; n
< n_core
; n
++)
316 core_map
[n
].which
= 0;
317 ptrs
[n
] = core_map
[n
];
319 for (n
= 0; n
< n_exec
; n
++)
321 exec_map
[n
].which
= 1;
322 ptrs
[n_core
+n
] = exec_map
[n
];
325 qsort (ptrs
, n_core
+ n_exec
, sizeof *ptrs
, ptr_cmp
);
327 for (n
= 0; n
< n_core
+ n_exec
; n
++)
329 struct pmap
*p
= &ptrs
[n
];
332 if (p
->mem_addr
< ptrs
[n
-1].mem_end
)
333 p
->mem_addr
= ptrs
[n
-1].mem_end
;
334 if (p
->mem_addr
>= p
->mem_end
)
337 printf_filtered ("%08x .. %08x %-6s %s\n",
338 p
->mem_addr
, p
->mem_end
, idstr
[p
->type
],
339 p
->which
? execfile
: corefile
);
343 /* Compare routine to put file sections in order.
344 Sort into increasing order on address, and put core file sections
345 before exec file sections if both files contain the same addresses. */
347 static ptr_cmp (a
, b
)
350 if (a
->mem_addr
!= b
->mem_addr
) return a
->mem_addr
- b
->mem_addr
;
351 return a
->which
- b
->which
;
354 /* Trapped internal variables are used to handle special registers.
355 A trapped i.v. calls a hook here every time it is dereferenced,
356 to provide a new value for the variable, and it calls a hook here
357 when a new value is assigned, to do something with the value.
359 The vector registers are $vl, $vs, $vm, $vN, $VN (N in 0..7).
360 The communication registers are $cN, $CN (N in 0..63).
361 They not handled as regular registers because it's expensive to
362 read them, and their size varies, and they have too many names. */
365 /* Return 1 if NAME is a trapped internal variable, else 0. */
368 is_trapped_internalvar (name
)
371 if ((name
[0] == 'c' || name
[0] == 'C')
372 && name
[1] >= '0' && name
[1] <= '9'
374 || (name
[2] >= '0' && name
[2] <= '9'
375 && name
[3] == '\0' && name
[1] != '0'))
376 && atoi (&name
[1]) < 64) return 1;
378 if ((name
[0] == 'v' || name
[0] == 'V')
379 && (((name
[1] & -8) == '0' && name
[2] == '\0')
380 || STREQ (name
, "vl")
381 || STREQ (name
, "vs")
382 || STREQ (name
, "vm")))
387 /* Return the value of trapped internal variable VAR */
390 value_of_trapped_internalvar (var
)
391 struct internalvar
*var
;
393 char *name
= var
->name
;
396 struct type
*range_type
;
397 long len
= *read_vector_register (VL_REGNUM
);
398 if (len
<= 0 || len
> 128) len
= 128;
400 if (STREQ (name
, "vl"))
402 val
= value_from_longest (builtin_type_int
,
403 (LONGEST
) *read_vector_register_1 (VL_REGNUM
));
405 else if (STREQ (name
, "vs"))
407 val
= value_from_longest (builtin_type_int
,
408 (LONGEST
) *read_vector_register_1 (VS_REGNUM
));
410 else if (STREQ (name
, "vm"))
414 memcpy (vm
, read_vector_register_1 (VM_REGNUM
), sizeof vm
);
416 create_range_type ((struct type
*) NULL
, builtin_type_int
, 0, len
- 1);
418 create_array_type ((struct type
*) NULL
, builtin_type_int
, range_type
);
419 val
= allocate_value (type
);
420 p
= (long *) VALUE_CONTENTS (val
);
421 for (i
= 0; i
< len
; i
++)
422 *p
++ = !! (vm
[3 - (i
>> 5)] & (1 << (i
& 037)));
424 else if (name
[0] == 'V')
427 create_range_type ((struct type
*) NULL
, builtin_type_int
0, len
- 1);
429 create_array_type ((struct type
*) NULL
, builtin_type_long_long
,
431 val
= allocate_value (type
);
432 memcpy (VALUE_CONTENTS (val
),
433 read_vector_register_1 (name
[1] - '0'),
436 else if (name
[0] == 'v')
440 create_range_type ((struct type
*) NULL
, builtin_type_int
0, len
- 1);
442 create_array_type ((struct type
*) NULL
, builtin_type_long
,
444 val
= allocate_value (type
);
445 p1
= read_vector_register_1 (name
[1] - '0');
446 p2
= (long *) VALUE_CONTENTS (val
);
447 while (--len
>= 0) {p1
++; *p2
++ = *p1
++;}
450 else if (name
[0] == 'c')
451 val
= value_from_longest (builtin_type_int
,
452 read_comm_register (atoi (&name
[1])));
453 else if (name
[0] == 'C')
454 val
= value_from_longest (builtin_type_long_long
,
455 read_comm_register (atoi (&name
[1])));
457 VALUE_LVAL (val
) = lval_internalvar
;
458 VALUE_INTERNALVAR (val
) = var
;
462 /* Handle a new value assigned to a trapped internal variable */
465 set_trapped_internalvar (var
, val
, bitpos
, bitsize
, offset
)
466 struct internalvar
*var
;
468 int bitpos
, bitsize
, offset
;
470 char *name
= var
->name
;
471 long long newval
= value_as_long (val
);
473 if (STREQ (name
, "vl"))
474 write_vector_register (VL_REGNUM
, 0, newval
);
475 else if (STREQ (name
, "vs"))
476 write_vector_register (VS_REGNUM
, 0, newval
);
477 else if (name
[0] == 'c' || name
[0] == 'C')
478 write_comm_register (atoi (&name
[1]), newval
);
479 else if (STREQ (name
, "vm"))
480 error ("can't assign to $vm");
483 offset
/= bitsize
/ 8;
484 write_vector_register (name
[1] - '0', offset
, newval
);
488 /* Print an integer value when no format was specified. gdb normally
489 prints these values in decimal, but the the leading 0x80000000 of
490 pointers produces intolerable 10-digit negative numbers.
491 If it looks like an address, print it in hex instead. */
493 decout (stream
, type
, val
)
500 switch (output_radix
)
503 if ((lv
== val
|| (unsigned) lv
== val
)
504 && ((lv
& 0xf0000000) == 0x80000000
505 || ((lv
& 0xf0000000) == 0xf0000000 && lv
< STACK_END_ADDR
)))
507 print_longest (stream
, "x", 0, val
);
512 print_longest (stream
, TYPE_UNSIGNED (type
) ? "u" : "d", 0, val
);
516 print_longest (stream
, "o", 0, val
);
520 print_longest (stream
, "x", 0, val
);
525 /* Change the default output radix to 10 or 16, or set it to 0 (heuristic).
526 This command is mostly obsolete now that the print command allows
527 formats to apply to aggregates, but is still handy occasionally. */
530 set_base_command (arg
)
539 new_radix
= atoi (arg
);
540 if (new_radix
!= 10 && new_radix
!= 16 && new_radix
!= 8)
541 error ("base must be 8, 10 or 16, or null");
542 else output_radix
= new_radix
;
546 /* Turn pipelining on or off in the inferior. */
549 set_pipelining_command (arg
)
554 sequential
= !sequential
;
555 printf_filtered ("%s\n", sequential
? "off" : "on");
557 else if (STREQ (arg
, "on"))
559 else if (STREQ (arg
, "off"))
561 else error ("valid args are `on', to allow instructions to overlap, or\n\
562 `off', to prevent it and thereby pinpoint exceptions.");
565 /* Enable, disable, or force parallel execution in the inferior. */
568 set_parallel_command (arg
)
572 int prevparallel
= parallel
;
574 if (!strncmp (arg
, "fixed", strlen (arg
)))
576 else if (STREQ (arg
, "on"))
578 else if (STREQ (arg
, "off"))
580 else error ("valid args are `on', to allow multiple threads, or\n\
581 `fixed', to force multiple threads, or\n\
582 `off', to run with one thread only.");
584 if ((prevparallel
== 0) != (parallel
== 0) && inferior_pid
)
585 printf_filtered ("will take effect at next run.\n");
587 getrlimit (RLIMIT_CONCUR
, &rl
);
588 rl
.rlim_cur
= parallel
? rl
.rlim_max
: 1;
589 setrlimit (RLIMIT_CONCUR
, &rl
);
592 set_fixed_scheduling (inferior_pid
, parallel
== 2);
595 /* Add a new name for an existing command. */
601 static char *aliaserr
= "usage is `alias NEW OLD', no args allowed";
603 struct cmd_list_element
*new, *old
;
606 error_no_arg ("newname oldname");
608 new = lookup_cmd (&arg
, cmdlist
, "", -1);
609 if (new && !strncmp (newname
, new->name
, strlen (new->name
)))
613 || (*arg
>= 'a' && *arg
<= 'z')
614 || (*arg
>= 'A' && *arg
<= 'Z')
615 || (*arg
>= '0' && *arg
<= '9')))
622 || (*arg
>= 'a' && *arg
<= 'z')
623 || (*arg
>= 'A' && *arg
<= 'Z')
624 || (*arg
>= '0' && *arg
<= '9'))
626 if (*arg
!= ' ' && *arg
!= '\t')
632 old
= lookup_cmd (&arg
, cmdlist
, "", 0);
637 if (new && !strncmp (newname
, new->name
, strlen (new->name
)))
640 if (new->class == (int) class_user
|| new->class == (int) class_alias
)
641 tem
= "Redefine command \"%s\"? ";
643 tem
= "Really redefine built-in command \"%s\"? ";
644 if (!query (tem
, new->name
))
645 error ("Command \"%s\" not redefined.", new->name
);
648 add_com (newname
, class_alias
, old
->function
, old
->doc
);
653 /* Print the current thread number, and any threads with signals in the
660 if (have_inferior_p ())
662 ps
.pi_buffer
= (char *) &comm_registers
;
663 ps
.pi_nbytes
= sizeof comm_registers
;
665 ps
.pi_thread
= inferior_thread
;
666 ioctl (inferior_fd
, PIXRDCREGS
, &ps
);
669 /* FIXME: stop_signal is from target.h but stop_sigcode is a
670 convex-specific thing. */
671 printf_filtered ("Current thread %d stopped with signal %d.%d (%s).\n",
672 inferior_thread
, stop_signal
, stop_sigcode
,
673 subsig_name (stop_signal
, stop_sigcode
));
675 for (p
= signal_stack
; p
->pid
; p
--)
676 printf_filtered ("Thread %d stopped with signal %d.%d (%s).\n",
677 p
->thread
, p
->signo
, p
->subsig
,
678 subsig_name (p
->signo
, p
->subsig
));
680 if (iscrlbit (comm_registers
.crctl
.lbits
.cc
, 64+13))
681 printf_filtered ("New thread start pc %#x\n",
682 (long) (comm_registers
.crreg
.pcpsw
>> 32));
685 /* Return string describing a signal.subcode number */
688 subsig_name (signo
, subcode
)
691 static char *subsig4
[] = {
692 "error exit", "privileged instruction", "unknown",
693 "unknown", "undefined opcode",
695 static char *subsig5
[] = {0,
696 "breakpoint", "single step", "fork trap", "exec trap", "pfork trap",
697 "join trap", "idle trap", "last thread", "wfork trap",
698 "process breakpoint", "trap instruction",
700 static char *subsig8
[] = {0,
701 "int overflow", "int divide check", "float overflow",
702 "float divide check", "float underflow", "reserved operand",
703 "sqrt error", "exp error", "ln error", "sin error", "cos error",
705 static char *subsig10
[] = {0,
706 "invalid inward ring address", "invalid outward ring call",
707 "invalid inward ring return", "invalid syscall gate",
708 "invalid rtn frame length", "invalid comm reg address",
711 static char *subsig11
[] = {0,
712 "read access denied", "write access denied", "execute access denied",
713 "segment descriptor fault", "page table fault", "data reference fault",
714 "i/o access denied", "levt pte invalid",
717 static char **subsig_list
[] =
718 {0, 0, 0, 0, subsig4
, subsig5
, 0, 0, subsig8
, 0, subsig10
, subsig11
, 0};
723 if ((p
= strsignal (signo
)) == NULL
)
725 if (signo
>= (sizeof subsig_list
/ sizeof *subsig_list
)
726 || !subsig_list
[signo
])
728 for (i
= 1; subsig_list
[signo
][i
]; i
++)
730 return subsig_list
[signo
][subcode
];
735 /* Print a compact display of thread status, essentially x/i $pc
736 for all active threads. */
743 for (t
= 0; t
< n_threads
; t
++)
744 if (thread_state
[t
] == PI_TALIVE
)
746 printf_filtered ("%d%c %08x%c %d.%d ", t
,
747 (t
== inferior_thread
? '*' : ' '), thread_pc
[t
],
748 (thread_is_in_kernel
[t
] ? '#' : ' '),
749 thread_signal
[t
], thread_sigcode
[t
]);
750 print_insn (thread_pc
[t
], stdout
);
751 printf_filtered ("\n");
755 /* Change the current thread to ARG. */
757 set_thread_command (arg
)
768 thread
= parse_and_eval_address (arg
);
770 if (thread
< 0 || thread
> n_threads
|| thread_state
[thread
] != PI_TALIVE
)
771 error ("no such thread.");
773 select_thread (thread
);
775 stop_pc
= read_pc ();
776 flush_cached_frames ();
777 select_frame (get_current_frame (), 0);
778 print_stack_frame (selected_frame
, selected_frame_level
, -1);
781 /* Here on CONT command; gdb's dispatch address is changed to come here.
782 Set global variable ALL_CONTINUE to tell resume() that it should
783 start up all threads, and that a thread switch will not blow gdb's
787 convex_cont_command (proc_count_exp
, from_tty
)
788 char *proc_count_exp
;
792 cont_command (proc_count_exp
, from_tty
);
795 /* Here on 1CONT command. Resume only the current thread. */
797 one_cont_command (proc_count_exp
, from_tty
)
798 char *proc_count_exp
;
801 cont_command (proc_count_exp
, from_tty
);
804 /* Print the contents and lock bits of all communication registers,
805 or just register ARG if ARG is a communication register,
806 or the 3-word resource structure in memory at address ARG. */
808 comm_registers_info (arg
)
815 if (sscanf (arg
, "$c%d", ®num
) == 1) {
817 } else if (sscanf (arg
, "$C%d", ®num
) == 1) {
820 regnum
= parse_and_eval_address (arg
);
826 error ("%s: invalid register name.", arg
);
828 /* if we got a (user) address, examine the resource struct there */
833 read_memory (regnum
, buf
, sizeof buf
);
834 printf_filtered ("%08x %08x%08x%s\n", regnum
, buf
[1], buf
[2],
835 buf
[0] & 0xff ? " locked" : "");
840 ps
.pi_buffer
= (char *) &comm_registers
;
841 ps
.pi_nbytes
= sizeof comm_registers
;
843 ps
.pi_thread
= inferior_thread
;
844 ioctl (inferior_fd
, PIXRDCREGS
, &ps
);
846 for (i
= 0; i
< 64; i
++)
847 if (!arg
|| i
== regnum
)
848 printf_filtered ("%2d 0x8%03x %016llx%s\n", i
, i
,
849 comm_registers
.crreg
.r4
[i
],
850 (iscrlbit (comm_registers
.crctl
.lbits
.cc
, i
)
867 static struct pswbit pswbit
[] =
869 { 0x80000000, -1, "A carry" },
870 { 0x40000000, -1, "A integer overflow" },
871 { 0x20000000, -1, "A zero divide" },
872 { 0x10000000, -1, "Integer overflow enable" },
873 { 0x08000000, -1, "Trace" },
874 { 0x06000000, 25, "Frame length" },
875 { 0x01000000, -1, "Sequential" },
876 { 0x00800000, -1, "S carry" },
877 { 0x00400000, -1, "S integer overflow" },
878 { 0x00200000, -1, "S zero divide" },
879 { 0x00100000, -1, "Zero divide enable" },
880 { 0x00080000, -1, "Floating underflow" },
881 { 0x00040000, -1, "Floating overflow" },
882 { 0x00020000, -1, "Floating reserved operand" },
883 { 0x00010000, -1, "Floating zero divide" },
884 { 0x00008000, -1, "Floating error enable" },
885 { 0x00004000, -1, "Floating underflow enable" },
886 { 0x00002000, -1, "IEEE" },
887 { 0x00001000, -1, "Sequential stores" },
888 { 0x00000800, -1, "Intrinsic error" },
889 { 0x00000400, -1, "Intrinsic error enable" },
890 { 0x00000200, -1, "Trace thread creates" },
891 { 0x00000100, -1, "Thread init trap" },
892 { 0x000000e0, 5, "Reserved" },
893 { 0x0000001f, 0, "Intrinsic error code" },
901 psw
= parse_and_eval_address (arg
);
903 psw
= read_register (PS_REGNUM
);
905 for (p
= pswbit
; p
->bit
; p
++)
908 printf_filtered ("%08x %s %s\n", p
->bit
,
909 (psw
& p
->bit
) ? "yes" : "no ", p
->text
);
911 printf_filtered ("%08x %3d %s\n", p
->bit
,
912 (psw
& p
->bit
) >> p
->pos
, p
->text
);
918 /* reg (fmt_field, inst_field) --
919 the {first,second,third} operand of instruction as fmt_field = [ijk]
920 gets the value of the field from the [ijk] position of the instruction */
922 #define reg(a,b) ((char (*)[3])(op[fmt->a]))[inst.f0.b]
924 /* lit (fmt_field) -- field [ijk] is a literal (PSW, VL, eg) */
926 #define lit(i) op[fmt->i]
928 /* aj[j] -- name for A register j */
930 #define aj ((char (*)[3])(op[A]))
950 unsigned char byte
[8];
951 unsigned short half
[4];
953 short signed_half
[4];
957 int mask
; /* opcode mask */
958 int shift
; /* opcode align */
959 struct formstr
*formstr
[3]; /* ST, E0, E1 */
963 unsigned lop
:8, rop
:5; /* opcode */
964 unsigned fmt
:5; /* inst format */
965 unsigned i
:5, j
:5, k
:2; /* operand formats */
968 #include "opcode/convex.h"
970 CONST
unsigned char formdecode
[] = {
971 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
972 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
973 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
974 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
975 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
976 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
977 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
978 4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8,
979 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
980 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
981 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
982 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
983 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
984 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
985 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
986 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
989 CONST
struct opform opdecode
[] = {
990 0x7e00, 9, format0
, e0_format0
, e1_format0
,
991 0x3f00, 8, format1
, e0_format1
, e1_format1
,
992 0x1fc0, 6, format2
, e0_format2
, e1_format2
,
993 0x0fc0, 6, format3
, e0_format3
, e1_format3
,
994 0x0700, 8, format4
, e0_format4
, e1_format4
,
995 0x03c0, 6, format5
, e0_format5
, e1_format5
,
996 0x01f8, 3, format6
, e0_format6
, e1_format6
,
997 0x00f8, 3, format7
, e0_format7
, e1_format7
,
998 0x0000, 0, formatx
, formatx
, formatx
,
999 0x0f80, 7, formatx
, formatx
, formatx
,
1000 0x0f80, 7, formatx
, formatx
, formatx
,
1003 /* Print the instruction at address MEMADDR in debugged memory,
1004 on STREAM. Returns length of the instruction, in bytes. */
1007 convex_print_insn (memaddr
, stream
)
1012 struct formstr
*fmt
;
1013 register int format
, op1
, pfx
;
1016 read_memory (memaddr
, &inst
, sizeof inst
);
1018 /* Remove and note prefix, if present */
1021 if ((pfx
& 0xfff0) == 0x7ef0)
1023 pfx
= ((pfx
>> 3) & 1) + 1;
1024 *(long long *) &inst
= *(long long *) &inst
.half
[1];
1028 /* Split opcode into format.op1 and look up in appropriate table */
1030 format
= formdecode
[inst
.byte
[0]];
1031 op1
= (inst
.half
[0] & opdecode
[format
].mask
) >> opdecode
[format
].shift
;
1036 else if (inst
.f1
.j
== 0)
1037 fmt
= &format1a
[op1
];
1038 else if (inst
.f1
.j
== 1)
1039 fmt
= &format1b
[op1
];
1044 fmt
= &opdecode
[format
].formstr
[pfx
][op1
];
1048 if (fmt
->fmt
== xxx
)
1050 /* noninstruction */
1051 fprintf (stream
, "0x%04x", pfx
? pfx
: inst
.half
[0]);
1058 fprintf (stream
, "%s%s%s", lop
[fmt
->lop
], rop
[fmt
->rop
],
1059 &" "[strlen(lop
[fmt
->lop
]) + strlen(rop
[fmt
->rop
])]);
1063 case rrr
: /* three register */
1064 fprintf (stream
, "%s,%s,%s", reg(i
,i
), reg(j
,j
), reg(k
,k
));
1067 case rr
: /* two register */
1068 fprintf (stream
, "%s,%s", reg(i
,j
), reg(j
,k
));
1071 case rxr
: /* two register, reversed i and j fields */
1072 fprintf (stream
, "%s,%s", reg(i
,k
), reg(j
,j
));
1075 case r
: /* one register */
1076 fprintf (stream
, "%s", reg(i
,k
));
1079 case nops
: /* no operands */
1082 case nr
: /* short immediate, one register */
1083 fprintf (stream
, "#%d,%s", inst
.f0
.j
, reg(i
,k
));
1086 case pcrel
: /* pc relative */
1087 print_address (memaddr
+ 2 * inst
.signed_byte
[1], stream
);
1090 case lr
: /* literal, one register */
1091 fprintf (stream
, "%s,%s", lit(i
), reg(j
,k
));
1094 case rxl
: /* one register, literal */
1095 fprintf (stream
, "%s,%s", reg(i
,k
), lit(j
));
1098 case rlr
: /* register, literal, register */
1099 fprintf (stream
, "%s,%s,%s", reg(i
,j
), lit(j
), reg(k
,k
));
1102 case rrl
: /* register, register, literal */
1103 fprintf (stream
, "%s,%s,%s", reg(i
,j
), reg(j
,k
), lit(k
));
1106 case iml
: /* immediate, literal */
1109 fprintf (stream
, "#%#x,%s",
1110 (inst
.signed_half
[1] << 16) + inst
.half
[2], lit(i
));
1115 fprintf (stream
, "#%d,%s", inst
.signed_half
[1], lit(i
));
1119 case imr
: /* immediate, register */
1122 fprintf (stream
, "#%#x,%s",
1123 (inst
.signed_half
[1] << 16) + inst
.half
[2], reg(i
,k
));
1128 fprintf (stream
, "#%d,%s", inst
.signed_half
[1], reg(i
,k
));
1132 case a1r
: /* memory, register */
1133 l
= print_effa (inst
, stream
);
1134 fprintf (stream
, ",%s", reg(i
,k
));
1137 case a1l
: /* memory, literal */
1138 l
= print_effa (inst
, stream
);
1139 fprintf (stream
, ",%s", lit(i
));
1142 case a2r
: /* register, memory */
1143 fprintf (stream
, "%s,", reg(i
,k
));
1144 return pfx
+ print_effa (inst
, stream
);
1146 case a2l
: /* literal, memory */
1147 fprintf (stream
, "%s,", lit(i
));
1148 return pfx
+ print_effa (inst
, stream
);
1150 case a3
: /* memory */
1151 return pfx
+ print_effa (inst
, stream
);
1153 case a4
: /* system call */
1160 unsigned int m
= (inst
.signed_half
[1] << 16) + inst
.half
[2];
1161 fprintf (stream
, "#%d,#%d", m
>> l
, m
& (-1 >> (32-l
)));
1166 unsigned int m
= inst
.signed_half
[1];
1167 fprintf (stream
, "#%d,#%d", m
>> l
, m
& (-1 >> (32-l
)));
1174 /* print effective address @nnn(aj), return instruction length */
1176 int print_effa (inst
, stream
)
1184 n
= (inst
.signed_half
[1] << 16) + inst
.half
[2];
1189 n
= inst
.signed_half
[1];
1198 print_address (n
, stream
);
1202 fprintf (stream
, (n
& 0xf0000000) == 0x80000000 ? "%#x(%s)" : "%d(%s)",
1210 _initialize_convex_dep ()
1212 add_com ("alias", class_support
, alias_command
,
1213 "Add a new name for an existing command.");
1215 add_cmd ("base", class_vars
, set_base_command
,
1216 "Change the integer output radix to 8, 10 or 16\n\
1217 or use just `set base' with no args to return to the ad-hoc default,\n\
1218 which is 16 for integers that look like addresses, 10 otherwise.",
1221 add_cmd ("pipeline", class_run
, set_pipelining_command
,
1222 "Enable or disable overlapped execution of instructions.\n\
1223 With `set pipe off', exceptions are reported with\n\
1224 $pc pointing at the instruction after the faulting one.\n\
1225 The default is `set pipe on', which runs faster.",
1228 add_cmd ("parallel", class_run
, set_parallel_command
,
1229 "Enable or disable multi-threaded execution of parallel code.\n\
1230 `set parallel off' means run the program on a single CPU.\n\
1231 `set parallel fixed' means run the program with all CPUs assigned to it.\n\
1232 `set parallel on' means run the program on any CPUs that are available.",
1235 add_com ("1cont", class_run
, one_cont_command
,
1236 "Continue the program, activating only the current thread.\n\
1237 Args are the same as the `cont' command.");
1239 add_com ("thread", class_run
, set_thread_command
,
1240 "Change the current thread, the one under scrutiny and control.\n\
1241 With no arg, show the active threads, the current one marked with *.");
1243 add_info ("threads", thread_info
,
1244 "List status of active threads.");
1246 add_info ("comm-registers", comm_registers_info
,
1247 "List communication registers and their contents.\n\
1248 A communication register name as argument means describe only that register.\n\
1249 An address as argument means describe the resource structure at that address.\n\
1250 `Locked' means that the register has been sent to but not yet received from.");
1252 add_info ("psw", psw_info
,
1253 "Display $ps, the processor status word, bit by bit.\n\
1254 An argument means display that value's interpretation as a psw.");
1256 add_cmd ("convex", no_class
, 0, "Convex-specific commands.\n\
1257 32-bit registers $pc $ps $sp $ap $fp $a1-5 $s0-7 $v0-7 $vl $vs $vm $c0-63\n\
1258 64-bit registers $S0-7 $V0-7 $C0-63\n\
1260 info threads display info on stopped threads waiting to signal\n\
1261 thread display list of active threads\n\
1262 thread N select thread N (its registers, stack, memory, etc.)\n\
1263 step, next, etc step selected thread only\n\
1264 1cont continue selected thread only\n\
1265 cont continue all threads\n\
1266 info comm-registers display contents of comm register(s) or a resource struct\n\
1267 info psw display processor status word $ps\n\
1268 set base N change integer radix used by `print' without a format\n\
1269 set pipeline off exceptions are precise, $pc points after the faulting insn\n\
1270 set pipeline on normal mode, $pc is somewhere ahead of faulting insn\n\
1271 set parallel off program runs on a single CPU\n\
1272 set parallel fixed all CPUs are assigned to the program\n\
1273 set parallel on normal mode, parallel execution on random available CPUs\n\
This page took 0.056732 seconds and 4 git commands to generate.