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