1 /* GOULD RISC target-dependent code for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1989, 1991 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. */
25 #include "opcode/pn.h"
27 #include "opcode/np1.h"
30 /* GOULD RISC instructions are never longer than this many bytes. */
33 /* Number of elements in the opcode table. */
34 #define NOPCODES (sizeof gld_opcodes / sizeof gld_opcodes[0])
36 /* Both gcc and cc return small structs in registers (i.e. in GDB
37 terminology, small structs don't use the struct return convention). */
39 gould_use_struct_convention (gcc_p
, type
)
43 return (TYPE_LENGTH(type
) > 8);
48 /* Print the GOULD instruction at address MEMADDR in debugged memory,
49 on STREAM. Returns length of the instruction, in bytes. */
52 gould_print_insn (memaddr
, stream
)
56 unsigned char buffer
[MAXLEN
];
59 register int bestmask
;
61 int temp
, index
, bestlen
;
63 read_memory (memaddr
, buffer
, MAXLEN
);
68 for (i
= 0; i
< NOPCODES
; i
++)
70 register unsigned int opcode
= gld_opcodes
[i
].opcode
;
71 register unsigned int mask
= gld_opcodes
[i
].mask
;
72 register unsigned int len
= gld_opcodes
[i
].length
;
73 register unsigned int test
;
75 /* Get possible opcode bytes into integer */
76 test
= buffer
[0] << 24;
77 test
|= buffer
[1] << 16;
78 test
|= buffer
[2] << 8;
81 /* Mask with opcode and see if match */
82 if ((opcode
& mask
) == (test
& mask
))
84 /* See if second or third match */
87 /* Take new one if it looks good */
88 if (bestlen
== MAXLEN
&& len
== MAXLEN
)
90 /* See if lower bits matched */
91 if (((bestmask
& 3) == 0) &&
103 /* First match, save it */
112 /* Handle undefined instructions. */
115 fprintf (stream
, "undefined 0%o",(buffer
[0]<<8)+buffer
[1]);
119 /* Print instruction name */
120 fprintf (stream
, "%-12s", gld_opcodes
[index
].name
);
122 /* Adjust if short instruction */
123 if (gld_opcodes
[index
].length
< 4)
133 /* Dump out instruction arguments */
134 for (d
= gld_opcodes
[index
].args
; *d
; ++d
)
139 fprintf (stream
, "%d", (best
>> (7 + i
)) & 7);
142 fprintf (stream
, "r%d", (best
>> (7 + i
)) & 7);
145 fprintf (stream
, "r%d", (best
>> (4 + i
)) & 7);
148 fprintf (stream
, "b%d", (best
>> (7 + i
)) & 7);
151 fprintf (stream
, "b%d", (best
>> (4 + i
)) & 7);
154 fprintf (stream
, "b%d", (best
>> (7 + i
)) & 7);
157 fprintf (stream
, "b%d", (best
>> (4 + i
)) & 7);
160 temp
= (best
>> 20) & 7;
162 fprintf (stream
, "r%d", temp
);
167 temp
= (best
>> 16) & 7;
169 fprintf (stream
, "(b%d)", temp
);
172 fprintf (stream
, "#%d", best
& 0x1f);
175 fprintf (stream
, "#%x", best
& 0xffff);
178 fprintf (stream
, "%x", best
& 0xffff);
181 fprintf (stream
, "%d", best
& 0xfffe);
184 fprintf (stream
, "%d", best
& 0xfffc);
187 fprintf (stream
, "%d", (best
>> 8) & 0xff);
190 fprintf (stream
, "%d", best
& 0xff);
198 /* Return length of instruction */
199 return (gld_opcodes
[index
].length
);
203 * Find the number of arguments to a function.
206 struct frame_info
*frame
;
208 register struct symbol
*func
;
209 register unsigned pc
;
212 /* find starting address of frame function */
213 pc
= get_pc_function_start (frame
->pc
);
215 /* find function symbol info */
216 func
= find_pc_function (pc
);
218 /* call blockframe code to look for match */
220 return (func
->value
.block
->nsyms
/ sizeof(int));
227 * In the case of the NPL, the frame's norminal address is Br2 and the
228 * previous routines frame is up the stack X bytes. Finding out what
229 * 'X' is can be tricky.
231 * 1.) stored in the code function header xA(Br1).
232 * 2.) must be careful of recurssion.
236 struct frame_info
*thisframe
;
238 register CORE_ADDR pointer
;
239 CORE_ADDR
framechain();
241 struct frame_info
*frame
;
243 /* Setup toplevel frame structure */
244 frame
->pc
= read_pc();
245 frame
->next_frame
= 0;
246 frame
->frame
= read_register (SP_REGNUM
); /* Br2 */
248 /* Search for this frame (start at current Br2) */
251 pointer
= framechain(frame
);
252 frame
->next_frame
= frame
->frame
;
253 frame
->frame
= pointer
;
254 frame
->pc
= FRAME_SAVED_PC(frame
);
256 while (frame
->next_frame
!= thisframe
);
259 pointer
= framechain (thisframe
);
261 /* stop gap for now, end at __base3 */
262 if (thisframe
->pc
== 0)
269 * Gdb front-end and internal framechain routine.
270 * Go back up stack one level. Tricky...
274 register struct frame_info
*frame
;
276 register CORE_ADDR func
, prevsp
;
277 register unsigned value
;
279 /* Get real function start address from internal frame address */
280 func
= get_pc_function_start(frame
->pc
);
282 /* If no stack given, read register Br1 "(sp)" */
284 prevsp
= read_register (SP_REGNUM
);
286 prevsp
= frame
->frame
;
288 /* Check function header, case #2 */
289 value
= read_memory_integer (func
, 4);
292 /* 32bit call push value stored in function header */
297 /* read half-word from suabr at start of function */
298 prevsp
+= read_memory_integer (func
+ 10, 2);
This page took 0.047097 seconds and 4 git commands to generate.