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