1 // OBSOLETE /* Target-machine dependent code for Zilog Z8000, for GDB.
3 // OBSOLETE Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
4 // OBSOLETE 2002, 2003 Free Software Foundation, Inc.
6 // OBSOLETE This file is part of GDB.
8 // OBSOLETE This program is free software; you can redistribute it and/or modify
9 // OBSOLETE it under the terms of the GNU General Public License as published by
10 // OBSOLETE the Free Software Foundation; either version 2 of the License, or
11 // OBSOLETE (at your option) any later version.
13 // OBSOLETE This program is distributed in the hope that it will be useful,
14 // OBSOLETE but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // OBSOLETE MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // OBSOLETE GNU General Public License for more details.
18 // OBSOLETE You should have received a copy of the GNU General Public License
19 // OBSOLETE along with this program; if not, write to the Free Software
20 // OBSOLETE Foundation, Inc., 59 Temple Place - Suite 330,
21 // OBSOLETE Boston, MA 02111-1307, USA. */
24 // OBSOLETE Contributed by Steve Chamberlain
28 // OBSOLETE #include "defs.h"
29 // OBSOLETE #include "frame.h"
30 // OBSOLETE #include "symtab.h"
31 // OBSOLETE #include "gdbcmd.h"
32 // OBSOLETE #include "gdbtypes.h"
33 // OBSOLETE #include "dis-asm.h"
34 // OBSOLETE #include "gdbcore.h"
35 // OBSOLETE #include "regcache.h"
37 // OBSOLETE #include "value.h" /* For read_register() */
40 // OBSOLETE static int read_memory_pointer (CORE_ADDR x);
42 // OBSOLETE /* Return the saved PC from this frame.
44 // OBSOLETE If the frame has a memory copy of SRP_REGNUM, use that. If not,
45 // OBSOLETE just use the register SRP_REGNUM itself. */
48 // OBSOLETE z8k_frame_saved_pc (struct frame_info *frame)
50 // OBSOLETE return read_memory_pointer (frame->frame + (BIG ? 4 : 2));
53 // OBSOLETE #define IS_PUSHL(x) (BIG ? ((x & 0xfff0) == 0x91e0):((x & 0xfff0) == 0x91F0))
54 // OBSOLETE #define IS_PUSHW(x) (BIG ? ((x & 0xfff0) == 0x93e0):((x & 0xfff0)==0x93f0))
55 // OBSOLETE #define IS_MOVE_FP(x) (BIG ? x == 0xa1ea : x == 0xa1fa)
56 // OBSOLETE #define IS_MOV_SP_FP(x) (BIG ? x == 0x94ea : x == 0x0d76)
57 // OBSOLETE #define IS_SUB2_SP(x) (x==0x1b87)
58 // OBSOLETE #define IS_MOVK_R5(x) (x==0x7905)
59 // OBSOLETE #define IS_SUB_SP(x) ((x & 0xffff) == 0x020f)
60 // OBSOLETE #define IS_PUSH_FP(x) (BIG ? (x == 0x93ea) : (x == 0x93fa))
62 // OBSOLETE /* work out how much local space is on the stack and
63 // OBSOLETE return the pc pointing to the first push */
65 // OBSOLETE static CORE_ADDR
66 // OBSOLETE skip_adjust (CORE_ADDR pc, int *size)
68 // OBSOLETE *size = 0;
70 // OBSOLETE if (IS_PUSH_FP (read_memory_short (pc))
71 // OBSOLETE && IS_MOV_SP_FP (read_memory_short (pc + 2)))
73 // OBSOLETE /* This is a function with an explict frame pointer */
75 // OBSOLETE *size += 2; /* remember the frame pointer */
78 // OBSOLETE /* remember any stack adjustment */
79 // OBSOLETE if (IS_SUB_SP (read_memory_short (pc)))
81 // OBSOLETE *size += read_memory_short (pc + 2);
84 // OBSOLETE return pc;
87 // OBSOLETE static CORE_ADDR examine_frame (CORE_ADDR, CORE_ADDR * regs, CORE_ADDR);
88 // OBSOLETE static CORE_ADDR
89 // OBSOLETE examine_frame (CORE_ADDR pc, CORE_ADDR *regs, CORE_ADDR sp)
91 // OBSOLETE int w = read_memory_short (pc);
92 // OBSOLETE int offset = 0;
93 // OBSOLETE int regno;
95 // OBSOLETE for (regno = 0; regno < NUM_REGS; regno++)
96 // OBSOLETE regs[regno] = 0;
98 // OBSOLETE while (IS_PUSHW (w) || IS_PUSHL (w))
100 // OBSOLETE /* work out which register is being pushed to where */
101 // OBSOLETE if (IS_PUSHL (w))
103 // OBSOLETE regs[w & 0xf] = offset;
104 // OBSOLETE regs[(w & 0xf) + 1] = offset + 2;
105 // OBSOLETE offset += 4;
109 // OBSOLETE regs[w & 0xf] = offset;
110 // OBSOLETE offset += 2;
113 // OBSOLETE w = read_memory_short (pc);
116 // OBSOLETE if (IS_MOVE_FP (w))
118 // OBSOLETE /* We know the fp */
121 // OBSOLETE else if (IS_SUB_SP (w))
123 // OBSOLETE /* Subtracting a value from the sp, so were in a function
124 // OBSOLETE which needs stack space for locals, but has no fp. We fake up
125 // OBSOLETE the values as if we had an fp */
126 // OBSOLETE regs[FP_REGNUM] = sp;
130 // OBSOLETE /* This one didn't have an fp, we'll fake it up */
131 // OBSOLETE regs[SP_REGNUM] = sp;
133 // OBSOLETE /* stack pointer contains address of next frame */
134 // OBSOLETE /* regs[fp_regnum()] = fp; */
135 // OBSOLETE regs[SP_REGNUM] = sp;
136 // OBSOLETE return pc;
139 // OBSOLETE CORE_ADDR
140 // OBSOLETE z8k_skip_prologue (CORE_ADDR start_pc)
142 // OBSOLETE CORE_ADDR dummy[NUM_REGS];
144 // OBSOLETE return examine_frame (start_pc, dummy, 0);
147 // OBSOLETE CORE_ADDR
148 // OBSOLETE z8k_addr_bits_remove (CORE_ADDR addr)
150 // OBSOLETE return (addr & PTR_MASK);
153 // OBSOLETE static int
154 // OBSOLETE read_memory_pointer (CORE_ADDR x)
156 // OBSOLETE return read_memory_integer (ADDR_BITS_REMOVE (x), BIG ? 4 : 2);
159 // OBSOLETE CORE_ADDR
160 // OBSOLETE z8k_frame_chain (struct frame_info *thisframe)
162 // OBSOLETE if (!inside_entry_file (get_frame_pc (thisframe)))
164 // OBSOLETE return read_memory_pointer (thisframe->frame);
166 // OBSOLETE return 0;
169 // OBSOLETE /* Put here the code to store, into a struct frame_saved_regs,
170 // OBSOLETE the addresses of the saved registers of frame described by FRAME_INFO.
171 // OBSOLETE This includes special registers such as pc and fp saved in special
172 // OBSOLETE ways in the stack frame. sp is even more special:
173 // OBSOLETE the address we return for it IS the sp for the next frame. */
176 // OBSOLETE z8k_frame_init_saved_regs (struct frame_info *frame_info)
178 // OBSOLETE CORE_ADDR pc;
181 // OBSOLETE frame_saved_regs_zalloc (frame_info);
182 // OBSOLETE pc = get_pc_function_start (get_frame_pc (frame_info));
184 // OBSOLETE /* wander down the instruction stream */
185 // OBSOLETE examine_frame (pc, frame_info->saved_regs, frame_info->frame);
190 // OBSOLETE z8k_push_dummy_frame (void)
192 // OBSOLETE internal_error (__FILE__, __LINE__, "failed internal consistency check");
196 // OBSOLETE gdb_print_insn_z8k (bfd_vma memaddr, disassemble_info *info)
199 // OBSOLETE return print_insn_z8001 (memaddr, info);
201 // OBSOLETE return print_insn_z8002 (memaddr, info);
204 // OBSOLETE /* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or
205 // OBSOLETE is not the address of a valid instruction, the address of the next
206 // OBSOLETE instruction beyond ADDR otherwise. *PWORD1 receives the first word
207 // OBSOLETE of the instruction. */
209 // OBSOLETE CORE_ADDR
210 // OBSOLETE NEXT_PROLOGUE_INSN (CORE_ADDR addr, CORE_ADDR lim, short *pword1)
212 // OBSOLETE char buf[2];
213 // OBSOLETE if (addr < lim + 8)
215 // OBSOLETE read_memory (addr, buf, 2);
216 // OBSOLETE *pword1 = extract_signed_integer (buf, 2);
218 // OBSOLETE return addr + 2;
220 // OBSOLETE return 0;
224 // OBSOLETE /* Put here the code to store, into a struct frame_saved_regs,
225 // OBSOLETE the addresses of the saved registers of frame described by FRAME_INFO.
226 // OBSOLETE This includes special registers such as pc and fp saved in special
227 // OBSOLETE ways in the stack frame. sp is even more special:
228 // OBSOLETE the address we return for it IS the sp for the next frame.
230 // OBSOLETE We cache the result of doing this in the frame_cache_obstack, since
231 // OBSOLETE it is fairly expensive. */
234 // OBSOLETE frame_find_saved_regs (struct frame_info *fip, struct frame_saved_regs *fsrp)
236 // OBSOLETE int locals;
237 // OBSOLETE CORE_ADDR pc;
238 // OBSOLETE CORE_ADDR adr;
241 // OBSOLETE memset (fsrp, 0, sizeof *fsrp);
243 // OBSOLETE pc = skip_adjust (get_pc_function_start (get_frame_pc (fip)), &locals);
246 // OBSOLETE adr = get_frame_base (fip) - locals;
247 // OBSOLETE for (i = 0; i < 8; i++)
249 // OBSOLETE int word = read_memory_short (pc);
252 // OBSOLETE if (IS_PUSHL (word))
254 // OBSOLETE fsrp->regs[word & 0xf] = adr;
255 // OBSOLETE fsrp->regs[(word & 0xf) + 1] = adr - 2;
256 // OBSOLETE adr -= 4;
258 // OBSOLETE else if (IS_PUSHW (word))
260 // OBSOLETE fsrp->regs[word & 0xf] = adr;
261 // OBSOLETE adr -= 2;
269 // OBSOLETE fsrp->regs[PC_REGNUM] = fip->frame + 4;
270 // OBSOLETE fsrp->regs[FP_REGNUM] = fip->frame;
276 // OBSOLETE z8k_saved_pc_after_call (struct frame_info *frame)
278 // OBSOLETE return ADDR_BITS_REMOVE
279 // OBSOLETE (read_memory_integer (read_register (SP_REGNUM), PTR_SIZE));
284 // OBSOLETE extract_return_value (struct type *type, char *regbuf, char *valbuf)
287 // OBSOLETE int len = TYPE_LENGTH (type);
289 // OBSOLETE for (b = 0; b < len; b += 2)
291 // OBSOLETE int todo = len - b;
293 // OBSOLETE if (todo > 2)
294 // OBSOLETE todo = 2;
295 // OBSOLETE memcpy (valbuf + b, regbuf + b, todo);
300 // OBSOLETE write_return_value (struct type *type, char *valbuf)
305 // OBSOLETE for (len = 0; len < TYPE_LENGTH (type); len += 2)
306 // OBSOLETE deprecated_write_register_bytes (REGISTER_BYTE (len / 2 + 2),
307 // OBSOLETE valbuf + len, 2);
311 // OBSOLETE store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
313 // OBSOLETE write_register (2, addr);
317 // OBSOLETE static void
318 // OBSOLETE z8k_print_register_hook (int regno)
320 // OBSOLETE if ((regno & 1) == 0 && regno < 16)
322 // OBSOLETE unsigned char l[4];
324 // OBSOLETE frame_register_read (deprecated_selected_frame, regno, l + 0);
325 // OBSOLETE frame_register_read (deprecated_selected_frame, regno + 1, l + 2);
326 // OBSOLETE printf_unfiltered ("\t");
327 // OBSOLETE printf_unfiltered ("0x%02x%02x%02x%02x", l[0], l[1], l[2], l[3]);
330 // OBSOLETE if ((regno & 3) == 0 && regno < 16)
332 // OBSOLETE unsigned char l[8];
334 // OBSOLETE frame_register_read (deprecated_selected_frame, regno, l + 0);
335 // OBSOLETE frame_register_read (deprecated_selected_frame, regno + 1, l + 2);
336 // OBSOLETE frame_register_read (deprecated_selected_frame, regno + 2, l + 4);
337 // OBSOLETE frame_register_read (deprecated_selected_frame, regno + 3, l + 6);
339 // OBSOLETE printf_unfiltered ("\t");
340 // OBSOLETE printf_unfiltered ("0x%02x%02x%02x%02x%02x%02x%02x%02x",
341 // OBSOLETE l[0], l[1], l[2], l[3], l[4], l[5], l[6], l[7]);
343 // OBSOLETE if (regno == 15)
345 // OBSOLETE unsigned short rval;
348 // OBSOLETE frame_register_read (deprecated_selected_frame, regno, (char *) (&rval));
350 // OBSOLETE printf_unfiltered ("\n");
351 // OBSOLETE for (i = 0; i < 10; i += 2)
353 // OBSOLETE printf_unfiltered ("(sp+%d=%04x)", i,
354 // OBSOLETE (unsigned int)read_memory_short (rval + i));
359 // OBSOLETE static void
360 // OBSOLETE z8k_print_registers_info (struct gdbarch *gdbarch,
361 // OBSOLETE struct ui_file *file,
362 // OBSOLETE struct frame_info *frame,
363 // OBSOLETE int regnum, int print_all)
366 // OBSOLETE const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
367 // OBSOLETE char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
368 // OBSOLETE char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
370 // OBSOLETE for (i = 0; i < numregs; i++)
372 // OBSOLETE /* Decide between printing all regs, non-float / vector regs, or
373 // OBSOLETE specific reg. */
374 // OBSOLETE if (regnum == -1)
376 // OBSOLETE if (!print_all)
378 // OBSOLETE if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
379 // OBSOLETE continue;
380 // OBSOLETE if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)))
381 // OBSOLETE continue;
386 // OBSOLETE if (i != regnum)
387 // OBSOLETE continue;
390 // OBSOLETE /* If the register name is empty, it is undefined for this
391 // OBSOLETE processor, so don't display anything. */
392 // OBSOLETE if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
393 // OBSOLETE continue;
395 // OBSOLETE fputs_filtered (REGISTER_NAME (i), file);
396 // OBSOLETE print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
398 // OBSOLETE /* Get the data in raw format. */
399 // OBSOLETE if (! frame_register_read (frame, i, raw_buffer))
401 // OBSOLETE fprintf_filtered (file, "*value not available*\n");
402 // OBSOLETE continue;
405 // OBSOLETE /* FIXME: cagney/2002-08-03: This code shouldn't be necessary.
406 // OBSOLETE The function frame_register_read() should have returned the
407 // OBSOLETE pre-cooked register so no conversion is necessary. */
408 // OBSOLETE /* Convert raw data to virtual format if necessary. */
409 // OBSOLETE if (REGISTER_CONVERTIBLE (i))
411 // OBSOLETE REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
412 // OBSOLETE raw_buffer, virtual_buffer);
416 // OBSOLETE memcpy (virtual_buffer, raw_buffer,
417 // OBSOLETE REGISTER_VIRTUAL_SIZE (i));
420 // OBSOLETE /* If virtual format is floating, print it that way, and in raw
422 // OBSOLETE if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
426 // OBSOLETE val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
427 // OBSOLETE file, 0, 1, 0, Val_pretty_default);
429 // OBSOLETE fprintf_filtered (file, "\t(raw 0x");
430 // OBSOLETE for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
433 // OBSOLETE if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
436 // OBSOLETE idx = REGISTER_RAW_SIZE (i) - 1 - j;
437 // OBSOLETE fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
439 // OBSOLETE fprintf_filtered (file, ")");
443 // OBSOLETE /* Print the register in hex. */
444 // OBSOLETE val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
445 // OBSOLETE file, 'x', 1, 0, Val_pretty_default);
446 // OBSOLETE /* If not a vector register, print it also according to its
447 // OBSOLETE natural format. */
448 // OBSOLETE if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)) == 0)
450 // OBSOLETE fprintf_filtered (file, "\t");
451 // OBSOLETE val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
452 // OBSOLETE file, 0, 1, 0, Val_pretty_default);
456 // OBSOLETE /* Some z8k specific info. */
457 // OBSOLETE z8k_print_register_hook (i);
459 // OBSOLETE fprintf_filtered (file, "\n");
464 // OBSOLETE z8k_do_registers_info (int regnum, int all)
466 // OBSOLETE z8k_print_registers_info (current_gdbarch, gdb_stdout,
467 // OBSOLETE deprecated_selected_frame, regnum, all);
471 // OBSOLETE z8k_pop_frame (void)
475 // OBSOLETE struct cmd_list_element *setmemorylist;
478 // OBSOLETE z8k_set_pointer_size (int newsize)
480 // OBSOLETE static int oldsize = 0;
482 // OBSOLETE if (oldsize != newsize)
484 // OBSOLETE printf_unfiltered ("pointer size set to %d bits\n", newsize);
485 // OBSOLETE oldsize = newsize;
486 // OBSOLETE if (newsize == 32)
494 // OBSOLETE /* FIXME: This code should be using the GDBARCH framework to
495 // OBSOLETE handle changed type sizes. If this problem is ever fixed
496 // OBSOLETE (the direct reference to _initialize_gdbtypes() below
497 // OBSOLETE eliminated) then Makefile.in should be updated so that
498 // OBSOLETE z8k-tdep.c is again compiled with -Werror. */
499 // OBSOLETE _initialize_gdbtypes ();
503 // OBSOLETE static void
504 // OBSOLETE segmented_command (char *args, int from_tty)
506 // OBSOLETE z8k_set_pointer_size (32);
509 // OBSOLETE static void
510 // OBSOLETE unsegmented_command (char *args, int from_tty)
512 // OBSOLETE z8k_set_pointer_size (16);
515 // OBSOLETE static void
516 // OBSOLETE set_memory (char *args, int from_tty)
518 // OBSOLETE printf_unfiltered ("\"set memory\" must be followed by the name of a memory subcommand.\n");
519 // OBSOLETE help_list (setmemorylist, "set memory ", -1, gdb_stdout);
523 // OBSOLETE _initialize_z8ktdep (void)
525 // OBSOLETE tm_print_insn = gdb_print_insn_z8k;
527 // OBSOLETE add_prefix_cmd ("memory", no_class, set_memory,
528 // OBSOLETE "set the memory model", &setmemorylist, "set memory ", 0,
529 // OBSOLETE &setlist);
530 // OBSOLETE add_cmd ("segmented", class_support, segmented_command,
531 // OBSOLETE "Set segmented memory model.", &setmemorylist);
532 // OBSOLETE add_cmd ("unsegmented", class_support, unsegmented_command,
533 // OBSOLETE "Set unsegmented memory model.", &setmemorylist);