Commit | Line | Data |
---|---|---|
93d5585d | 1 | /* Target dependent code for the NS32000, for GDB. |
464e0365 AC |
2 | |
3 | Copyright 1986, 1988, 1991, 1992, 1994, 1995, 1998, 1999, 2000, | |
4 | 2001, 2002, 2003, 2004 Free Software Foundation, Inc. | |
c906108c | 5 | |
c5aa993b | 6 | This file is part of GDB. |
c906108c | 7 | |
c5aa993b JM |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
c906108c | 12 | |
c5aa993b JM |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
c906108c | 17 | |
c5aa993b JM |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |
21 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
22 | |
23 | #include "defs.h" | |
f6427ade | 24 | #include "frame.h" |
93d5585d | 25 | #include "gdbtypes.h" |
381bab78 | 26 | #include "gdbcore.h" |
93d5585d JT |
27 | #include "inferior.h" |
28 | #include "regcache.h" | |
29 | #include "target.h" | |
93d5585d | 30 | #include "arch-utils.h" |
4be87837 | 31 | #include "osabi.h" |
a89aa300 | 32 | #include "dis-asm.h" |
93d5585d JT |
33 | |
34 | #include "ns32k-tdep.h" | |
9bbe19fb | 35 | #include "gdb_string.h" |
381bab78 AC |
36 | |
37 | static int sign_extend (int value, int bits); | |
78f9d765 JT |
38 | static CORE_ADDR ns32k_get_enter_addr (CORE_ADDR); |
39 | static int ns32k_localcount (CORE_ADDR enter_pc); | |
7bcc927b | 40 | static void flip_bytes (void *, int); |
c906108c | 41 | |
fa88f677 | 42 | static const char * |
af137673 | 43 | ns32k_register_name_32082 (int regno) |
c906108c | 44 | { |
af137673 JT |
45 | static char *register_names[] = |
46 | { | |
47 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
48 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", | |
49 | "sp", "fp", "pc", "ps", | |
50 | "l0", "l1", "l2", "l3", "xx", | |
51 | }; | |
52 | ||
53 | if (regno < 0) | |
54 | return NULL; | |
55 | if (regno >= sizeof (register_names) / sizeof (*register_names)) | |
56 | return NULL; | |
57 | ||
58 | return (register_names[regno]); | |
59 | } | |
60 | ||
fa88f677 | 61 | static const char * |
af137673 JT |
62 | ns32k_register_name_32382 (int regno) |
63 | { | |
64 | static char *register_names[] = | |
65 | { | |
66 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
67 | "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", | |
68 | "sp", "fp", "pc", "ps", | |
69 | "fsr", | |
70 | "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", "xx", | |
71 | }; | |
72 | ||
73 | if (regno < 0) | |
74 | return NULL; | |
75 | if (regno >= sizeof (register_names) / sizeof (*register_names)) | |
76 | return NULL; | |
77 | ||
78 | return (register_names[regno]); | |
c906108c | 79 | } |
b83266a0 | 80 | |
93d5585d | 81 | static int |
f2c762e0 JT |
82 | ns32k_register_byte_32082 (int regno) |
83 | { | |
93d5585d JT |
84 | if (regno >= NS32K_LP0_REGNUM) |
85 | return (NS32K_LP0_REGNUM * 4) + ((regno - NS32K_LP0_REGNUM) * 8); | |
f2c762e0 JT |
86 | |
87 | return (regno * 4); | |
88 | } | |
89 | ||
93d5585d | 90 | static int |
f2c762e0 JT |
91 | ns32k_register_byte_32382 (int regno) |
92 | { | |
93 | /* This is a bit yuk. The even numbered double precision floating | |
94 | point long registers occupy the same space as the even:odd numbered | |
95 | single precision floating point registers, but the extra 32381 FPU | |
96 | registers are at the end. Doing it this way is compatible for both | |
97 | 32081 and 32381 equipped machines. */ | |
98 | ||
93d5585d JT |
99 | return ((regno < NS32K_LP0_REGNUM ? regno |
100 | : (regno - NS32K_LP0_REGNUM) & 1 ? regno - 1 | |
101 | : (regno - NS32K_LP0_REGNUM + FP0_REGNUM)) * 4); | |
f2c762e0 JT |
102 | } |
103 | ||
93d5585d | 104 | static int |
f2c762e0 JT |
105 | ns32k_register_raw_size (int regno) |
106 | { | |
107 | /* All registers are 4 bytes, except for the doubled floating | |
108 | registers. */ | |
109 | ||
93d5585d | 110 | return ((regno >= NS32K_LP0_REGNUM) ? 8 : 4); |
f2c762e0 JT |
111 | } |
112 | ||
93d5585d | 113 | static int |
f2c762e0 JT |
114 | ns32k_register_virtual_size (int regno) |
115 | { | |
93d5585d | 116 | return ((regno >= NS32K_LP0_REGNUM) ? 8 : 4); |
f2c762e0 JT |
117 | } |
118 | ||
93d5585d | 119 | static struct type * |
f2c762e0 JT |
120 | ns32k_register_virtual_type (int regno) |
121 | { | |
122 | if (regno < FP0_REGNUM) | |
123 | return (builtin_type_int); | |
124 | ||
125 | if (regno < FP0_REGNUM + 8) | |
126 | return (builtin_type_float); | |
127 | ||
93d5585d | 128 | if (regno < NS32K_LP0_REGNUM) |
f2c762e0 JT |
129 | return (builtin_type_int); |
130 | ||
131 | return (builtin_type_double); | |
132 | } | |
133 | ||
efb2c70e JT |
134 | /* Immediately after a function call, return the saved PC. Can't |
135 | always go through the frames for this because on some systems, | |
136 | the new frame is not set up until the new function executes some | |
137 | instructions. */ | |
138 | ||
93d5585d | 139 | static CORE_ADDR |
efb2c70e JT |
140 | ns32k_saved_pc_after_call (struct frame_info *frame) |
141 | { | |
142 | return (read_memory_integer (read_register (SP_REGNUM), 4)); | |
143 | } | |
144 | ||
b83266a0 SS |
145 | /* Advance PC across any function entry prologue instructions |
146 | to reach some "real" code. */ | |
147 | ||
93d5585d | 148 | static CORE_ADDR |
fba45db2 | 149 | umax_skip_prologue (CORE_ADDR pc) |
b83266a0 | 150 | { |
52f0bd74 | 151 | unsigned char op = read_memory_integer (pc, 1); |
b83266a0 SS |
152 | if (op == 0x82) |
153 | { | |
c5aa993b | 154 | op = read_memory_integer (pc + 2, 1); |
b83266a0 SS |
155 | if ((op & 0x80) == 0) |
156 | pc += 3; | |
157 | else if ((op & 0xc0) == 0x80) | |
158 | pc += 4; | |
159 | else | |
160 | pc += 6; | |
c5aa993b | 161 | } |
b83266a0 SS |
162 | return pc; |
163 | } | |
78f9d765 | 164 | \f |
93d5585d | 165 | static const unsigned char * |
78f9d765 JT |
166 | ns32k_breakpoint_from_pc (CORE_ADDR *pcp, int *lenp) |
167 | { | |
168 | static const unsigned char breakpoint_insn[] = { 0xf2 }; | |
169 | ||
170 | *lenp = sizeof (breakpoint_insn); | |
171 | return breakpoint_insn; | |
172 | } | |
b83266a0 | 173 | |
cce74817 JM |
174 | /* Return number of args passed to a frame. |
175 | Can return -1, meaning no way to tell. | |
176 | Encore's C compiler often reuses same area on stack for args, | |
177 | so this will often not work properly. If the arg names | |
178 | are known, it's likely most of them will be printed. */ | |
bb19ff3b | 179 | |
93d5585d | 180 | static int |
fba45db2 | 181 | umax_frame_num_args (struct frame_info *fi) |
392a587b JM |
182 | { |
183 | int numargs; | |
184 | CORE_ADDR pc; | |
185 | CORE_ADDR enter_addr; | |
186 | unsigned int insn; | |
187 | unsigned int addr_mode; | |
188 | int width; | |
189 | ||
190 | numargs = -1; | |
50abf9e5 | 191 | enter_addr = ns32k_get_enter_addr (get_frame_pc (fi)); |
392a587b JM |
192 | if (enter_addr > 0) |
193 | { | |
194 | pc = ((enter_addr == 1) | |
6913c89a | 195 | ? DEPRECATED_SAVED_PC_AFTER_CALL (fi) |
8bedc050 | 196 | : DEPRECATED_FRAME_SAVED_PC (fi)); |
c5aa993b | 197 | insn = read_memory_integer (pc, 2); |
392a587b JM |
198 | addr_mode = (insn >> 11) & 0x1f; |
199 | insn = insn & 0x7ff; | |
200 | if ((insn & 0x7fc) == 0x57c | |
c5aa993b | 201 | && addr_mode == 0x14) /* immediate */ |
392a587b | 202 | { |
c5aa993b | 203 | if (insn == 0x57c) /* adjspb */ |
392a587b | 204 | width = 1; |
c5aa993b | 205 | else if (insn == 0x57d) /* adjspw */ |
392a587b | 206 | width = 2; |
c5aa993b | 207 | else if (insn == 0x57f) /* adjspd */ |
392a587b | 208 | width = 4; |
381bab78 AC |
209 | else |
210 | internal_error (__FILE__, __LINE__, "bad else"); | |
c5aa993b | 211 | numargs = read_memory_integer (pc + 2, width); |
392a587b JM |
212 | if (width > 1) |
213 | flip_bytes (&numargs, width); | |
c5aa993b | 214 | numargs = -sign_extend (numargs, width * 8) / 4; |
392a587b JM |
215 | } |
216 | } | |
217 | return numargs; | |
218 | } | |
b83266a0 | 219 | |
381bab78 | 220 | static int |
fba45db2 | 221 | sign_extend (int value, int bits) |
c906108c SS |
222 | { |
223 | value = value & ((1 << bits) - 1); | |
c5aa993b | 224 | return (value & (1 << (bits - 1)) |
c906108c SS |
225 | ? value | (~((1 << bits) - 1)) |
226 | : value); | |
227 | } | |
228 | ||
7bcc927b | 229 | static void |
381bab78 | 230 | flip_bytes (void *p, int count) |
c906108c SS |
231 | { |
232 | char tmp; | |
381bab78 | 233 | char *ptr = 0; |
c906108c SS |
234 | |
235 | while (count > 0) | |
236 | { | |
237 | tmp = *ptr; | |
c5aa993b JM |
238 | ptr[0] = ptr[count - 1]; |
239 | ptr[count - 1] = tmp; | |
c906108c SS |
240 | ptr++; |
241 | count -= 2; | |
242 | } | |
243 | } | |
244 | ||
78f9d765 JT |
245 | /* Return the number of locals in the current frame given a |
246 | pc pointing to the enter instruction. This is used by | |
247 | ns32k_frame_init_saved_regs. */ | |
c906108c | 248 | |
78f9d765 | 249 | static int |
fba45db2 | 250 | ns32k_localcount (CORE_ADDR enter_pc) |
c906108c SS |
251 | { |
252 | unsigned char localtype; | |
253 | int localcount; | |
254 | ||
c5aa993b | 255 | localtype = read_memory_integer (enter_pc + 2, 1); |
c906108c SS |
256 | if ((localtype & 0x80) == 0) |
257 | localcount = localtype; | |
258 | else if ((localtype & 0xc0) == 0x80) | |
259 | localcount = (((localtype & 0x3f) << 8) | |
c5aa993b | 260 | | (read_memory_integer (enter_pc + 3, 1) & 0xff)); |
c906108c SS |
261 | else |
262 | localcount = (((localtype & 0x3f) << 24) | |
c5aa993b JM |
263 | | ((read_memory_integer (enter_pc + 3, 1) & 0xff) << 16) |
264 | | ((read_memory_integer (enter_pc + 4, 1) & 0xff) << 8) | |
265 | | (read_memory_integer (enter_pc + 5, 1) & 0xff)); | |
c906108c SS |
266 | return localcount; |
267 | } | |
268 | ||
269 | ||
270 | /* Nonzero if instruction at PC is a return instruction. */ | |
271 | ||
272 | static int | |
fba45db2 | 273 | ns32k_about_to_return (CORE_ADDR pc) |
c906108c SS |
274 | { |
275 | return (read_memory_integer (pc, 1) == 0x12); | |
276 | } | |
277 | ||
78f9d765 JT |
278 | /* Get the address of the enter opcode for this function, if it is active. |
279 | Returns positive address > 1 if pc is between enter/exit, | |
280 | 1 if pc before enter or after exit, 0 otherwise. */ | |
281 | static CORE_ADDR | |
fba45db2 | 282 | ns32k_get_enter_addr (CORE_ADDR pc) |
c906108c SS |
283 | { |
284 | CORE_ADDR enter_addr; | |
285 | unsigned char op; | |
286 | ||
287 | if (pc == 0) | |
288 | return 0; | |
289 | ||
290 | if (ns32k_about_to_return (pc)) | |
c5aa993b | 291 | return 1; /* after exit */ |
c906108c SS |
292 | |
293 | enter_addr = get_pc_function_start (pc); | |
294 | ||
c5aa993b JM |
295 | if (pc == enter_addr) |
296 | return 1; /* before enter */ | |
c906108c SS |
297 | |
298 | op = read_memory_integer (enter_addr, 1); | |
299 | ||
300 | if (op != 0x82) | |
c5aa993b | 301 | return 0; /* function has no enter/exit */ |
c906108c | 302 | |
c5aa993b | 303 | return enter_addr; /* pc is between enter and exit */ |
c906108c | 304 | } |
af137673 | 305 | |
93d5585d | 306 | static CORE_ADDR |
78f9d765 JT |
307 | ns32k_frame_chain (struct frame_info *frame) |
308 | { | |
309 | /* In the case of the NS32000 series, the frame's nominal address is the | |
310 | FP value, and that address is saved at the previous FP value as a | |
311 | 4-byte word. */ | |
312 | ||
627b3ba2 | 313 | if (deprecated_inside_entry_file (get_frame_pc (frame))) |
78f9d765 JT |
314 | return 0; |
315 | ||
1e2330ba | 316 | return (read_memory_integer (get_frame_base (frame), 4)); |
78f9d765 JT |
317 | } |
318 | ||
f407986f AC |
319 | |
320 | static CORE_ADDR | |
321 | ns32k_sigtramp_saved_pc (struct frame_info *frame) | |
322 | { | |
323 | CORE_ADDR sigcontext_addr; | |
324 | char *buf; | |
325 | int ptrbytes = TYPE_LENGTH (builtin_type_void_func_ptr); | |
326 | int sigcontext_offs = (2 * TARGET_INT_BIT) / TARGET_CHAR_BIT; | |
327 | ||
328 | buf = alloca (ptrbytes); | |
329 | /* Get sigcontext address, it is the third parameter on the stack. */ | |
11c02a10 | 330 | if (get_next_frame (frame)) |
f407986f | 331 | sigcontext_addr = read_memory_typed_address |
42efa47a | 332 | (DEPRECATED_FRAME_ARGS_ADDRESS (get_next_frame (frame)) + FRAME_ARGS_SKIP + sigcontext_offs, |
f407986f AC |
333 | builtin_type_void_data_ptr); |
334 | else | |
335 | sigcontext_addr = read_memory_typed_address | |
336 | (read_register (SP_REGNUM) + sigcontext_offs, builtin_type_void_data_ptr); | |
337 | ||
338 | /* Don't cause a memory_error when accessing sigcontext in case the stack | |
339 | layout has changed or the stack is corrupt. */ | |
340 | target_read_memory (sigcontext_addr + SIGCONTEXT_PC_OFFSET, buf, ptrbytes); | |
341 | return extract_typed_address (buf, builtin_type_void_func_ptr); | |
342 | } | |
343 | ||
93d5585d | 344 | static CORE_ADDR |
78f9d765 JT |
345 | ns32k_frame_saved_pc (struct frame_info *frame) |
346 | { | |
5a203e44 | 347 | if ((get_frame_type (frame) == SIGTRAMP_FRAME)) |
f407986f | 348 | return (ns32k_sigtramp_saved_pc (frame)); /* XXXJRT */ |
78f9d765 | 349 | |
1e2330ba | 350 | return (read_memory_integer (get_frame_base (frame) + 4, 4)); |
78f9d765 JT |
351 | } |
352 | ||
93d5585d | 353 | static CORE_ADDR |
78f9d765 JT |
354 | ns32k_frame_args_address (struct frame_info *frame) |
355 | { | |
50abf9e5 | 356 | if (ns32k_get_enter_addr (get_frame_pc (frame)) > 1) |
1e2330ba | 357 | return (get_frame_base (frame)); |
78f9d765 JT |
358 | |
359 | return (read_register (SP_REGNUM) - 4); | |
360 | } | |
361 | ||
78f9d765 JT |
362 | /* Code to initialize the addresses of the saved registers of frame described |
363 | by FRAME_INFO. This includes special registers such as pc and fp saved in | |
364 | special ways in the stack frame. sp is even more special: the address we | |
365 | return for it IS the sp for the next frame. */ | |
366 | ||
93d5585d | 367 | static void |
78f9d765 JT |
368 | ns32k_frame_init_saved_regs (struct frame_info *frame) |
369 | { | |
370 | int regmask, regnum; | |
371 | int localcount; | |
372 | CORE_ADDR enter_addr, next_addr; | |
373 | ||
1b1d3794 | 374 | if (deprecated_get_frame_saved_regs (frame)) |
78f9d765 JT |
375 | return; |
376 | ||
377 | frame_saved_regs_zalloc (frame); | |
378 | ||
50abf9e5 | 379 | enter_addr = ns32k_get_enter_addr (get_frame_pc (frame)); |
78f9d765 JT |
380 | if (enter_addr > 1) |
381 | { | |
382 | regmask = read_memory_integer (enter_addr + 1, 1) & 0xff; | |
383 | localcount = ns32k_localcount (enter_addr); | |
1e2330ba | 384 | next_addr = get_frame_base (frame) + localcount; |
78f9d765 JT |
385 | |
386 | for (regnum = 0; regnum < 8; regnum++) | |
387 | { | |
388 | if (regmask & (1 << regnum)) | |
1b1d3794 | 389 | deprecated_get_frame_saved_regs (frame)[regnum] = next_addr -= 4; |
78f9d765 JT |
390 | } |
391 | ||
1b1d3794 AC |
392 | deprecated_get_frame_saved_regs (frame)[SP_REGNUM] = get_frame_base (frame) + 4; |
393 | deprecated_get_frame_saved_regs (frame)[PC_REGNUM] = get_frame_base (frame) + 4; | |
394 | deprecated_get_frame_saved_regs (frame)[DEPRECATED_FP_REGNUM] = read_memory_integer (get_frame_base (frame), 4); | |
78f9d765 JT |
395 | } |
396 | else if (enter_addr == 1) | |
397 | { | |
398 | CORE_ADDR sp = read_register (SP_REGNUM); | |
1b1d3794 AC |
399 | deprecated_get_frame_saved_regs (frame)[PC_REGNUM] = sp; |
400 | deprecated_get_frame_saved_regs (frame)[SP_REGNUM] = sp + 4; | |
78f9d765 JT |
401 | } |
402 | } | |
403 | ||
93d5585d | 404 | static void |
78f9d765 JT |
405 | ns32k_push_dummy_frame (void) |
406 | { | |
407 | CORE_ADDR sp = read_register (SP_REGNUM); | |
408 | int regnum; | |
409 | ||
410 | sp = push_word (sp, read_register (PC_REGNUM)); | |
0ba6dca9 AC |
411 | sp = push_word (sp, read_register (DEPRECATED_FP_REGNUM)); |
412 | write_register (DEPRECATED_FP_REGNUM, sp); | |
78f9d765 JT |
413 | |
414 | for (regnum = 0; regnum < 8; regnum++) | |
415 | sp = push_word (sp, read_register (regnum)); | |
416 | ||
417 | write_register (SP_REGNUM, sp); | |
418 | } | |
419 | ||
93d5585d | 420 | static void |
78f9d765 JT |
421 | ns32k_pop_frame (void) |
422 | { | |
423 | struct frame_info *frame = get_current_frame (); | |
424 | CORE_ADDR fp; | |
425 | int regnum; | |
426 | ||
1e2330ba | 427 | fp = get_frame_base (frame); |
f30ee0bc | 428 | DEPRECATED_FRAME_INIT_SAVED_REGS (frame); |
78f9d765 JT |
429 | |
430 | for (regnum = 0; regnum < 8; regnum++) | |
1b1d3794 | 431 | if (deprecated_get_frame_saved_regs (frame)[regnum]) |
78f9d765 | 432 | write_register (regnum, |
1b1d3794 | 433 | read_memory_integer (deprecated_get_frame_saved_regs (frame)[regnum], 4)); |
78f9d765 | 434 | |
0ba6dca9 | 435 | write_register (DEPRECATED_FP_REGNUM, read_memory_integer (fp, 4)); |
78f9d765 JT |
436 | write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); |
437 | write_register (SP_REGNUM, fp + 8); | |
438 | flush_cached_frames (); | |
439 | } | |
7bcc927b JT |
440 | \f |
441 | /* The NS32000 call dummy sequence: | |
442 | ||
443 | enter 0xff,0 82 ff 00 | |
444 | jsr @0x00010203 7f ae c0 01 02 03 | |
445 | adjspd 0x69696969 7f a5 01 02 03 04 | |
446 | bpt f2 | |
447 | ||
448 | It is 16 bytes long. */ | |
449 | ||
93d5585d | 450 | static LONGEST ns32k_call_dummy_words[] = |
7bcc927b JT |
451 | { |
452 | 0x7f00ff82, | |
453 | 0x0201c0ae, | |
454 | 0x01a57f03, | |
455 | 0xf2040302 | |
456 | }; | |
93d5585d | 457 | static int sizeof_ns32k_call_dummy_words = sizeof (ns32k_call_dummy_words); |
7bcc927b JT |
458 | |
459 | #define NS32K_CALL_DUMMY_ADDR 5 | |
460 | #define NS32K_CALL_DUMMY_NARGS 11 | |
78f9d765 | 461 | |
93d5585d | 462 | static void |
7bcc927b JT |
463 | ns32k_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, |
464 | struct value **args, struct type *type, int gcc_p) | |
465 | { | |
466 | int flipped; | |
467 | ||
468 | flipped = fun | 0xc0000000; | |
469 | flip_bytes (&flipped, 4); | |
470 | store_unsigned_integer (dummy + NS32K_CALL_DUMMY_ADDR, 4, flipped); | |
471 | ||
472 | flipped = - nargs * 4; | |
473 | flip_bytes (&flipped, 4); | |
474 | store_unsigned_integer (dummy + NS32K_CALL_DUMMY_NARGS, 4, flipped); | |
475 | } | |
476 | \f | |
93d5585d | 477 | static void |
efb2c70e JT |
478 | ns32k_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) |
479 | { | |
480 | /* On this machine, this is a no-op (Encore Umax didn't use GCC). */ | |
481 | } | |
482 | ||
93d5585d | 483 | static void |
efb2c70e JT |
484 | ns32k_extract_return_value (struct type *valtype, char *regbuf, char *valbuf) |
485 | { | |
486 | memcpy (valbuf, | |
62700349 | 487 | regbuf + DEPRECATED_REGISTER_BYTE (TYPE_CODE (valtype) == TYPE_CODE_FLT ? |
efb2c70e JT |
488 | FP0_REGNUM : 0), TYPE_LENGTH (valtype)); |
489 | } | |
490 | ||
93d5585d | 491 | static void |
efb2c70e JT |
492 | ns32k_store_return_value (struct type *valtype, char *valbuf) |
493 | { | |
73937e03 AC |
494 | deprecated_write_register_bytes (TYPE_CODE (valtype) == TYPE_CODE_FLT |
495 | ? FP0_REGNUM : 0, valbuf, | |
496 | TYPE_LENGTH (valtype)); | |
efb2c70e JT |
497 | } |
498 | ||
93d5585d JT |
499 | void |
500 | ns32k_gdbarch_init_32082 (struct gdbarch *gdbarch) | |
501 | { | |
502 | set_gdbarch_num_regs (gdbarch, NS32K_NUM_REGS_32082); | |
503 | ||
504 | set_gdbarch_register_name (gdbarch, ns32k_register_name_32082); | |
b8b527c5 | 505 | set_gdbarch_deprecated_register_bytes (gdbarch, NS32K_REGISTER_BYTES_32082); |
9c04cab7 | 506 | set_gdbarch_deprecated_register_byte (gdbarch, ns32k_register_byte_32082); |
93d5585d JT |
507 | } |
508 | ||
509 | void | |
510 | ns32k_gdbarch_init_32382 (struct gdbarch *gdbarch) | |
511 | { | |
512 | set_gdbarch_num_regs (gdbarch, NS32K_NUM_REGS_32382); | |
513 | ||
514 | set_gdbarch_register_name (gdbarch, ns32k_register_name_32382); | |
b8b527c5 | 515 | set_gdbarch_deprecated_register_bytes (gdbarch, NS32K_REGISTER_BYTES_32382); |
9c04cab7 | 516 | set_gdbarch_deprecated_register_byte (gdbarch, ns32k_register_byte_32382); |
93d5585d JT |
517 | } |
518 | ||
519 | /* Initialize the current architecture based on INFO. If possible, re-use an | |
520 | architecture from ARCHES, which is a list of architectures already created | |
521 | during this debugging session. | |
522 | ||
523 | Called e.g. at program startup, when reading a core file, and when reading | |
524 | a binary file. */ | |
525 | ||
526 | static struct gdbarch * | |
527 | ns32k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | |
528 | { | |
93d5585d | 529 | struct gdbarch *gdbarch; |
93d5585d | 530 | |
4be87837 DJ |
531 | /* If there is already a candidate, use it. */ |
532 | arches = gdbarch_list_lookup_by_info (arches, &info); | |
533 | if (arches != NULL) | |
534 | return arches->gdbarch; | |
93d5585d | 535 | |
4be87837 | 536 | gdbarch = gdbarch_alloc (&info, NULL); |
93d5585d | 537 | |
a5afb99f AC |
538 | /* NOTE: cagney/2002-12-06: This can be deleted when this arch is |
539 | ready to unwind the PC first (see frame.c:get_prev_frame()). */ | |
0968aa8c | 540 | set_gdbarch_deprecated_init_frame_pc (gdbarch, deprecated_init_frame_pc_default); |
a5afb99f | 541 | |
93d5585d JT |
542 | /* Register info */ |
543 | ns32k_gdbarch_init_32082 (gdbarch); | |
544 | set_gdbarch_num_regs (gdbarch, NS32K_SP_REGNUM); | |
545 | set_gdbarch_num_regs (gdbarch, NS32K_FP_REGNUM); | |
546 | set_gdbarch_num_regs (gdbarch, NS32K_PC_REGNUM); | |
547 | set_gdbarch_num_regs (gdbarch, NS32K_PS_REGNUM); | |
548 | ||
b1e29e33 | 549 | set_gdbarch_deprecated_register_size (gdbarch, NS32K_REGISTER_SIZE); |
9c04cab7 | 550 | set_gdbarch_deprecated_register_raw_size (gdbarch, ns32k_register_raw_size); |
a0ed5532 | 551 | set_gdbarch_deprecated_max_register_raw_size (gdbarch, NS32K_MAX_REGISTER_RAW_SIZE); |
9c04cab7 | 552 | set_gdbarch_deprecated_register_virtual_size (gdbarch, ns32k_register_virtual_size); |
a0ed5532 | 553 | set_gdbarch_deprecated_max_register_virtual_size (gdbarch, |
93d5585d | 554 | NS32K_MAX_REGISTER_VIRTUAL_SIZE); |
9c04cab7 | 555 | set_gdbarch_deprecated_register_virtual_type (gdbarch, ns32k_register_virtual_type); |
93d5585d JT |
556 | |
557 | /* Frame and stack info */ | |
558 | set_gdbarch_skip_prologue (gdbarch, umax_skip_prologue); | |
6913c89a | 559 | set_gdbarch_deprecated_saved_pc_after_call (gdbarch, ns32k_saved_pc_after_call); |
93d5585d JT |
560 | |
561 | set_gdbarch_frame_num_args (gdbarch, umax_frame_num_args); | |
562 | set_gdbarch_frameless_function_invocation (gdbarch, | |
563 | generic_frameless_function_invocation_not); | |
564 | ||
618ce49f | 565 | set_gdbarch_deprecated_frame_chain (gdbarch, ns32k_frame_chain); |
8bedc050 | 566 | set_gdbarch_deprecated_frame_saved_pc (gdbarch, ns32k_frame_saved_pc); |
93d5585d | 567 | |
42efa47a | 568 | set_gdbarch_deprecated_frame_args_address (gdbarch, ns32k_frame_args_address); |
93d5585d | 569 | |
f30ee0bc | 570 | set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, ns32k_frame_init_saved_regs); |
93d5585d JT |
571 | |
572 | set_gdbarch_frame_args_skip (gdbarch, 8); | |
573 | ||
93d5585d JT |
574 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); |
575 | ||
576 | /* Return value info */ | |
4183d812 | 577 | set_gdbarch_deprecated_store_struct_return (gdbarch, ns32k_store_struct_return); |
26e9b323 | 578 | set_gdbarch_deprecated_extract_return_value (gdbarch, ns32k_extract_return_value); |
ebba8386 | 579 | set_gdbarch_deprecated_store_return_value (gdbarch, ns32k_store_return_value); |
93d5585d JT |
580 | |
581 | /* Call dummy info */ | |
f3824013 | 582 | set_gdbarch_deprecated_push_dummy_frame (gdbarch, ns32k_push_dummy_frame); |
749b82f6 | 583 | set_gdbarch_deprecated_pop_frame (gdbarch, ns32k_pop_frame); |
93d5585d | 584 | set_gdbarch_call_dummy_location (gdbarch, ON_STACK); |
b1e29e33 AC |
585 | set_gdbarch_deprecated_call_dummy_words (gdbarch, ns32k_call_dummy_words); |
586 | set_gdbarch_deprecated_sizeof_call_dummy_words (gdbarch, sizeof_ns32k_call_dummy_words); | |
587 | set_gdbarch_deprecated_fix_call_dummy (gdbarch, ns32k_fix_call_dummy); | |
588 | set_gdbarch_deprecated_call_dummy_start_offset (gdbarch, 3); | |
589 | set_gdbarch_deprecated_call_dummy_breakpoint_offset (gdbarch, 15); | |
07555a72 | 590 | set_gdbarch_deprecated_use_generic_dummy_frames (gdbarch, 0); |
ae45cd16 | 591 | set_gdbarch_deprecated_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_on_stack); |
93d5585d JT |
592 | |
593 | /* Breakpoint info */ | |
93d5585d JT |
594 | set_gdbarch_breakpoint_from_pc (gdbarch, ns32k_breakpoint_from_pc); |
595 | ||
6c0e89ed | 596 | /* Should be using push_dummy_call. */ |
b46e02f6 | 597 | set_gdbarch_deprecated_dummy_write_sp (gdbarch, deprecated_write_sp); |
6c0e89ed | 598 | |
36482093 AC |
599 | set_gdbarch_print_insn (gdbarch, print_insn_ns32k); |
600 | ||
93d5585d | 601 | /* Hook in OS ABI-specific overrides, if they have been registered. */ |
4be87837 | 602 | gdbarch_init_osabi (info, gdbarch); |
93d5585d JT |
603 | |
604 | return (gdbarch); | |
605 | } | |
606 | ||
a78f21af AC |
607 | extern initialize_file_ftype _initialize_ns32k_tdep; /* -Wmissing-prototypes */ |
608 | ||
efb2c70e | 609 | void |
af137673 JT |
610 | _initialize_ns32k_tdep (void) |
611 | { | |
4be87837 | 612 | gdbarch_register (bfd_arch_ns32k, ns32k_gdbarch_init, NULL); |
93d5585d | 613 | |
af137673 | 614 | } |