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