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