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