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