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