]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Print VAX instructions for GDB, the GNU debugger. |
51eb8b08 | 2 | Copyright 1986, 1989, 1991, 1992, 1995, 1996, 1998, 1999, 2000, 2002 |
b6ba6518 | 3 | 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" | |
23 | #include "symtab.h" | |
24 | #include "opcode/vax.h" | |
c11c3a98 | 25 | #include "gdbcore.h" |
f267bd6a | 26 | #include "inferior.h" |
a33f7558 | 27 | #include "regcache.h" |
c11c3a98 AC |
28 | #include "frame.h" |
29 | #include "value.h" | |
f267bd6a JT |
30 | #include "arch-utils.h" |
31 | ||
32 | #include "vax-tdep.h" | |
33 | ||
34 | static gdbarch_register_name_ftype vax_register_name; | |
35 | static gdbarch_register_byte_ftype vax_register_byte; | |
36 | static gdbarch_register_raw_size_ftype vax_register_raw_size; | |
37 | static gdbarch_register_virtual_size_ftype vax_register_virtual_size; | |
38 | static gdbarch_register_virtual_type_ftype vax_register_virtual_type; | |
39 | ||
40 | static gdbarch_skip_prologue_ftype vax_skip_prologue; | |
41 | static gdbarch_saved_pc_after_call_ftype vax_saved_pc_after_call; | |
42 | static gdbarch_frame_num_args_ftype vax_frame_num_args; | |
43 | static gdbarch_frame_chain_ftype vax_frame_chain; | |
44 | static gdbarch_frame_saved_pc_ftype vax_frame_saved_pc; | |
45 | static gdbarch_frame_args_address_ftype vax_frame_args_address; | |
46 | static gdbarch_frame_locals_address_ftype vax_frame_locals_address; | |
47 | static gdbarch_frame_init_saved_regs_ftype vax_frame_init_saved_regs; | |
f267bd6a JT |
48 | |
49 | static gdbarch_store_struct_return_ftype vax_store_struct_return; | |
26e9b323 | 50 | static gdbarch_deprecated_extract_return_value_ftype vax_extract_return_value; |
26e9b323 | 51 | static gdbarch_deprecated_extract_struct_value_address_ftype |
f267bd6a JT |
52 | vax_extract_struct_value_address; |
53 | ||
54 | static gdbarch_push_dummy_frame_ftype vax_push_dummy_frame; | |
55 | static gdbarch_pop_frame_ftype vax_pop_frame; | |
56 | static gdbarch_fix_call_dummy_ftype vax_fix_call_dummy; | |
c906108c | 57 | |
75bc7ddf AC |
58 | /* Return 1 if P points to an invalid floating point value. |
59 | LEN is the length in bytes -- not relevant on the Vax. */ | |
60 | ||
61 | /* FIXME: cagney/2002-01-19: The macro below was originally defined in | |
62 | tm-vax.h and used in values.c. Two problems. Firstly this is a | |
63 | very non-portable and secondly it is wrong. The VAX should be | |
64 | using floatformat and associated methods to identify and handle | |
65 | invalid floating-point values. Adding to the poor target's woes | |
66 | there is no floatformat_vax_{f,d} and no TARGET_FLOAT_FORMAT | |
67 | et.al.. */ | |
68 | ||
69 | /* FIXME: cagney/2002-01-19: It turns out that the only thing that | |
70 | uses this macro is the vax disassembler code (so how old is this | |
71 | target?). This target should instead be using the opcodes | |
72 | disassembler. That allowing the macro to be eliminated. */ | |
73 | ||
74 | #define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) | |
75 | ||
c906108c SS |
76 | /* Vax instructions are never longer than this. */ |
77 | #define MAXLEN 62 | |
78 | ||
79 | /* Number of elements in the opcode table. */ | |
80 | #define NOPCODES (sizeof votstrs / sizeof votstrs[0]) | |
81 | ||
82 | static unsigned char *print_insn_arg (); | |
83 | \f | |
fa88f677 | 84 | static const char * |
51eb8b08 JT |
85 | vax_register_name (int regno) |
86 | { | |
87 | static char *register_names[] = | |
88 | { | |
89 | "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
90 | "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", | |
91 | "ps", | |
92 | }; | |
93 | ||
94 | if (regno < 0) | |
95 | return (NULL); | |
96 | if (regno >= (sizeof(register_names) / sizeof(*register_names))) | |
97 | return (NULL); | |
98 | return (register_names[regno]); | |
99 | } | |
100 | ||
f267bd6a | 101 | static int |
51eb8b08 JT |
102 | vax_register_byte (int regno) |
103 | { | |
104 | return (regno * 4); | |
105 | } | |
106 | ||
f267bd6a | 107 | static int |
51eb8b08 JT |
108 | vax_register_raw_size (int regno) |
109 | { | |
110 | return (4); | |
111 | } | |
112 | ||
f267bd6a | 113 | static int |
51eb8b08 JT |
114 | vax_register_virtual_size (int regno) |
115 | { | |
116 | return (4); | |
117 | } | |
118 | ||
f267bd6a | 119 | static struct type * |
51eb8b08 JT |
120 | vax_register_virtual_type (int regno) |
121 | { | |
122 | return (builtin_type_int); | |
123 | } | |
124 | \f | |
f267bd6a | 125 | static void |
ab62c900 JT |
126 | vax_frame_init_saved_regs (struct frame_info *frame) |
127 | { | |
128 | int regnum, regmask; | |
129 | CORE_ADDR next_addr; | |
130 | ||
131 | if (frame->saved_regs) | |
132 | return; | |
133 | ||
134 | frame_saved_regs_zalloc (frame); | |
135 | ||
136 | regmask = read_memory_integer (frame->frame + 4, 4) >> 16; | |
137 | ||
138 | next_addr = frame->frame + 16; | |
139 | ||
140 | /* regmask's low bit is for register 0, which is the first one | |
141 | what would be pushed. */ | |
1d049c5e | 142 | for (regnum = 0; regnum < VAX_AP_REGNUM; regnum++) |
ab62c900 JT |
143 | { |
144 | if (regmask & (1 << regnum)) | |
145 | frame->saved_regs[regnum] = next_addr += 4; | |
146 | } | |
147 | ||
148 | frame->saved_regs[SP_REGNUM] = next_addr + 4; | |
149 | if (regmask & (1 << FP_REGNUM)) | |
150 | frame->saved_regs[SP_REGNUM] += | |
151 | 4 + (4 * read_memory_integer (next_addr + 4, 4)); | |
152 | ||
153 | frame->saved_regs[PC_REGNUM] = frame->frame + 16; | |
154 | frame->saved_regs[FP_REGNUM] = frame->frame + 12; | |
1d049c5e | 155 | frame->saved_regs[VAX_AP_REGNUM] = frame->frame + 8; |
ab62c900 JT |
156 | frame->saved_regs[PS_REGNUM] = frame->frame + 4; |
157 | } | |
5516aa92 | 158 | |
f267bd6a | 159 | static CORE_ADDR |
5516aa92 JT |
160 | vax_frame_saved_pc (struct frame_info *frame) |
161 | { | |
162 | if (frame->signal_handler_caller) | |
163 | return (sigtramp_saved_pc (frame)); /* XXXJRT */ | |
164 | ||
165 | return (read_memory_integer (frame->frame + 16, 4)); | |
166 | } | |
167 | ||
168 | CORE_ADDR | |
169 | vax_frame_args_address_correct (struct frame_info *frame) | |
170 | { | |
171 | /* Cannot find the AP register value directly from the FP value. Must | |
172 | find it saved in the frame called by this one, or in the AP register | |
173 | for the innermost frame. However, there is no way to tell the | |
174 | difference between the innermost frame and a frame for which we | |
175 | just don't know the frame that it called (e.g. "info frame 0x7ffec789"). | |
176 | For the sake of argument, suppose that the stack is somewhat trashed | |
177 | (which is one reason that "info frame" exists). So, return 0 (indicating | |
178 | we don't know the address of the arglist) if we don't know what frame | |
179 | this frame calls. */ | |
180 | if (frame->next) | |
181 | return (read_memory_integer (frame->next->frame + 8, 4)); | |
182 | ||
183 | return (0); | |
184 | } | |
185 | ||
f267bd6a | 186 | static CORE_ADDR |
5516aa92 JT |
187 | vax_frame_args_address (struct frame_info *frame) |
188 | { | |
189 | /* In most of GDB, getting the args address is too important to | |
190 | just say "I don't know". This is sometimes wrong for functions | |
191 | that aren't on top of the stack, but c'est la vie. */ | |
192 | if (frame->next) | |
193 | return (read_memory_integer (frame->next->frame + 8, 4)); | |
194 | ||
1d049c5e | 195 | return (read_register (VAX_AP_REGNUM)); |
5516aa92 JT |
196 | } |
197 | ||
f267bd6a | 198 | static CORE_ADDR |
5516aa92 JT |
199 | vax_frame_locals_address (struct frame_info *frame) |
200 | { | |
201 | return (frame->frame); | |
202 | } | |
203 | ||
f267bd6a | 204 | static int |
5516aa92 JT |
205 | vax_frame_num_args (struct frame_info *fi) |
206 | { | |
207 | return (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1)); | |
208 | } | |
52efde73 | 209 | |
f267bd6a | 210 | static CORE_ADDR |
52efde73 JT |
211 | vax_frame_chain (struct frame_info *frame) |
212 | { | |
213 | /* In the case of the VAX, the frame's nominal address is the FP value, | |
214 | and 12 bytes later comes the saved previous FP value as a 4-byte word. */ | |
215 | if (inside_entry_file (frame->pc)) | |
216 | return (0); | |
217 | ||
218 | return (read_memory_integer (frame->frame + 12, 4)); | |
219 | } | |
220 | \f | |
f267bd6a | 221 | static void |
52efde73 JT |
222 | vax_push_dummy_frame (void) |
223 | { | |
224 | CORE_ADDR sp = read_register (SP_REGNUM); | |
225 | int regnum; | |
226 | ||
227 | sp = push_word (sp, 0); /* arglist */ | |
228 | for (regnum = 11; regnum >= 0; regnum--) | |
229 | sp = push_word (sp, read_register (regnum)); | |
230 | sp = push_word (sp, read_register (PC_REGNUM)); | |
231 | sp = push_word (sp, read_register (FP_REGNUM)); | |
1d049c5e | 232 | sp = push_word (sp, read_register (VAX_AP_REGNUM)); |
52efde73 JT |
233 | sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) + 0x2fff0000); |
234 | sp = push_word (sp, 0); | |
235 | write_register (SP_REGNUM, sp); | |
236 | write_register (FP_REGNUM, sp); | |
1d049c5e | 237 | write_register (VAX_AP_REGNUM, sp + (17 * 4)); |
52efde73 JT |
238 | } |
239 | ||
f267bd6a | 240 | static void |
52efde73 JT |
241 | vax_pop_frame (void) |
242 | { | |
243 | CORE_ADDR fp = read_register (FP_REGNUM); | |
244 | int regnum; | |
245 | int regmask = read_memory_integer (fp + 4, 4); | |
246 | ||
247 | write_register (PS_REGNUM, | |
248 | (regmask & 0xffff) | |
249 | | (read_register (PS_REGNUM) & 0xffff0000)); | |
250 | write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); | |
251 | write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); | |
1d049c5e | 252 | write_register (VAX_AP_REGNUM, read_memory_integer (fp + 8, 4)); |
52efde73 JT |
253 | fp += 16; |
254 | for (regnum = 0; regnum < 12; regnum++) | |
255 | if (regmask & (0x10000 << regnum)) | |
256 | write_register (regnum, read_memory_integer (fp += 4, 4)); | |
257 | fp = fp + 4 + ((regmask >> 30) & 3); | |
258 | if (regmask & 0x20000000) | |
259 | { | |
260 | regnum = read_memory_integer (fp, 4); | |
261 | fp += (regnum + 1) * 4; | |
262 | } | |
263 | write_register (SP_REGNUM, fp); | |
264 | flush_cached_frames (); | |
265 | } | |
a33f7558 JT |
266 | |
267 | /* The VAX call dummy sequence: | |
268 | ||
269 | calls #69, @#32323232 | |
270 | bpt | |
271 | ||
272 | It is 8 bytes long. The address and argc are patched by | |
273 | vax_fix_call_dummy(). */ | |
f267bd6a JT |
274 | static LONGEST vax_call_dummy_words[] = { 0x329f69fb, 0x03323232 }; |
275 | static int sizeof_vax_call_dummy_words = sizeof(vax_call_dummy_words); | |
a33f7558 | 276 | |
f267bd6a | 277 | static void |
a33f7558 JT |
278 | vax_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, |
279 | struct value **args, struct type *type, int gcc_p) | |
280 | { | |
281 | dummy[1] = nargs; | |
282 | store_unsigned_integer (dummy + 3, 4, fun); | |
283 | } | |
ab62c900 | 284 | \f |
f267bd6a | 285 | static void |
ea74468c JT |
286 | vax_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) |
287 | { | |
288 | write_register (1, addr); | |
289 | } | |
290 | ||
f267bd6a | 291 | static void |
ea74468c JT |
292 | vax_extract_return_value (struct type *valtype, char *regbuf, char *valbuf) |
293 | { | |
294 | memcpy (valbuf, regbuf + REGISTER_BYTE (0), TYPE_LENGTH (valtype)); | |
295 | } | |
296 | ||
f267bd6a | 297 | static void |
ea74468c JT |
298 | vax_store_return_value (struct type *valtype, char *valbuf) |
299 | { | |
300 | write_register_bytes (0, valbuf, TYPE_LENGTH (valtype)); | |
301 | } | |
302 | ||
f267bd6a | 303 | static CORE_ADDR |
ea74468c JT |
304 | vax_extract_struct_value_address (char *regbuf) |
305 | { | |
306 | return (extract_address (regbuf + REGISTER_BYTE (0), REGISTER_RAW_SIZE (0))); | |
307 | } | |
308 | \f | |
1d049c5e JT |
309 | static const unsigned char * |
310 | vax_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) | |
311 | { | |
312 | static const unsigned char vax_breakpoint[] = { 3 }; | |
313 | ||
314 | *lenptr = sizeof(vax_breakpoint); | |
315 | return (vax_breakpoint); | |
316 | } | |
317 | \f | |
b83266a0 SS |
318 | /* Advance PC across any function entry prologue instructions |
319 | to reach some "real" code. */ | |
320 | ||
f267bd6a | 321 | static CORE_ADDR |
fba45db2 | 322 | vax_skip_prologue (CORE_ADDR pc) |
b83266a0 SS |
323 | { |
324 | register int op = (unsigned char) read_memory_integer (pc, 1); | |
325 | if (op == 0x11) | |
c5aa993b | 326 | pc += 2; /* skip brb */ |
b83266a0 | 327 | if (op == 0x31) |
c5aa993b | 328 | pc += 3; /* skip brw */ |
b83266a0 | 329 | if (op == 0xC2 |
c5aa993b JM |
330 | && ((unsigned char) read_memory_integer (pc + 2, 1)) == 0x5E) |
331 | pc += 3; /* skip subl2 */ | |
b83266a0 | 332 | if (op == 0x9E |
c5aa993b JM |
333 | && ((unsigned char) read_memory_integer (pc + 1, 1)) == 0xAE |
334 | && ((unsigned char) read_memory_integer (pc + 3, 1)) == 0x5E) | |
335 | pc += 4; /* skip movab */ | |
b83266a0 | 336 | if (op == 0x9E |
c5aa993b JM |
337 | && ((unsigned char) read_memory_integer (pc + 1, 1)) == 0xCE |
338 | && ((unsigned char) read_memory_integer (pc + 4, 1)) == 0x5E) | |
339 | pc += 5; /* skip movab */ | |
b83266a0 | 340 | if (op == 0x9E |
c5aa993b JM |
341 | && ((unsigned char) read_memory_integer (pc + 1, 1)) == 0xEE |
342 | && ((unsigned char) read_memory_integer (pc + 6, 1)) == 0x5E) | |
343 | pc += 7; /* skip movab */ | |
b83266a0 SS |
344 | return pc; |
345 | } | |
346 | ||
f267bd6a | 347 | static CORE_ADDR |
a33f7558 JT |
348 | vax_saved_pc_after_call (struct frame_info *frame) |
349 | { | |
350 | return (FRAME_SAVED_PC(frame)); | |
351 | } | |
352 | \f | |
c906108c SS |
353 | /* Print the vax instruction at address MEMADDR in debugged memory, |
354 | from disassembler info INFO. | |
355 | Returns length of the instruction, in bytes. */ | |
356 | ||
357 | static int | |
fba45db2 | 358 | vax_print_insn (CORE_ADDR memaddr, disassemble_info *info) |
c906108c SS |
359 | { |
360 | unsigned char buffer[MAXLEN]; | |
361 | register int i; | |
362 | register unsigned char *p; | |
c11c3a98 | 363 | const char *d; |
c906108c SS |
364 | |
365 | int status = (*info->read_memory_func) (memaddr, buffer, MAXLEN, info); | |
366 | if (status != 0) | |
367 | { | |
368 | (*info->memory_error_func) (status, memaddr, info); | |
369 | return -1; | |
370 | } | |
371 | ||
372 | for (i = 0; i < NOPCODES; i++) | |
373 | if (votstrs[i].detail.code == buffer[0] | |
c5aa993b | 374 | || votstrs[i].detail.code == *(unsigned short *) buffer) |
c906108c SS |
375 | break; |
376 | ||
377 | /* Handle undefined instructions. */ | |
378 | if (i == NOPCODES) | |
379 | { | |
380 | (*info->fprintf_func) (info->stream, "0%o", buffer[0]); | |
381 | return 1; | |
382 | } | |
383 | ||
384 | (*info->fprintf_func) (info->stream, "%s", votstrs[i].name); | |
385 | ||
386 | /* Point at first byte of argument data, | |
387 | and at descriptor for first argument. */ | |
388 | p = buffer + 1 + (votstrs[i].detail.code >= 0x100); | |
389 | d = votstrs[i].detail.args; | |
390 | ||
391 | if (*d) | |
392 | (*info->fprintf_func) (info->stream, " "); | |
393 | ||
394 | while (*d) | |
395 | { | |
396 | p = print_insn_arg (d, p, memaddr + (p - buffer), info); | |
397 | d += 2; | |
398 | if (*d) | |
399 | (*info->fprintf_func) (info->stream, ","); | |
400 | } | |
401 | return p - buffer; | |
402 | } | |
f267bd6a | 403 | \f |
c906108c | 404 | static unsigned char * |
fba45db2 KB |
405 | print_insn_arg (char *d, register char *p, CORE_ADDR addr, |
406 | disassemble_info *info) | |
c906108c SS |
407 | { |
408 | register int regnum = *p & 0xf; | |
409 | float floatlitbuf; | |
410 | ||
411 | if (*d == 'b') | |
412 | { | |
413 | if (d[1] == 'b') | |
414 | (*info->fprintf_func) (info->stream, "0x%x", addr + *p++ + 1); | |
415 | else | |
416 | { | |
c5aa993b | 417 | (*info->fprintf_func) (info->stream, "0x%x", addr + *(short *) p + 2); |
c906108c SS |
418 | p += 2; |
419 | } | |
420 | } | |
421 | else | |
422 | switch ((*p++ >> 4) & 0xf) | |
423 | { | |
424 | case 0: | |
425 | case 1: | |
426 | case 2: | |
427 | case 3: /* Literal mode */ | |
428 | if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') | |
429 | { | |
c5aa993b | 430 | *(int *) &floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4); |
c906108c SS |
431 | (*info->fprintf_func) (info->stream, "$%f", floatlitbuf); |
432 | } | |
433 | else | |
434 | (*info->fprintf_func) (info->stream, "$%d", p[-1] & 0x3f); | |
435 | break; | |
436 | ||
437 | case 4: /* Indexed */ | |
438 | p = (char *) print_insn_arg (d, p, addr + 1, info); | |
439 | (*info->fprintf_func) (info->stream, "[%s]", REGISTER_NAME (regnum)); | |
440 | break; | |
441 | ||
442 | case 5: /* Register */ | |
443 | (*info->fprintf_func) (info->stream, REGISTER_NAME (regnum)); | |
444 | break; | |
445 | ||
446 | case 7: /* Autodecrement */ | |
447 | (*info->fprintf_func) (info->stream, "-"); | |
448 | case 6: /* Register deferred */ | |
449 | (*info->fprintf_func) (info->stream, "(%s)", REGISTER_NAME (regnum)); | |
450 | break; | |
451 | ||
452 | case 9: /* Autoincrement deferred */ | |
453 | (*info->fprintf_func) (info->stream, "@"); | |
454 | if (regnum == PC_REGNUM) | |
455 | { | |
456 | (*info->fprintf_func) (info->stream, "#"); | |
c5aa993b | 457 | info->target = *(long *) p; |
c906108c SS |
458 | (*info->print_address_func) (info->target, info); |
459 | p += 4; | |
460 | break; | |
461 | } | |
462 | case 8: /* Autoincrement */ | |
463 | if (regnum == PC_REGNUM) | |
464 | { | |
465 | (*info->fprintf_func) (info->stream, "#"); | |
466 | switch (d[1]) | |
467 | { | |
468 | case 'b': | |
469 | (*info->fprintf_func) (info->stream, "%d", *p++); | |
470 | break; | |
471 | ||
472 | case 'w': | |
c5aa993b | 473 | (*info->fprintf_func) (info->stream, "%d", *(short *) p); |
c906108c SS |
474 | p += 2; |
475 | break; | |
476 | ||
477 | case 'l': | |
c5aa993b | 478 | (*info->fprintf_func) (info->stream, "%d", *(long *) p); |
c906108c SS |
479 | p += 4; |
480 | break; | |
481 | ||
482 | case 'q': | |
483 | (*info->fprintf_func) (info->stream, "0x%x%08x", | |
c5aa993b | 484 | ((long *) p)[1], ((long *) p)[0]); |
c906108c SS |
485 | p += 8; |
486 | break; | |
487 | ||
488 | case 'o': | |
489 | (*info->fprintf_func) (info->stream, "0x%x%08x%08x%08x", | |
c5aa993b JM |
490 | ((long *) p)[3], ((long *) p)[2], |
491 | ((long *) p)[1], ((long *) p)[0]); | |
c906108c SS |
492 | p += 16; |
493 | break; | |
494 | ||
495 | case 'f': | |
496 | if (INVALID_FLOAT (p, 4)) | |
497 | (*info->fprintf_func) (info->stream, | |
498 | "<<invalid float 0x%x>>", | |
499 | *(int *) p); | |
500 | else | |
501 | (*info->fprintf_func) (info->stream, "%f", *(float *) p); | |
502 | p += 4; | |
503 | break; | |
504 | ||
505 | case 'd': | |
506 | if (INVALID_FLOAT (p, 8)) | |
507 | (*info->fprintf_func) (info->stream, | |
508 | "<<invalid float 0x%x%08x>>", | |
c5aa993b | 509 | ((long *) p)[1], ((long *) p)[0]); |
c906108c SS |
510 | else |
511 | (*info->fprintf_func) (info->stream, "%f", *(double *) p); | |
512 | p += 8; | |
513 | break; | |
514 | ||
515 | case 'g': | |
516 | (*info->fprintf_func) (info->stream, "g-float"); | |
517 | p += 8; | |
518 | break; | |
519 | ||
520 | case 'h': | |
521 | (*info->fprintf_func) (info->stream, "h-float"); | |
522 | p += 16; | |
523 | break; | |
524 | ||
525 | } | |
526 | } | |
527 | else | |
528 | (*info->fprintf_func) (info->stream, "(%s)+", REGISTER_NAME (regnum)); | |
529 | break; | |
530 | ||
531 | case 11: /* Byte displacement deferred */ | |
532 | (*info->fprintf_func) (info->stream, "@"); | |
533 | case 10: /* Byte displacement */ | |
534 | if (regnum == PC_REGNUM) | |
535 | { | |
536 | info->target = addr + *p + 2; | |
537 | (*info->print_address_func) (info->target, info); | |
538 | } | |
539 | else | |
540 | (*info->fprintf_func) (info->stream, "%d(%s)", *p, REGISTER_NAME (regnum)); | |
541 | p += 1; | |
542 | break; | |
543 | ||
544 | case 13: /* Word displacement deferred */ | |
545 | (*info->fprintf_func) (info->stream, "@"); | |
546 | case 12: /* Word displacement */ | |
547 | if (regnum == PC_REGNUM) | |
548 | { | |
c5aa993b | 549 | info->target = addr + *(short *) p + 3; |
c906108c SS |
550 | (*info->print_address_func) (info->target, info); |
551 | } | |
552 | else | |
553 | (*info->fprintf_func) (info->stream, "%d(%s)", | |
c5aa993b | 554 | *(short *) p, REGISTER_NAME (regnum)); |
c906108c SS |
555 | p += 2; |
556 | break; | |
557 | ||
558 | case 15: /* Long displacement deferred */ | |
559 | (*info->fprintf_func) (info->stream, "@"); | |
560 | case 14: /* Long displacement */ | |
561 | if (regnum == PC_REGNUM) | |
562 | { | |
c5aa993b | 563 | info->target = addr + *(short *) p + 5; |
c906108c SS |
564 | (*info->print_address_func) (info->target, info); |
565 | } | |
566 | else | |
567 | (*info->fprintf_func) (info->stream, "%d(%s)", | |
c5aa993b | 568 | *(long *) p, REGISTER_NAME (regnum)); |
c906108c SS |
569 | p += 4; |
570 | } | |
571 | ||
572 | return (unsigned char *) p; | |
573 | } | |
f267bd6a JT |
574 | \f |
575 | /* Initialize the current architecture based on INFO. If possible, re-use an | |
576 | architecture from ARCHES, which is a list of architectures already created | |
577 | during this debugging session. | |
578 | ||
579 | Called e.g. at program startup, when reading a core file, and when reading | |
580 | a binary file. */ | |
581 | ||
582 | static struct gdbarch * | |
583 | vax_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | |
584 | { | |
4791e091 | 585 | struct gdbarch_tdep *tdep; |
f267bd6a | 586 | struct gdbarch *gdbarch; |
4791e091 | 587 | enum gdb_osabi osabi = GDB_OSABI_UNKNOWN; |
f267bd6a | 588 | |
4791e091 | 589 | /* Try to determine the ABI of the object we are loading. */ |
f267bd6a | 590 | |
4791e091 JT |
591 | if (info.abfd != NULL) |
592 | osabi = gdbarch_lookup_osabi (info.abfd); | |
593 | ||
594 | /* Find a candidate among extant architectures. */ | |
595 | for (arches = gdbarch_list_lookup_by_info (arches, &info); | |
596 | arches != NULL; | |
597 | arches = gdbarch_list_lookup_by_info (arches->next, &info)) | |
598 | { | |
599 | /* Make sure the ABI selection matches. */ | |
600 | tdep = gdbarch_tdep (arches->gdbarch); | |
601 | if (tdep && tdep->osabi == osabi) | |
602 | return arches->gdbarch; | |
603 | } | |
604 | ||
605 | tdep = xmalloc (sizeof (struct gdbarch_tdep)); | |
606 | gdbarch = gdbarch_alloc (&info, tdep); | |
607 | ||
608 | tdep->osabi = osabi; | |
f267bd6a JT |
609 | |
610 | /* Register info */ | |
611 | set_gdbarch_num_regs (gdbarch, VAX_NUM_REGS); | |
612 | set_gdbarch_sp_regnum (gdbarch, VAX_SP_REGNUM); | |
613 | set_gdbarch_fp_regnum (gdbarch, VAX_FP_REGNUM); | |
614 | set_gdbarch_pc_regnum (gdbarch, VAX_PC_REGNUM); | |
615 | set_gdbarch_ps_regnum (gdbarch, VAX_PS_REGNUM); | |
616 | ||
617 | set_gdbarch_register_name (gdbarch, vax_register_name); | |
618 | set_gdbarch_register_size (gdbarch, VAX_REGISTER_SIZE); | |
619 | set_gdbarch_register_bytes (gdbarch, VAX_REGISTER_BYTES); | |
620 | set_gdbarch_register_byte (gdbarch, vax_register_byte); | |
621 | set_gdbarch_register_raw_size (gdbarch, vax_register_raw_size); | |
622 | set_gdbarch_max_register_raw_size (gdbarch, VAX_MAX_REGISTER_RAW_SIZE); | |
623 | set_gdbarch_register_virtual_size (gdbarch, vax_register_virtual_size); | |
624 | set_gdbarch_max_register_virtual_size (gdbarch, | |
625 | VAX_MAX_REGISTER_VIRTUAL_SIZE); | |
626 | set_gdbarch_register_virtual_type (gdbarch, vax_register_virtual_type); | |
627 | ||
628 | /* Frame and stack info */ | |
629 | set_gdbarch_skip_prologue (gdbarch, vax_skip_prologue); | |
630 | set_gdbarch_saved_pc_after_call (gdbarch, vax_saved_pc_after_call); | |
631 | ||
632 | set_gdbarch_frame_num_args (gdbarch, vax_frame_num_args); | |
633 | set_gdbarch_frameless_function_invocation (gdbarch, | |
634 | generic_frameless_function_invocation_not); | |
635 | ||
636 | set_gdbarch_frame_chain (gdbarch, vax_frame_chain); | |
637 | set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid); | |
638 | set_gdbarch_frame_saved_pc (gdbarch, vax_frame_saved_pc); | |
639 | ||
640 | set_gdbarch_frame_args_address (gdbarch, vax_frame_args_address); | |
641 | set_gdbarch_frame_locals_address (gdbarch, vax_frame_locals_address); | |
642 | ||
643 | set_gdbarch_frame_init_saved_regs (gdbarch, vax_frame_init_saved_regs); | |
644 | ||
645 | set_gdbarch_frame_args_skip (gdbarch, 4); | |
646 | ||
f267bd6a JT |
647 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); |
648 | ||
649 | /* Return value info */ | |
650 | set_gdbarch_store_struct_return (gdbarch, vax_store_struct_return); | |
26e9b323 | 651 | set_gdbarch_deprecated_extract_return_value (gdbarch, vax_extract_return_value); |
ebba8386 | 652 | set_gdbarch_deprecated_store_return_value (gdbarch, vax_store_return_value); |
26e9b323 | 653 | set_gdbarch_deprecated_extract_struct_value_address (gdbarch, vax_extract_struct_value_address); |
f267bd6a JT |
654 | |
655 | /* Call dummy info */ | |
656 | set_gdbarch_push_dummy_frame (gdbarch, vax_push_dummy_frame); | |
657 | set_gdbarch_pop_frame (gdbarch, vax_pop_frame); | |
658 | set_gdbarch_call_dummy_location (gdbarch, ON_STACK); | |
659 | set_gdbarch_call_dummy_p (gdbarch, 1); | |
660 | set_gdbarch_call_dummy_words (gdbarch, vax_call_dummy_words); | |
661 | set_gdbarch_sizeof_call_dummy_words (gdbarch, sizeof_vax_call_dummy_words); | |
662 | set_gdbarch_fix_call_dummy (gdbarch, vax_fix_call_dummy); | |
663 | set_gdbarch_call_dummy_start_offset (gdbarch, 0); | |
664 | set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1); | |
665 | set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 7); | |
666 | set_gdbarch_use_generic_dummy_frames (gdbarch, 0); | |
667 | set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_on_stack); | |
668 | set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0); | |
669 | ||
670 | /* Breakpoint info */ | |
1d049c5e | 671 | set_gdbarch_breakpoint_from_pc (gdbarch, vax_breakpoint_from_pc); |
f267bd6a JT |
672 | set_gdbarch_decr_pc_after_break (gdbarch, 0); |
673 | ||
674 | /* Misc info */ | |
675 | set_gdbarch_function_start_offset (gdbarch, 2); | |
1d049c5e | 676 | set_gdbarch_believe_pcc_promotion (gdbarch, 1); |
f267bd6a | 677 | |
4791e091 JT |
678 | /* Hook in ABI-specific overrides, if they have been registered. */ |
679 | gdbarch_init_osabi (info, gdbarch, osabi); | |
680 | ||
f267bd6a JT |
681 | return (gdbarch); |
682 | } | |
c906108c | 683 | |
4791e091 JT |
684 | static void |
685 | vax_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) | |
686 | { | |
687 | struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); | |
688 | ||
689 | if (tdep == NULL) | |
690 | return; | |
691 | ||
692 | fprintf_unfiltered (file, "vax_dump_tdep: OS ABI = %s\n", | |
693 | gdbarch_osabi_name (tdep->osabi)); | |
694 | } | |
695 | ||
c906108c | 696 | void |
fba45db2 | 697 | _initialize_vax_tdep (void) |
c906108c | 698 | { |
4791e091 | 699 | gdbarch_register (bfd_arch_vax, vax_gdbarch_init, vax_dump_tdep); |
f267bd6a | 700 | |
c906108c SS |
701 | tm_print_insn = vax_print_insn; |
702 | } |