1 /* OBSOLETE /* GOULD RISC target-dependent code for GDB, the GNU debugger. */
2 /* OBSOLETE Copyright 1986, 1987, 1989, 1991 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 "symtab.h" */
22 /* OBSOLETE #include "frame.h" */
23 /* OBSOLETE #include "gdbcore.h" */
24 /* OBSOLETE #if defined GOULD_PN */
25 /* OBSOLETE #include "opcode/pn.h" */
27 /* OBSOLETE #include "opcode/np1.h" */
30 /* OBSOLETE /* GOULD RISC instructions are never longer than this many bytes. *x/ */
31 /* OBSOLETE #define MAXLEN 4 */
33 /* OBSOLETE /* Number of elements in the opcode table. *x/ */
34 /* OBSOLETE #define NOPCODES (sizeof gld_opcodes / sizeof gld_opcodes[0]) */
37 /* OBSOLETE gould_frame_chain_valid (chain, fi) */
38 /* OBSOLETE CORE_ADDR chain; */
39 /* OBSOLETE struct frame_info *fi; /* not used here *x/ */
41 /* OBSOLETE return (chain != 0 && chain != (thisframe)->frame); */
44 /* OBSOLETE /* Both gcc and cc return small structs in registers (i.e. in GDB */
45 /* OBSOLETE terminology, small structs don't use the struct return convention). *x/ */
47 /* OBSOLETE gould_use_struct_convention (gcc_p, type) */
48 /* OBSOLETE int gcc_p; */
49 /* OBSOLETE struct type *type; */
51 /* OBSOLETE return (TYPE_LENGTH(type) > 8); */
56 /* OBSOLETE /* Print the GOULD instruction at address MEMADDR in debugged memory, */
57 /* OBSOLETE on STREAM. Returns length of the instruction, in bytes. *x/ */
60 /* OBSOLETE gould_print_insn (memaddr, stream) */
61 /* OBSOLETE CORE_ADDR memaddr; */
62 /* OBSOLETE FILE *stream; */
64 /* OBSOLETE unsigned char buffer[MAXLEN]; */
65 /* OBSOLETE register int i; */
66 /* OBSOLETE register char *d; */
67 /* OBSOLETE register int bestmask; */
68 /* OBSOLETE unsigned best; */
69 /* OBSOLETE int temp, index, bestlen; */
71 /* OBSOLETE read_memory (memaddr, buffer, MAXLEN); */
73 /* OBSOLETE bestmask = 0; */
74 /* OBSOLETE index = -1; */
75 /* OBSOLETE best = 0xffffffff; */
76 /* OBSOLETE for (i = 0; i < NOPCODES; i++) */
78 /* OBSOLETE register unsigned int opcode = gld_opcodes[i].opcode; */
79 /* OBSOLETE register unsigned int mask = gld_opcodes[i].mask; */
80 /* OBSOLETE register unsigned int len = gld_opcodes[i].length; */
81 /* OBSOLETE register unsigned int test; */
83 /* OBSOLETE /* Get possible opcode bytes into integer *x/ */
84 /* OBSOLETE test = buffer[0] << 24; */
85 /* OBSOLETE test |= buffer[1] << 16; */
86 /* OBSOLETE test |= buffer[2] << 8; */
87 /* OBSOLETE test |= buffer[3]; */
89 /* OBSOLETE /* Mask with opcode and see if match *x/ */
90 /* OBSOLETE if ((opcode & mask) == (test & mask)) */
92 /* OBSOLETE /* See if second or third match *x/ */
93 /* OBSOLETE if (index >= 0) */
95 /* OBSOLETE /* Take new one if it looks good *x/ */
96 /* OBSOLETE if (bestlen == MAXLEN && len == MAXLEN) */
98 /* OBSOLETE /* See if lower bits matched *x/ */
99 /* OBSOLETE if (((bestmask & 3) == 0) && */
100 /* OBSOLETE ((mask & 3) != 0)) */
102 /* OBSOLETE bestmask = mask; */
103 /* OBSOLETE bestlen = len; */
104 /* OBSOLETE best = test; */
105 /* OBSOLETE index = i; */
111 /* OBSOLETE /* First match, save it *x/ */
112 /* OBSOLETE bestmask = mask; */
113 /* OBSOLETE bestlen = len; */
114 /* OBSOLETE best = test; */
115 /* OBSOLETE index = i; */
120 /* OBSOLETE /* Handle undefined instructions. *x/ */
121 /* OBSOLETE if (index < 0) */
123 /* OBSOLETE fprintf (stream, "undefined 0%o",(buffer[0]<<8)+buffer[1]); */
124 /* OBSOLETE return 2; */
127 /* OBSOLETE /* Print instruction name *x/ */
128 /* OBSOLETE fprintf (stream, "%-12s", gld_opcodes[index].name); */
130 /* OBSOLETE /* Adjust if short instruction *x/ */
131 /* OBSOLETE if (gld_opcodes[index].length < 4) */
133 /* OBSOLETE best >>= 16; */
134 /* OBSOLETE i = 0; */
138 /* OBSOLETE i = 16; */
141 /* OBSOLETE /* Dump out instruction arguments *x/ */
142 /* OBSOLETE for (d = gld_opcodes[index].args; *d; ++d) */
144 /* OBSOLETE switch (*d) */
146 /* OBSOLETE case 'f': */
147 /* OBSOLETE fprintf (stream, "%d", (best >> (7 + i)) & 7); */
148 /* OBSOLETE break; */
149 /* OBSOLETE case 'r': */
150 /* OBSOLETE fprintf (stream, "r%d", (best >> (7 + i)) & 7); */
151 /* OBSOLETE break; */
152 /* OBSOLETE case 'R': */
153 /* OBSOLETE fprintf (stream, "r%d", (best >> (4 + i)) & 7); */
154 /* OBSOLETE break; */
155 /* OBSOLETE case 'b': */
156 /* OBSOLETE fprintf (stream, "b%d", (best >> (7 + i)) & 7); */
157 /* OBSOLETE break; */
158 /* OBSOLETE case 'B': */
159 /* OBSOLETE fprintf (stream, "b%d", (best >> (4 + i)) & 7); */
160 /* OBSOLETE break; */
161 /* OBSOLETE case 'v': */
162 /* OBSOLETE fprintf (stream, "b%d", (best >> (7 + i)) & 7); */
163 /* OBSOLETE break; */
164 /* OBSOLETE case 'V': */
165 /* OBSOLETE fprintf (stream, "b%d", (best >> (4 + i)) & 7); */
166 /* OBSOLETE break; */
167 /* OBSOLETE case 'X': */
168 /* OBSOLETE temp = (best >> 20) & 7; */
169 /* OBSOLETE if (temp) */
170 /* OBSOLETE fprintf (stream, "r%d", temp); */
172 /* OBSOLETE putc ('0', stream); */
173 /* OBSOLETE break; */
174 /* OBSOLETE case 'A': */
175 /* OBSOLETE temp = (best >> 16) & 7; */
176 /* OBSOLETE if (temp) */
177 /* OBSOLETE fprintf (stream, "(b%d)", temp); */
178 /* OBSOLETE break; */
179 /* OBSOLETE case 'S': */
180 /* OBSOLETE fprintf (stream, "#%d", best & 0x1f); */
181 /* OBSOLETE break; */
182 /* OBSOLETE case 'I': */
183 /* OBSOLETE fprintf (stream, "#%x", best & 0xffff); */
184 /* OBSOLETE break; */
185 /* OBSOLETE case 'O': */
186 /* OBSOLETE fprintf (stream, "%x", best & 0xffff); */
187 /* OBSOLETE break; */
188 /* OBSOLETE case 'h': */
189 /* OBSOLETE fprintf (stream, "%d", best & 0xfffe); */
190 /* OBSOLETE break; */
191 /* OBSOLETE case 'd': */
192 /* OBSOLETE fprintf (stream, "%d", best & 0xfffc); */
193 /* OBSOLETE break; */
194 /* OBSOLETE case 'T': */
195 /* OBSOLETE fprintf (stream, "%d", (best >> 8) & 0xff); */
196 /* OBSOLETE break; */
197 /* OBSOLETE case 'N': */
198 /* OBSOLETE fprintf (stream, "%d", best & 0xff); */
199 /* OBSOLETE break; */
200 /* OBSOLETE default: */
201 /* OBSOLETE putc (*d, stream); */
202 /* OBSOLETE break; */
206 /* OBSOLETE /* Return length of instruction *x/ */
207 /* OBSOLETE return (gld_opcodes[index].length); */
211 /* OBSOLETE * Find the number of arguments to a function. */
213 /* OBSOLETE findarg(frame) */
214 /* OBSOLETE struct frame_info *frame; */
216 /* OBSOLETE register struct symbol *func; */
217 /* OBSOLETE register unsigned pc; */
219 /* OBSOLETE #ifdef notdef */
220 /* OBSOLETE /* find starting address of frame function *x/ */
221 /* OBSOLETE pc = get_pc_function_start (frame->pc); */
223 /* OBSOLETE /* find function symbol info *x/ */
224 /* OBSOLETE func = find_pc_function (pc); */
226 /* OBSOLETE /* call blockframe code to look for match *x/ */
227 /* OBSOLETE if (func != NULL) */
228 /* OBSOLETE return (func->value.block->nsyms / sizeof(int)); */
229 /* OBSOLETE #endif */
231 /* OBSOLETE return (-1); */
235 /* OBSOLETE * In the case of the NPL, the frame's norminal address is Br2 and the */
236 /* OBSOLETE * previous routines frame is up the stack X bytes. Finding out what */
237 /* OBSOLETE * 'X' is can be tricky. */
239 /* OBSOLETE * 1.) stored in the code function header xA(Br1). */
240 /* OBSOLETE * 2.) must be careful of recurssion. */
242 /* OBSOLETE CORE_ADDR */
243 /* OBSOLETE findframe(thisframe) */
244 /* OBSOLETE struct frame_info *thisframe; */
246 /* OBSOLETE register CORE_ADDR pointer; */
247 /* OBSOLETE CORE_ADDR framechain(); */
249 /* OBSOLETE struct frame_info *frame; */
251 /* OBSOLETE /* Setup toplevel frame structure *x/ */
252 /* OBSOLETE frame->pc = read_pc(); */
253 /* OBSOLETE frame->next_frame = 0; */
254 /* OBSOLETE frame->frame = read_register (SP_REGNUM); /* Br2 *x/ */
256 /* OBSOLETE /* Search for this frame (start at current Br2) *x/ */
259 /* OBSOLETE pointer = framechain(frame); */
260 /* OBSOLETE frame->next_frame = frame->frame; */
261 /* OBSOLETE frame->frame = pointer; */
262 /* OBSOLETE frame->pc = FRAME_SAVED_PC(frame); */
264 /* OBSOLETE while (frame->next_frame != thisframe); */
265 /* OBSOLETE #endif */
267 /* OBSOLETE pointer = framechain (thisframe); */
269 /* OBSOLETE /* stop gap for now, end at __base3 *x/ */
270 /* OBSOLETE if (thisframe->pc == 0) */
271 /* OBSOLETE return 0; */
273 /* OBSOLETE return pointer; */
277 /* OBSOLETE * Gdb front-end and internal framechain routine. */
278 /* OBSOLETE * Go back up stack one level. Tricky... */
280 /* OBSOLETE CORE_ADDR */
281 /* OBSOLETE framechain(frame) */
282 /* OBSOLETE register struct frame_info *frame; */
284 /* OBSOLETE register CORE_ADDR func, prevsp; */
285 /* OBSOLETE register unsigned value; */
287 /* OBSOLETE /* Get real function start address from internal frame address *x/ */
288 /* OBSOLETE func = get_pc_function_start(frame->pc); */
290 /* OBSOLETE /* If no stack given, read register Br1 "(sp)" *x/ */
291 /* OBSOLETE if (!frame->frame) */
292 /* OBSOLETE prevsp = read_register (SP_REGNUM); */
294 /* OBSOLETE prevsp = frame->frame; */
296 /* OBSOLETE /* Check function header, case #2 *x/ */
297 /* OBSOLETE value = read_memory_integer (func, 4); */
298 /* OBSOLETE if (value) */
300 /* OBSOLETE /* 32bit call push value stored in function header *x/ */
301 /* OBSOLETE prevsp += value; */
305 /* OBSOLETE /* read half-word from suabr at start of function *x/ */
306 /* OBSOLETE prevsp += read_memory_integer (func + 10, 2); */
309 /* OBSOLETE return (prevsp); */
This page took 0.036342 seconds and 5 git commands to generate.