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