1 /* OBSOLETE /* Target-dependent code for Mitsubishi D30V, for GDB. */
3 /* OBSOLETE Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software */
4 /* OBSOLETE 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. */ */
23 /* OBSOLETE /* Contributed by Martin Hunt, hunt@cygnus.com */ */
25 /* OBSOLETE #include "defs.h" */
26 /* OBSOLETE #include "frame.h" */
27 /* OBSOLETE #include "obstack.h" */
28 /* OBSOLETE #include "symtab.h" */
29 /* OBSOLETE #include "gdbtypes.h" */
30 /* OBSOLETE #include "gdbcmd.h" */
31 /* OBSOLETE #include "gdbcore.h" */
32 /* OBSOLETE #include "gdb_string.h" */
33 /* OBSOLETE #include "value.h" */
34 /* OBSOLETE #include "inferior.h" */
35 /* OBSOLETE #include "dis-asm.h" */
36 /* OBSOLETE #include "symfile.h" */
37 /* OBSOLETE #include "objfiles.h" */
38 /* OBSOLETE #include "regcache.h" */
40 /* OBSOLETE #include "language.h" /* For local_hex_string() */ */
42 /* OBSOLETE void d30v_frame_find_saved_regs (struct frame_info *fi, */
43 /* OBSOLETE struct frame_saved_regs *fsr); */
44 /* OBSOLETE void d30v_frame_find_saved_regs_offsets (struct frame_info *fi, */
45 /* OBSOLETE struct frame_saved_regs *fsr); */
46 /* OBSOLETE static void d30v_pop_dummy_frame (struct frame_info *fi); */
47 /* OBSOLETE static void d30v_print_flags (void); */
48 /* OBSOLETE static void print_flags_command (char *, int); */
50 /* OBSOLETE /* the following defines assume: */
51 /* OBSOLETE fp is r61, lr is r62, sp is r63, and ?? is r22 */
52 /* OBSOLETE if that changes, they will need to be updated */ */
54 /* OBSOLETE #define OP_MASK_ALL_BUT_RA 0x0ffc0fff /* throw away Ra, keep the rest */ */
56 /* OBSOLETE #define OP_STW_SPM 0x054c0fc0 /* stw Ra, @(sp-) */ */
57 /* OBSOLETE #define OP_STW_SP_R0 0x05400fc0 /* stw Ra, @(sp,r0) */ */
58 /* OBSOLETE #define OP_STW_SP_IMM0 0x05480fc0 /* st Ra, @(sp, 0x0) */ */
59 /* OBSOLETE #define OP_STW_R22P_R0 0x05440580 /* stw Ra, @(r22+,r0) */ */
61 /* OBSOLETE #define OP_ST2W_SPM 0x056c0fc0 /* st2w Ra, @(sp-) */ */
62 /* OBSOLETE #define OP_ST2W_SP_R0 0x05600fc0 /* st2w Ra, @(sp, r0) */ */
63 /* OBSOLETE #define OP_ST2W_SP_IMM0 0x05680fc0 /* st2w Ra, @(sp, 0x0) */ */
64 /* OBSOLETE #define OP_ST2W_R22P_R0 0x05640580 /* st2w Ra, @(r22+, r0) */ */
66 /* OBSOLETE #define OP_MASK_OPCODE 0x0ffc0000 /* just the opcode, ign operands */ */
67 /* OBSOLETE #define OP_NOP 0x00f00000 /* nop */ */
69 /* OBSOLETE #define OP_MASK_ALL_BUT_IMM 0x0fffffc0 /* throw away imm, keep the rest */ */
70 /* OBSOLETE #define OP_SUB_SP_IMM 0x082bffc0 /* sub sp,sp,imm */ */
71 /* OBSOLETE #define OP_ADD_SP_IMM 0x080bffc0 /* add sp,sp,imm */ */
72 /* OBSOLETE #define OP_ADD_R22_SP_IMM 0x08096fc0 /* add r22,sp,imm */ */
73 /* OBSOLETE #define OP_STW_FP_SP_IMM 0x054bdfc0 /* stw fp,@(sp,imm) */ */
74 /* OBSOLETE #define OP_OR_SP_R0_IMM 0x03abf000 /* or sp,r0,imm */ */
76 /* OBSOLETE /* no mask */ */
77 /* OBSOLETE #define OP_OR_FP_R0_SP 0x03a3d03f /* or fp,r0,sp */ */
78 /* OBSOLETE #define OP_OR_FP_SP_R0 0x03a3dfc0 /* or fp,sp,r0 */ */
79 /* OBSOLETE #define OP_OR_FP_IMM0_SP 0x03abd03f /* or fp,0x0,sp */ */
80 /* OBSOLETE #define OP_STW_FP_R22P_R0 0x0547d580 /* stw fp,@(r22+,r0) */ */
81 /* OBSOLETE #define OP_STW_LR_R22P_R0 0x0547e580 /* stw lr,@(r22+,r0) */ */
83 /* OBSOLETE #define OP_MASK_OP_AND_RB 0x0ff80fc0 /* keep op and rb,throw away rest */ */
84 /* OBSOLETE #define OP_STW_SP_IMM 0x05480fc0 /* stw Ra,@(sp,imm) */ */
85 /* OBSOLETE #define OP_ST2W_SP_IMM 0x05680fc0 /* st2w Ra,@(sp,imm) */ */
86 /* OBSOLETE #define OP_STW_FP_IMM 0x05480f40 /* stw Ra,@(fp,imm) */ */
87 /* OBSOLETE #define OP_STW_FP_R0 0x05400f40 /* stw Ra,@(fp,r0) */ */
89 /* OBSOLETE #define OP_MASK_FM_BIT 0x80000000 */
90 /* OBSOLETE #define OP_MASK_CC_BITS 0x70000000 */
91 /* OBSOLETE #define OP_MASK_SUB_INST 0x0fffffff */
93 /* OBSOLETE #define EXTRACT_RA(op) (((op) >> 12) & 0x3f) */
94 /* OBSOLETE #define EXTRACT_RB(op) (((op) >> 6) & 0x3f) */
95 /* OBSOLETE #define EXTRACT_RC(op) (((op) & 0x3f) */
96 /* OBSOLETE #define EXTRACT_UIMM6(op) ((op) & 0x3f) */
97 /* OBSOLETE #define EXTRACT_IMM6(op) ((((int)EXTRACT_UIMM6(op)) << 26) >> 26) */
98 /* OBSOLETE #define EXTRACT_IMM26(op) ((((op)&0x0ff00000) >> 2) | ((op)&0x0003ffff)) */
99 /* OBSOLETE #define EXTRACT_IMM32(opl, opr) ((EXTRACT_UIMM6(opl) << 26)|EXTRACT_IMM26(opr)) */
103 /* OBSOLETE d30v_frame_chain_valid (CORE_ADDR chain, struct frame_info *fi) */
106 /* OBSOLETE return ((chain) != 0 && (fi) != 0 && (fi)->return_pc != 0); */
108 /* OBSOLETE return ((chain) != 0 && (fi) != 0 && (fi)->frame <= chain); */
109 /* OBSOLETE #endif */
112 /* OBSOLETE /* Discard from the stack the innermost frame, restoring all saved */
113 /* OBSOLETE registers. */ */
116 /* OBSOLETE d30v_pop_frame (void) */
118 /* OBSOLETE struct frame_info *frame = get_current_frame (); */
119 /* OBSOLETE CORE_ADDR fp; */
120 /* OBSOLETE int regnum; */
121 /* OBSOLETE struct frame_saved_regs fsr; */
122 /* OBSOLETE char raw_buffer[8]; */
124 /* OBSOLETE fp = FRAME_FP (frame); */
125 /* OBSOLETE if (frame->dummy) */
127 /* OBSOLETE d30v_pop_dummy_frame (frame); */
128 /* OBSOLETE return; */
131 /* OBSOLETE /* fill out fsr with the address of where each */ */
132 /* OBSOLETE /* register was stored in the frame */ */
133 /* OBSOLETE get_frame_saved_regs (frame, &fsr); */
135 /* OBSOLETE /* now update the current registers with the old values */ */
136 /* OBSOLETE for (regnum = A0_REGNUM; regnum < A0_REGNUM + 2; regnum++) */
138 /* OBSOLETE if (fsr.regs[regnum]) */
140 /* OBSOLETE read_memory (fsr.regs[regnum], raw_buffer, 8); */
141 /* OBSOLETE write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 8); */
144 /* OBSOLETE for (regnum = 0; regnum < SP_REGNUM; regnum++) */
146 /* OBSOLETE if (fsr.regs[regnum]) */
148 /* OBSOLETE write_register (regnum, read_memory_unsigned_integer (fsr.regs[regnum], 4)); */
151 /* OBSOLETE if (fsr.regs[PSW_REGNUM]) */
153 /* OBSOLETE write_register (PSW_REGNUM, read_memory_unsigned_integer (fsr.regs[PSW_REGNUM], 4)); */
156 /* OBSOLETE write_register (PC_REGNUM, read_register (LR_REGNUM)); */
157 /* OBSOLETE write_register (SP_REGNUM, fp + frame->size); */
158 /* OBSOLETE target_store_registers (-1); */
159 /* OBSOLETE flush_cached_frames (); */
162 /* OBSOLETE static int */
163 /* OBSOLETE check_prologue (unsigned long op) */
165 /* OBSOLETE /* add sp,sp,imm -- observed */ */
166 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_ADD_SP_IMM) */
167 /* OBSOLETE return 1; */
169 /* OBSOLETE /* add r22,sp,imm -- observed */ */
170 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_ADD_R22_SP_IMM) */
171 /* OBSOLETE return 1; */
173 /* OBSOLETE /* or fp,r0,sp -- observed */ */
174 /* OBSOLETE if (op == OP_OR_FP_R0_SP) */
175 /* OBSOLETE return 1; */
177 /* OBSOLETE /* nop */ */
178 /* OBSOLETE if ((op & OP_MASK_OPCODE) == OP_NOP) */
179 /* OBSOLETE return 1; */
181 /* OBSOLETE /* stw Ra,@(sp,r0) */ */
182 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_SP_R0) */
183 /* OBSOLETE return 1; */
185 /* OBSOLETE /* stw Ra,@(sp,0x0) */ */
186 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_SP_IMM0) */
187 /* OBSOLETE return 1; */
189 /* OBSOLETE /* st2w Ra,@(sp,r0) */ */
190 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_SP_R0) */
191 /* OBSOLETE return 1; */
193 /* OBSOLETE /* st2w Ra,@(sp,0x0) */ */
194 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_SP_IMM0) */
195 /* OBSOLETE return 1; */
197 /* OBSOLETE /* stw fp, @(r22+,r0) -- observed */ */
198 /* OBSOLETE if (op == OP_STW_FP_R22P_R0) */
199 /* OBSOLETE return 1; */
201 /* OBSOLETE /* stw r62, @(r22+,r0) -- observed */ */
202 /* OBSOLETE if (op == OP_STW_LR_R22P_R0) */
203 /* OBSOLETE return 1; */
205 /* OBSOLETE /* stw Ra, @(fp,r0) -- observed */ */
206 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_FP_R0) */
207 /* OBSOLETE return 1; /* first arg */ */
209 /* OBSOLETE /* stw Ra, @(fp,imm) -- observed */ */
210 /* OBSOLETE if ((op & OP_MASK_OP_AND_RB) == OP_STW_FP_IMM) */
211 /* OBSOLETE return 1; /* second and subsequent args */ */
213 /* OBSOLETE /* stw fp,@(sp,imm) -- observed */ */
214 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_STW_FP_SP_IMM) */
215 /* OBSOLETE return 1; */
217 /* OBSOLETE /* st2w Ra,@(r22+,r0) */ */
218 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_R22P_R0) */
219 /* OBSOLETE return 1; */
221 /* OBSOLETE /* stw Ra, @(sp-) */ */
222 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_SPM) */
223 /* OBSOLETE return 1; */
225 /* OBSOLETE /* st2w Ra, @(sp-) */ */
226 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_SPM) */
227 /* OBSOLETE return 1; */
229 /* OBSOLETE /* sub.? sp,sp,imm */ */
230 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_SUB_SP_IMM) */
231 /* OBSOLETE return 1; */
233 /* OBSOLETE return 0; */
236 /* OBSOLETE CORE_ADDR */
237 /* OBSOLETE d30v_skip_prologue (CORE_ADDR pc) */
239 /* OBSOLETE unsigned long op[2]; */
240 /* OBSOLETE unsigned long opl, opr; /* left / right sub operations */ */
241 /* OBSOLETE unsigned long fm0, fm1; /* left / right mode bits */ */
242 /* OBSOLETE unsigned long cc0, cc1; */
243 /* OBSOLETE unsigned long op1, op2; */
244 /* OBSOLETE CORE_ADDR func_addr, func_end; */
245 /* OBSOLETE struct symtab_and_line sal; */
247 /* OBSOLETE /* If we have line debugging information, then the end of the */ */
248 /* OBSOLETE /* prologue should the first assembly instruction of the first source line */ */
249 /* OBSOLETE if (find_pc_partial_function (pc, NULL, &func_addr, &func_end)) */
251 /* OBSOLETE sal = find_pc_line (func_addr, 0); */
252 /* OBSOLETE if (sal.end && sal.end < func_end) */
253 /* OBSOLETE return sal.end; */
256 /* OBSOLETE if (target_read_memory (pc, (char *) &op[0], 8)) */
257 /* OBSOLETE return pc; /* Can't access it -- assume no prologue. */ */
259 /* OBSOLETE while (1) */
261 /* OBSOLETE opl = (unsigned long) read_memory_integer (pc, 4); */
262 /* OBSOLETE opr = (unsigned long) read_memory_integer (pc + 4, 4); */
264 /* OBSOLETE fm0 = (opl & OP_MASK_FM_BIT); */
265 /* OBSOLETE fm1 = (opr & OP_MASK_FM_BIT); */
267 /* OBSOLETE cc0 = (opl & OP_MASK_CC_BITS); */
268 /* OBSOLETE cc1 = (opr & OP_MASK_CC_BITS); */
270 /* OBSOLETE opl = (opl & OP_MASK_SUB_INST); */
271 /* OBSOLETE opr = (opr & OP_MASK_SUB_INST); */
273 /* OBSOLETE if (fm0 && fm1) */
275 /* OBSOLETE /* long instruction (opl contains the opcode) */ */
276 /* OBSOLETE if (((opl & OP_MASK_ALL_BUT_IMM) != OP_ADD_SP_IMM) && /* add sp,sp,imm */ */
277 /* OBSOLETE ((opl & OP_MASK_ALL_BUT_IMM) != OP_ADD_R22_SP_IMM) && /* add r22,sp,imm */ */
278 /* OBSOLETE ((opl & OP_MASK_OP_AND_RB) != OP_STW_SP_IMM) && /* stw Ra, @(sp,imm) */ */
279 /* OBSOLETE ((opl & OP_MASK_OP_AND_RB) != OP_ST2W_SP_IMM)) /* st2w Ra, @(sp,imm) */ */
280 /* OBSOLETE break; */
284 /* OBSOLETE /* short instructions */ */
285 /* OBSOLETE if (fm0 && !fm1) */
287 /* OBSOLETE op1 = opr; */
288 /* OBSOLETE op2 = opl; */
292 /* OBSOLETE op1 = opl; */
293 /* OBSOLETE op2 = opr; */
295 /* OBSOLETE if (check_prologue (op1)) */
297 /* OBSOLETE if (!check_prologue (op2)) */
299 /* OBSOLETE /* if the previous opcode was really part of the prologue */ */
300 /* OBSOLETE /* and not just a NOP, then we want to break after both instructions */ */
301 /* OBSOLETE if ((op1 & OP_MASK_OPCODE) != OP_NOP) */
302 /* OBSOLETE pc += 8; */
303 /* OBSOLETE break; */
307 /* OBSOLETE break; */
309 /* OBSOLETE pc += 8; */
311 /* OBSOLETE return pc; */
314 /* OBSOLETE static int end_of_stack; */
316 /* OBSOLETE /* Given a GDB frame, determine the address of the calling function's frame. */
317 /* OBSOLETE This will be used to create a new GDB frame struct, and then */
318 /* OBSOLETE INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame. */
321 /* OBSOLETE CORE_ADDR */
322 /* OBSOLETE d30v_frame_chain (struct frame_info *frame) */
324 /* OBSOLETE struct frame_saved_regs fsr; */
326 /* OBSOLETE d30v_frame_find_saved_regs (frame, &fsr); */
328 /* OBSOLETE if (end_of_stack) */
329 /* OBSOLETE return (CORE_ADDR) 0; */
331 /* OBSOLETE if (frame->return_pc == IMEM_START) */
332 /* OBSOLETE return (CORE_ADDR) 0; */
334 /* OBSOLETE if (!fsr.regs[FP_REGNUM]) */
336 /* OBSOLETE if (!fsr.regs[SP_REGNUM] || fsr.regs[SP_REGNUM] == STACK_START) */
337 /* OBSOLETE return (CORE_ADDR) 0; */
339 /* OBSOLETE return fsr.regs[SP_REGNUM]; */
342 /* OBSOLETE if (!read_memory_unsigned_integer (fsr.regs[FP_REGNUM], 4)) */
343 /* OBSOLETE return (CORE_ADDR) 0; */
345 /* OBSOLETE return read_memory_unsigned_integer (fsr.regs[FP_REGNUM], 4); */
348 /* OBSOLETE static int next_addr, uses_frame; */
349 /* OBSOLETE static int frame_size; */
351 /* OBSOLETE static int */
352 /* OBSOLETE prologue_find_regs (unsigned long op, struct frame_saved_regs *fsr, */
353 /* OBSOLETE CORE_ADDR addr) */
355 /* OBSOLETE int n; */
356 /* OBSOLETE int offset; */
358 /* OBSOLETE /* add sp,sp,imm -- observed */ */
359 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_ADD_SP_IMM) */
361 /* OBSOLETE offset = EXTRACT_IMM6 (op); */
362 /* OBSOLETE /*next_addr += offset; */ */
363 /* OBSOLETE frame_size += -offset; */
364 /* OBSOLETE return 1; */
367 /* OBSOLETE /* add r22,sp,imm -- observed */ */
368 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_ADD_R22_SP_IMM) */
370 /* OBSOLETE offset = EXTRACT_IMM6 (op); */
371 /* OBSOLETE next_addr = (offset - frame_size); */
372 /* OBSOLETE return 1; */
375 /* OBSOLETE /* stw Ra, @(fp, offset) -- observed */ */
376 /* OBSOLETE if ((op & OP_MASK_OP_AND_RB) == OP_STW_FP_IMM) */
378 /* OBSOLETE n = EXTRACT_RA (op); */
379 /* OBSOLETE offset = EXTRACT_IMM6 (op); */
380 /* OBSOLETE fsr->regs[n] = (offset - frame_size); */
381 /* OBSOLETE return 1; */
384 /* OBSOLETE /* stw Ra, @(fp, r0) -- observed */ */
385 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_FP_R0) */
387 /* OBSOLETE n = EXTRACT_RA (op); */
388 /* OBSOLETE fsr->regs[n] = (-frame_size); */
389 /* OBSOLETE return 1; */
392 /* OBSOLETE /* or fp,0,sp -- observed */ */
393 /* OBSOLETE if ((op == OP_OR_FP_R0_SP) || */
394 /* OBSOLETE (op == OP_OR_FP_SP_R0) || */
395 /* OBSOLETE (op == OP_OR_FP_IMM0_SP)) */
397 /* OBSOLETE uses_frame = 1; */
398 /* OBSOLETE return 1; */
401 /* OBSOLETE /* nop */ */
402 /* OBSOLETE if ((op & OP_MASK_OPCODE) == OP_NOP) */
403 /* OBSOLETE return 1; */
405 /* OBSOLETE /* stw Ra,@(r22+,r0) -- observed */ */
406 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_R22P_R0) */
408 /* OBSOLETE n = EXTRACT_RA (op); */
409 /* OBSOLETE fsr->regs[n] = next_addr; */
410 /* OBSOLETE next_addr += 4; */
411 /* OBSOLETE return 1; */
413 /* OBSOLETE #if 0 /* subsumed in pattern above */ */
414 /* OBSOLETE /* stw fp,@(r22+,r0) -- observed */ */
415 /* OBSOLETE if (op == OP_STW_FP_R22P_R0) */
417 /* OBSOLETE fsr->regs[FP_REGNUM] = next_addr; /* XXX */ */
418 /* OBSOLETE next_addr += 4; */
419 /* OBSOLETE return 1; */
422 /* OBSOLETE /* stw r62,@(r22+,r0) -- observed */ */
423 /* OBSOLETE if (op == OP_STW_LR_R22P_R0) */
425 /* OBSOLETE fsr->regs[LR_REGNUM] = next_addr; */
426 /* OBSOLETE next_addr += 4; */
427 /* OBSOLETE return 1; */
429 /* OBSOLETE #endif */
430 /* OBSOLETE /* st2w Ra,@(r22+,r0) -- observed */ */
431 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_R22P_R0) */
433 /* OBSOLETE n = EXTRACT_RA (op); */
434 /* OBSOLETE fsr->regs[n] = next_addr; */
435 /* OBSOLETE fsr->regs[n + 1] = next_addr + 4; */
436 /* OBSOLETE next_addr += 8; */
437 /* OBSOLETE return 1; */
440 /* OBSOLETE /* stw rn, @(sp-) */ */
441 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_RA) == OP_STW_SPM) */
443 /* OBSOLETE n = EXTRACT_RA (op); */
444 /* OBSOLETE fsr->regs[n] = next_addr; */
445 /* OBSOLETE next_addr -= 4; */
446 /* OBSOLETE return 1; */
449 /* OBSOLETE /* st2w Ra, @(sp-) */ */
450 /* OBSOLETE else if ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_SPM) */
452 /* OBSOLETE n = EXTRACT_RA (op); */
453 /* OBSOLETE fsr->regs[n] = next_addr; */
454 /* OBSOLETE fsr->regs[n + 1] = next_addr + 4; */
455 /* OBSOLETE next_addr -= 8; */
456 /* OBSOLETE return 1; */
459 /* OBSOLETE /* sub sp,sp,imm */ */
460 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_SUB_SP_IMM) */
462 /* OBSOLETE offset = EXTRACT_IMM6 (op); */
463 /* OBSOLETE frame_size += -offset; */
464 /* OBSOLETE return 1; */
467 /* OBSOLETE /* st rn, @(sp,0) -- observed */ */
468 /* OBSOLETE if (((op & OP_MASK_ALL_BUT_RA) == OP_STW_SP_R0) || */
469 /* OBSOLETE ((op & OP_MASK_ALL_BUT_RA) == OP_STW_SP_IMM0)) */
471 /* OBSOLETE n = EXTRACT_RA (op); */
472 /* OBSOLETE fsr->regs[n] = (-frame_size); */
473 /* OBSOLETE return 1; */
476 /* OBSOLETE /* st2w rn, @(sp,0) */ */
477 /* OBSOLETE if (((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_SP_R0) || */
478 /* OBSOLETE ((op & OP_MASK_ALL_BUT_RA) == OP_ST2W_SP_IMM0)) */
480 /* OBSOLETE n = EXTRACT_RA (op); */
481 /* OBSOLETE fsr->regs[n] = (-frame_size); */
482 /* OBSOLETE fsr->regs[n + 1] = (-frame_size) + 4; */
483 /* OBSOLETE return 1; */
486 /* OBSOLETE /* stw fp,@(sp,imm) -- observed */ */
487 /* OBSOLETE if ((op & OP_MASK_ALL_BUT_IMM) == OP_STW_FP_SP_IMM) */
489 /* OBSOLETE offset = EXTRACT_IMM6 (op); */
490 /* OBSOLETE fsr->regs[FP_REGNUM] = (offset - frame_size); */
491 /* OBSOLETE return 1; */
493 /* OBSOLETE return 0; */
496 /* OBSOLETE /* Put here the code to store, into a struct frame_saved_regs, the */
497 /* OBSOLETE addresses of the saved registers of frame described by FRAME_INFO. */
498 /* OBSOLETE This includes special registers such as pc and fp saved in special */
499 /* OBSOLETE ways in the stack frame. sp is even more special: the address we */
500 /* OBSOLETE return for it IS the sp for the next frame. */ */
502 /* OBSOLETE d30v_frame_find_saved_regs (struct frame_info *fi, struct frame_saved_regs *fsr) */
504 /* OBSOLETE CORE_ADDR fp, pc; */
505 /* OBSOLETE unsigned long opl, opr; */
506 /* OBSOLETE unsigned long op1, op2; */
507 /* OBSOLETE unsigned long fm0, fm1; */
508 /* OBSOLETE int i; */
510 /* OBSOLETE fp = fi->frame; */
511 /* OBSOLETE memset (fsr, 0, sizeof (*fsr)); */
512 /* OBSOLETE next_addr = 0; */
513 /* OBSOLETE frame_size = 0; */
514 /* OBSOLETE end_of_stack = 0; */
516 /* OBSOLETE uses_frame = 0; */
518 /* OBSOLETE d30v_frame_find_saved_regs_offsets (fi, fsr); */
520 /* OBSOLETE fi->size = frame_size; */
522 /* OBSOLETE if (!fp) */
523 /* OBSOLETE fp = read_register (SP_REGNUM); */
525 /* OBSOLETE for (i = 0; i < NUM_REGS - 1; i++) */
526 /* OBSOLETE if (fsr->regs[i]) */
528 /* OBSOLETE fsr->regs[i] = fsr->regs[i] + fp + frame_size; */
531 /* OBSOLETE if (fsr->regs[LR_REGNUM]) */
532 /* OBSOLETE fi->return_pc = read_memory_unsigned_integer (fsr->regs[LR_REGNUM], 4); */
534 /* OBSOLETE fi->return_pc = read_register (LR_REGNUM); */
536 /* OBSOLETE /* the SP is not normally (ever?) saved, but check anyway */ */
537 /* OBSOLETE if (!fsr->regs[SP_REGNUM]) */
539 /* OBSOLETE /* if the FP was saved, that means the current FP is valid, */ */
540 /* OBSOLETE /* otherwise, it isn't being used, so we use the SP instead */ */
541 /* OBSOLETE if (uses_frame) */
542 /* OBSOLETE fsr->regs[SP_REGNUM] = read_register (FP_REGNUM) + fi->size; */
545 /* OBSOLETE fsr->regs[SP_REGNUM] = fp + fi->size; */
546 /* OBSOLETE fi->frameless = 1; */
547 /* OBSOLETE fsr->regs[FP_REGNUM] = 0; */
553 /* OBSOLETE d30v_frame_find_saved_regs_offsets (struct frame_info *fi, */
554 /* OBSOLETE struct frame_saved_regs *fsr) */
556 /* OBSOLETE CORE_ADDR fp, pc; */
557 /* OBSOLETE unsigned long opl, opr; */
558 /* OBSOLETE unsigned long op1, op2; */
559 /* OBSOLETE unsigned long fm0, fm1; */
560 /* OBSOLETE int i; */
562 /* OBSOLETE fp = fi->frame; */
563 /* OBSOLETE memset (fsr, 0, sizeof (*fsr)); */
564 /* OBSOLETE next_addr = 0; */
565 /* OBSOLETE frame_size = 0; */
566 /* OBSOLETE end_of_stack = 0; */
568 /* OBSOLETE pc = get_pc_function_start (fi->pc); */
570 /* OBSOLETE uses_frame = 0; */
571 /* OBSOLETE while (pc < fi->pc) */
573 /* OBSOLETE opl = (unsigned long) read_memory_integer (pc, 4); */
574 /* OBSOLETE opr = (unsigned long) read_memory_integer (pc + 4, 4); */
576 /* OBSOLETE fm0 = (opl & OP_MASK_FM_BIT); */
577 /* OBSOLETE fm1 = (opr & OP_MASK_FM_BIT); */
579 /* OBSOLETE opl = (opl & OP_MASK_SUB_INST); */
580 /* OBSOLETE opr = (opr & OP_MASK_SUB_INST); */
582 /* OBSOLETE if (fm0 && fm1) */
584 /* OBSOLETE /* long instruction */ */
585 /* OBSOLETE if ((opl & OP_MASK_ALL_BUT_IMM) == OP_ADD_SP_IMM) */
587 /* OBSOLETE /* add sp,sp,n */ */
588 /* OBSOLETE long offset = EXTRACT_IMM32 (opl, opr); */
589 /* OBSOLETE frame_size += -offset; */
591 /* OBSOLETE else if ((opl & OP_MASK_ALL_BUT_IMM) == OP_ADD_R22_SP_IMM) */
593 /* OBSOLETE /* add r22,sp,offset */ */
594 /* OBSOLETE long offset = EXTRACT_IMM32 (opl, opr); */
595 /* OBSOLETE next_addr = (offset - frame_size); */
597 /* OBSOLETE else if ((opl & OP_MASK_OP_AND_RB) == OP_STW_SP_IMM) */
599 /* OBSOLETE /* st Ra, @(sp,imm) */ */
600 /* OBSOLETE long offset = EXTRACT_IMM32 (opl, opr); */
601 /* OBSOLETE short n = EXTRACT_RA (opl); */
602 /* OBSOLETE fsr->regs[n] = (offset - frame_size); */
604 /* OBSOLETE else if ((opl & OP_MASK_OP_AND_RB) == OP_ST2W_SP_IMM) */
606 /* OBSOLETE /* st2w Ra, @(sp,offset) */ */
607 /* OBSOLETE long offset = EXTRACT_IMM32 (opl, opr); */
608 /* OBSOLETE short n = EXTRACT_RA (opl); */
609 /* OBSOLETE fsr->regs[n] = (offset - frame_size); */
610 /* OBSOLETE fsr->regs[n + 1] = (offset - frame_size) + 4; */
612 /* OBSOLETE else if ((opl & OP_MASK_ALL_BUT_IMM) == OP_OR_SP_R0_IMM) */
614 /* OBSOLETE end_of_stack = 1; */
617 /* OBSOLETE break; */
621 /* OBSOLETE /* short instructions */ */
622 /* OBSOLETE if (fm0 && !fm1) */
624 /* OBSOLETE op2 = opl; */
625 /* OBSOLETE op1 = opr; */
629 /* OBSOLETE op1 = opl; */
630 /* OBSOLETE op2 = opr; */
632 /* OBSOLETE if (!prologue_find_regs (op1, fsr, pc) || !prologue_find_regs (op2, fsr, pc)) */
633 /* OBSOLETE break; */
635 /* OBSOLETE pc += 8; */
639 /* OBSOLETE fi->size = frame_size; */
641 /* OBSOLETE if (!fp) */
642 /* OBSOLETE fp = read_register (SP_REGNUM); */
644 /* OBSOLETE for (i = 0; i < NUM_REGS - 1; i++) */
645 /* OBSOLETE if (fsr->regs[i]) */
647 /* OBSOLETE fsr->regs[i] = fsr->regs[i] + fp + frame_size; */
650 /* OBSOLETE if (fsr->regs[LR_REGNUM]) */
651 /* OBSOLETE fi->return_pc = read_memory_unsigned_integer (fsr->regs[LR_REGNUM], 4); */
653 /* OBSOLETE fi->return_pc = read_register (LR_REGNUM); */
655 /* OBSOLETE /* the SP is not normally (ever?) saved, but check anyway */ */
656 /* OBSOLETE if (!fsr->regs[SP_REGNUM]) */
658 /* OBSOLETE /* if the FP was saved, that means the current FP is valid, */ */
659 /* OBSOLETE /* otherwise, it isn't being used, so we use the SP instead */ */
660 /* OBSOLETE if (uses_frame) */
661 /* OBSOLETE fsr->regs[SP_REGNUM] = read_register (FP_REGNUM) + fi->size; */
664 /* OBSOLETE fsr->regs[SP_REGNUM] = fp + fi->size; */
665 /* OBSOLETE fi->frameless = 1; */
666 /* OBSOLETE fsr->regs[FP_REGNUM] = 0; */
669 /* OBSOLETE #endif */
673 /* OBSOLETE d30v_init_extra_frame_info (int fromleaf, struct frame_info *fi) */
675 /* OBSOLETE struct frame_saved_regs dummy; */
677 /* OBSOLETE if (fi->next && (fi->pc == 0)) */
678 /* OBSOLETE fi->pc = fi->next->return_pc; */
680 /* OBSOLETE d30v_frame_find_saved_regs_offsets (fi, &dummy); */
682 /* OBSOLETE if (uses_frame == 0) */
683 /* OBSOLETE fi->frameless = 1; */
685 /* OBSOLETE fi->frameless = 0; */
687 /* OBSOLETE if ((fi->next == 0) && (uses_frame == 0)) */
688 /* OBSOLETE /* innermost frame and it's "frameless", */
689 /* OBSOLETE so the fi->frame field is wrong, fix it! */ */
690 /* OBSOLETE fi->frame = read_sp (); */
692 /* OBSOLETE if (dummy.regs[LR_REGNUM]) */
694 /* OBSOLETE /* it was saved, grab it! */ */
695 /* OBSOLETE dummy.regs[LR_REGNUM] += (fi->frame + frame_size); */
696 /* OBSOLETE fi->return_pc = read_memory_unsigned_integer (dummy.regs[LR_REGNUM], 4); */
699 /* OBSOLETE fi->return_pc = read_register (LR_REGNUM); */
703 /* OBSOLETE d30v_init_frame_pc (int fromleaf, struct frame_info *prev) */
705 /* OBSOLETE /* default value, put here so we can breakpoint on it and */
706 /* OBSOLETE see if the default value is really the right thing to use */ */
707 /* OBSOLETE prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \ */
708 /* OBSOLETE prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ()); */
711 /* OBSOLETE static void d30v_print_register (int regnum, int tabular); */
713 /* OBSOLETE static void */
714 /* OBSOLETE d30v_print_register (int regnum, int tabular) */
716 /* OBSOLETE if (regnum < A0_REGNUM) */
718 /* OBSOLETE if (tabular) */
719 /* OBSOLETE printf_filtered ("%08lx", (long) read_register (regnum)); */
721 /* OBSOLETE printf_filtered ("0x%lx %ld", */
722 /* OBSOLETE (long) read_register (regnum), */
723 /* OBSOLETE (long) read_register (regnum)); */
727 /* OBSOLETE char regbuf[MAX_REGISTER_RAW_SIZE]; */
729 /* OBSOLETE frame_register_read (selected_frame, regnum, regbuf); */
731 /* OBSOLETE val_print (REGISTER_VIRTUAL_TYPE (regnum), regbuf, 0, 0, */
732 /* OBSOLETE gdb_stdout, 'x', 1, 0, Val_pretty_default); */
734 /* OBSOLETE if (!tabular) */
736 /* OBSOLETE printf_filtered (" "); */
737 /* OBSOLETE val_print (REGISTER_VIRTUAL_TYPE (regnum), regbuf, 0, 0, */
738 /* OBSOLETE gdb_stdout, 'd', 1, 0, Val_pretty_default); */
743 /* OBSOLETE static void */
744 /* OBSOLETE d30v_print_flags (void) */
746 /* OBSOLETE long psw = read_register (PSW_REGNUM); */
747 /* OBSOLETE printf_filtered ("flags #1"); */
748 /* OBSOLETE printf_filtered (" (sm) %d", (psw & PSW_SM) != 0); */
749 /* OBSOLETE printf_filtered (" (ea) %d", (psw & PSW_EA) != 0); */
750 /* OBSOLETE printf_filtered (" (db) %d", (psw & PSW_DB) != 0); */
751 /* OBSOLETE printf_filtered (" (ds) %d", (psw & PSW_DS) != 0); */
752 /* OBSOLETE printf_filtered (" (ie) %d", (psw & PSW_IE) != 0); */
753 /* OBSOLETE printf_filtered (" (rp) %d", (psw & PSW_RP) != 0); */
754 /* OBSOLETE printf_filtered (" (md) %d\n", (psw & PSW_MD) != 0); */
756 /* OBSOLETE printf_filtered ("flags #2"); */
757 /* OBSOLETE printf_filtered (" (f0) %d", (psw & PSW_F0) != 0); */
758 /* OBSOLETE printf_filtered (" (f1) %d", (psw & PSW_F1) != 0); */
759 /* OBSOLETE printf_filtered (" (f2) %d", (psw & PSW_F2) != 0); */
760 /* OBSOLETE printf_filtered (" (f3) %d", (psw & PSW_F3) != 0); */
761 /* OBSOLETE printf_filtered (" (s) %d", (psw & PSW_S) != 0); */
762 /* OBSOLETE printf_filtered (" (v) %d", (psw & PSW_V) != 0); */
763 /* OBSOLETE printf_filtered (" (va) %d", (psw & PSW_VA) != 0); */
764 /* OBSOLETE printf_filtered (" (c) %d\n", (psw & PSW_C) != 0); */
767 /* OBSOLETE static void */
768 /* OBSOLETE print_flags_command (char *args, int from_tty) */
770 /* OBSOLETE d30v_print_flags (); */
774 /* OBSOLETE d30v_do_registers_info (int regnum, int fpregs) */
776 /* OBSOLETE long long num1, num2; */
777 /* OBSOLETE long psw; */
779 /* OBSOLETE if (regnum != -1) */
781 /* OBSOLETE if (REGISTER_NAME (0) == NULL || REGISTER_NAME (0)[0] == '\000') */
782 /* OBSOLETE return; */
784 /* OBSOLETE printf_filtered ("%s ", REGISTER_NAME (regnum)); */
785 /* OBSOLETE d30v_print_register (regnum, 0); */
787 /* OBSOLETE printf_filtered ("\n"); */
788 /* OBSOLETE return; */
791 /* OBSOLETE /* Have to print all the registers. Format them nicely. */ */
793 /* OBSOLETE printf_filtered ("PC="); */
794 /* OBSOLETE print_address (read_pc (), gdb_stdout); */
796 /* OBSOLETE printf_filtered (" PSW="); */
797 /* OBSOLETE d30v_print_register (PSW_REGNUM, 1); */
799 /* OBSOLETE printf_filtered (" BPC="); */
800 /* OBSOLETE print_address (read_register (BPC_REGNUM), gdb_stdout); */
802 /* OBSOLETE printf_filtered (" BPSW="); */
803 /* OBSOLETE d30v_print_register (BPSW_REGNUM, 1); */
804 /* OBSOLETE printf_filtered ("\n"); */
806 /* OBSOLETE printf_filtered ("DPC="); */
807 /* OBSOLETE print_address (read_register (DPC_REGNUM), gdb_stdout); */
809 /* OBSOLETE printf_filtered (" DPSW="); */
810 /* OBSOLETE d30v_print_register (DPSW_REGNUM, 1); */
812 /* OBSOLETE printf_filtered (" IBA="); */
813 /* OBSOLETE print_address (read_register (IBA_REGNUM), gdb_stdout); */
814 /* OBSOLETE printf_filtered ("\n"); */
816 /* OBSOLETE printf_filtered ("RPT_C="); */
817 /* OBSOLETE d30v_print_register (RPT_C_REGNUM, 1); */
819 /* OBSOLETE printf_filtered (" RPT_S="); */
820 /* OBSOLETE print_address (read_register (RPT_S_REGNUM), gdb_stdout); */
822 /* OBSOLETE printf_filtered (" RPT_E="); */
823 /* OBSOLETE print_address (read_register (RPT_E_REGNUM), gdb_stdout); */
824 /* OBSOLETE printf_filtered ("\n"); */
826 /* OBSOLETE printf_filtered ("MOD_S="); */
827 /* OBSOLETE print_address (read_register (MOD_S_REGNUM), gdb_stdout); */
829 /* OBSOLETE printf_filtered (" MOD_E="); */
830 /* OBSOLETE print_address (read_register (MOD_E_REGNUM), gdb_stdout); */
831 /* OBSOLETE printf_filtered ("\n"); */
833 /* OBSOLETE printf_filtered ("EIT_VB="); */
834 /* OBSOLETE print_address (read_register (EIT_VB_REGNUM), gdb_stdout); */
836 /* OBSOLETE printf_filtered (" INT_S="); */
837 /* OBSOLETE d30v_print_register (INT_S_REGNUM, 1); */
839 /* OBSOLETE printf_filtered (" INT_M="); */
840 /* OBSOLETE d30v_print_register (INT_M_REGNUM, 1); */
841 /* OBSOLETE printf_filtered ("\n"); */
843 /* OBSOLETE d30v_print_flags (); */
844 /* OBSOLETE for (regnum = 0; regnum <= 63;) */
846 /* OBSOLETE int i; */
848 /* OBSOLETE printf_filtered ("R%d-R%d ", regnum, regnum + 7); */
849 /* OBSOLETE if (regnum < 10) */
850 /* OBSOLETE printf_filtered (" "); */
851 /* OBSOLETE if (regnum + 7 < 10) */
852 /* OBSOLETE printf_filtered (" "); */
854 /* OBSOLETE for (i = 0; i < 8; i++) */
856 /* OBSOLETE printf_filtered (" "); */
857 /* OBSOLETE d30v_print_register (regnum++, 1); */
860 /* OBSOLETE printf_filtered ("\n"); */
863 /* OBSOLETE printf_filtered ("A0-A1 "); */
865 /* OBSOLETE d30v_print_register (A0_REGNUM, 1); */
866 /* OBSOLETE printf_filtered (" "); */
867 /* OBSOLETE d30v_print_register (A1_REGNUM, 1); */
868 /* OBSOLETE printf_filtered ("\n"); */
871 /* OBSOLETE CORE_ADDR */
872 /* OBSOLETE d30v_fix_call_dummy (char *dummyname, CORE_ADDR start_sp, CORE_ADDR fun, */
873 /* OBSOLETE int nargs, struct value **args, */
874 /* OBSOLETE struct type *type, int gcc_p) */
876 /* OBSOLETE int regnum; */
877 /* OBSOLETE CORE_ADDR sp; */
878 /* OBSOLETE char buffer[MAX_REGISTER_RAW_SIZE]; */
879 /* OBSOLETE struct frame_info *frame = get_current_frame (); */
880 /* OBSOLETE frame->dummy = start_sp; */
881 /* OBSOLETE /*start_sp |= DMEM_START; */ */
883 /* OBSOLETE sp = start_sp; */
884 /* OBSOLETE for (regnum = 0; regnum < NUM_REGS; regnum++) */
886 /* OBSOLETE sp -= REGISTER_RAW_SIZE (regnum); */
887 /* OBSOLETE store_address (buffer, REGISTER_RAW_SIZE (regnum), read_register (regnum)); */
888 /* OBSOLETE write_memory (sp, buffer, REGISTER_RAW_SIZE (regnum)); */
890 /* OBSOLETE write_register (SP_REGNUM, (LONGEST) sp); */
891 /* OBSOLETE /* now we need to load LR with the return address */ */
892 /* OBSOLETE write_register (LR_REGNUM, (LONGEST) d30v_call_dummy_address ()); */
893 /* OBSOLETE return sp; */
896 /* OBSOLETE static void */
897 /* OBSOLETE d30v_pop_dummy_frame (struct frame_info *fi) */
899 /* OBSOLETE CORE_ADDR sp = fi->dummy; */
900 /* OBSOLETE int regnum; */
902 /* OBSOLETE for (regnum = 0; regnum < NUM_REGS; regnum++) */
904 /* OBSOLETE sp -= REGISTER_RAW_SIZE (regnum); */
905 /* OBSOLETE write_register (regnum, read_memory_unsigned_integer (sp, REGISTER_RAW_SIZE (regnum))); */
907 /* OBSOLETE flush_cached_frames (); /* needed? */ */
911 /* OBSOLETE CORE_ADDR */
912 /* OBSOLETE d30v_push_arguments (int nargs, struct value **args, CORE_ADDR sp, */
913 /* OBSOLETE int struct_return, CORE_ADDR struct_addr) */
915 /* OBSOLETE int i, len, index = 0, regnum = 2; */
916 /* OBSOLETE char buffer[4], *contents; */
917 /* OBSOLETE LONGEST val; */
918 /* OBSOLETE CORE_ADDR ptrs[10]; */
921 /* OBSOLETE /* Pass 1. Put all large args on stack */ */
922 /* OBSOLETE for (i = 0; i < nargs; i++) */
924 /* OBSOLETE struct value *arg = args[i]; */
925 /* OBSOLETE struct type *arg_type = check_typedef (VALUE_TYPE (arg)); */
926 /* OBSOLETE len = TYPE_LENGTH (arg_type); */
927 /* OBSOLETE contents = VALUE_CONTENTS (arg); */
928 /* OBSOLETE val = extract_signed_integer (contents, len); */
929 /* OBSOLETE if (len > 4) */
931 /* OBSOLETE /* put on stack and pass pointers */ */
932 /* OBSOLETE sp -= len; */
933 /* OBSOLETE write_memory (sp, contents, len); */
934 /* OBSOLETE ptrs[index++] = sp; */
937 /* OBSOLETE #endif */
938 /* OBSOLETE index = 0; */
940 /* OBSOLETE for (i = 0; i < nargs; i++) */
942 /* OBSOLETE struct value *arg = args[i]; */
943 /* OBSOLETE struct type *arg_type = check_typedef (VALUE_TYPE (arg)); */
944 /* OBSOLETE len = TYPE_LENGTH (arg_type); */
945 /* OBSOLETE contents = VALUE_CONTENTS (arg); */
946 /* OBSOLETE if (len > 4) */
948 /* OBSOLETE /* we need multiple registers */ */
949 /* OBSOLETE int ndx; */
951 /* OBSOLETE for (ndx = 0; len > 0; ndx += 8, len -= 8) */
953 /* OBSOLETE if (regnum & 1) */
954 /* OBSOLETE regnum++; /* all args > 4 bytes start in even register */ */
956 /* OBSOLETE if (regnum < 18) */
958 /* OBSOLETE val = extract_signed_integer (&contents[ndx], 4); */
959 /* OBSOLETE write_register (regnum++, val); */
961 /* OBSOLETE if (len >= 8) */
962 /* OBSOLETE val = extract_signed_integer (&contents[ndx + 4], 4); */
964 /* OBSOLETE val = extract_signed_integer (&contents[ndx + 4], len - 4); */
965 /* OBSOLETE write_register (regnum++, val); */
969 /* OBSOLETE /* no more registers available. put it on the stack */ */
971 /* OBSOLETE /* all args > 4 bytes are padded to a multiple of 8 bytes */
972 /* OBSOLETE and start on an 8 byte boundary */ */
973 /* OBSOLETE if (sp & 7) */
974 /* OBSOLETE sp -= (sp & 7); /* align it */ */
976 /* OBSOLETE sp -= ((len + 7) & ~7); /* allocate space */ */
977 /* OBSOLETE write_memory (sp, &contents[ndx], len); */
978 /* OBSOLETE break; */
984 /* OBSOLETE if (regnum < 18) */
986 /* OBSOLETE val = extract_signed_integer (contents, len); */
987 /* OBSOLETE write_register (regnum++, val); */
991 /* OBSOLETE /* all args are padded to a multiple of 4 bytes (at least) */ */
992 /* OBSOLETE sp -= ((len + 3) & ~3); */
993 /* OBSOLETE write_memory (sp, contents, len); */
997 /* OBSOLETE if (sp & 7) */
998 /* OBSOLETE /* stack pointer is not on an 8 byte boundary -- align it */ */
999 /* OBSOLETE sp -= (sp & 7); */
1000 /* OBSOLETE return sp; */
1004 /* OBSOLETE /* pick an out-of-the-way place to set the return value */ */
1005 /* OBSOLETE /* for an inferior function call. The link register is set to this */ */
1006 /* OBSOLETE /* value and a momentary breakpoint is set there. When the breakpoint */ */
1007 /* OBSOLETE /* is hit, the dummy frame is popped and the previous environment is */ */
1008 /* OBSOLETE /* restored. */ */
1010 /* OBSOLETE CORE_ADDR */
1011 /* OBSOLETE d30v_call_dummy_address (void) */
1013 /* OBSOLETE CORE_ADDR entry; */
1014 /* OBSOLETE struct minimal_symbol *sym; */
1016 /* OBSOLETE entry = entry_point_address (); */
1018 /* OBSOLETE if (entry != 0) */
1019 /* OBSOLETE return entry; */
1021 /* OBSOLETE sym = lookup_minimal_symbol ("_start", NULL, symfile_objfile); */
1023 /* OBSOLETE if (!sym || MSYMBOL_TYPE (sym) != mst_text) */
1024 /* OBSOLETE return 0; */
1026 /* OBSOLETE return SYMBOL_VALUE_ADDRESS (sym); */
1029 /* OBSOLETE /* Given a return value in `regbuf' with a type `valtype', */
1030 /* OBSOLETE extract and copy its value into `valbuf'. */ */
1033 /* OBSOLETE d30v_extract_return_value (struct type *valtype, char regbuf[REGISTER_BYTES], */
1034 /* OBSOLETE char *valbuf) */
1036 /* OBSOLETE memcpy (valbuf, regbuf + REGISTER_BYTE (2), TYPE_LENGTH (valtype)); */
1039 /* OBSOLETE /* The following code implements access to, and display of, the D30V's */
1040 /* OBSOLETE instruction trace buffer. The buffer consists of 64K or more */
1041 /* OBSOLETE 4-byte words of data, of which each words includes an 8-bit count, */
1042 /* OBSOLETE an 8-bit segment number, and a 16-bit instruction address. */
1044 /* OBSOLETE In theory, the trace buffer is continuously capturing instruction */
1045 /* OBSOLETE data that the CPU presents on its "debug bus", but in practice, the */
1046 /* OBSOLETE ROMified GDB stub only enables tracing when it continues or steps */
1047 /* OBSOLETE the program, and stops tracing when the program stops; so it */
1048 /* OBSOLETE actually works for GDB to read the buffer counter out of memory and */
1049 /* OBSOLETE then read each trace word. The counter records where the tracing */
1050 /* OBSOLETE stops, but there is no record of where it started, so we remember */
1051 /* OBSOLETE the PC when we resumed and then search backwards in the trace */
1052 /* OBSOLETE buffer for a word that includes that address. This is not perfect, */
1053 /* OBSOLETE because you will miss trace data if the resumption PC is the target */
1054 /* OBSOLETE of a branch. (The value of the buffer counter is semi-random, any */
1055 /* OBSOLETE trace data from a previous program stop is gone.) */ */
1057 /* OBSOLETE /* The address of the last word recorded in the trace buffer. */ */
1059 /* OBSOLETE #define DBBC_ADDR (0xd80000) */
1061 /* OBSOLETE /* The base of the trace buffer, at least for the "Board_0". */ */
1063 /* OBSOLETE #define TRACE_BUFFER_BASE (0xf40000) */
1065 /* OBSOLETE static void trace_command (char *, int); */
1067 /* OBSOLETE static void untrace_command (char *, int); */
1069 /* OBSOLETE static void trace_info (char *, int); */
1071 /* OBSOLETE static void tdisassemble_command (char *, int); */
1073 /* OBSOLETE static void display_trace (int, int); */
1075 /* OBSOLETE /* True when instruction traces are being collected. */ */
1077 /* OBSOLETE static int tracing; */
1079 /* OBSOLETE /* Remembered PC. */ */
1081 /* OBSOLETE static CORE_ADDR last_pc; */
1083 /* OBSOLETE /* True when trace output should be displayed whenever program stops. */ */
1085 /* OBSOLETE static int trace_display; */
1087 /* OBSOLETE /* True when trace listing should include source lines. */ */
1089 /* OBSOLETE static int default_trace_show_source = 1; */
1091 /* OBSOLETE struct trace_buffer */
1093 /* OBSOLETE int size; */
1094 /* OBSOLETE short *counts; */
1095 /* OBSOLETE CORE_ADDR *addrs; */
1097 /* OBSOLETE trace_data; */
1099 /* OBSOLETE static void */
1100 /* OBSOLETE trace_command (char *args, int from_tty) */
1102 /* OBSOLETE /* Clear the host-side trace buffer, allocating space if needed. */ */
1103 /* OBSOLETE trace_data.size = 0; */
1104 /* OBSOLETE if (trace_data.counts == NULL) */
1105 /* OBSOLETE trace_data.counts = (short *) xmalloc (65536 * sizeof (short)); */
1106 /* OBSOLETE if (trace_data.addrs == NULL) */
1107 /* OBSOLETE trace_data.addrs = (CORE_ADDR *) xmalloc (65536 * sizeof (CORE_ADDR)); */
1109 /* OBSOLETE tracing = 1; */
1111 /* OBSOLETE printf_filtered ("Tracing is now on.\n"); */
1114 /* OBSOLETE static void */
1115 /* OBSOLETE untrace_command (char *args, int from_tty) */
1117 /* OBSOLETE tracing = 0; */
1119 /* OBSOLETE printf_filtered ("Tracing is now off.\n"); */
1122 /* OBSOLETE static void */
1123 /* OBSOLETE trace_info (char *args, int from_tty) */
1125 /* OBSOLETE int i; */
1127 /* OBSOLETE if (trace_data.size) */
1129 /* OBSOLETE printf_filtered ("%d entries in trace buffer:\n", trace_data.size); */
1131 /* OBSOLETE for (i = 0; i < trace_data.size; ++i) */
1133 /* OBSOLETE printf_filtered ("%d: %d instruction%s at 0x%s\n", */
1134 /* OBSOLETE i, trace_data.counts[i], */
1135 /* OBSOLETE (trace_data.counts[i] == 1 ? "" : "s"), */
1136 /* OBSOLETE paddr_nz (trace_data.addrs[i])); */
1140 /* OBSOLETE printf_filtered ("No entries in trace buffer.\n"); */
1142 /* OBSOLETE printf_filtered ("Tracing is currently %s.\n", (tracing ? "on" : "off")); */
1145 /* OBSOLETE /* Print the instruction at address MEMADDR in debugged memory, */
1146 /* OBSOLETE on STREAM. Returns length of the instruction, in bytes. */ */
1148 /* OBSOLETE static int */
1149 /* OBSOLETE print_insn (CORE_ADDR memaddr, struct ui_file *stream) */
1151 /* OBSOLETE /* If there's no disassembler, something is very wrong. */ */
1152 /* OBSOLETE if (tm_print_insn == NULL) */
1153 /* OBSOLETE internal_error (__FILE__, __LINE__, */
1154 /* OBSOLETE "print_insn: no disassembler"); */
1156 /* OBSOLETE if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) */
1157 /* OBSOLETE tm_print_insn_info.endian = BFD_ENDIAN_BIG; */
1159 /* OBSOLETE tm_print_insn_info.endian = BFD_ENDIAN_LITTLE; */
1160 /* OBSOLETE return TARGET_PRINT_INSN (memaddr, &tm_print_insn_info); */
1164 /* OBSOLETE d30v_eva_prepare_to_trace (void) */
1166 /* OBSOLETE if (!tracing) */
1167 /* OBSOLETE return; */
1169 /* OBSOLETE last_pc = read_register (PC_REGNUM); */
1172 /* OBSOLETE /* Collect trace data from the target board and format it into a form */
1173 /* OBSOLETE more useful for display. */ */
1176 /* OBSOLETE d30v_eva_get_trace_data (void) */
1178 /* OBSOLETE int count, i, j, oldsize; */
1179 /* OBSOLETE int trace_addr, trace_seg, trace_cnt, next_cnt; */
1180 /* OBSOLETE unsigned int last_trace, trace_word, next_word; */
1181 /* OBSOLETE unsigned int *tmpspace; */
1183 /* OBSOLETE if (!tracing) */
1184 /* OBSOLETE return; */
1186 /* OBSOLETE tmpspace = xmalloc (65536 * sizeof (unsigned int)); */
1188 /* OBSOLETE last_trace = read_memory_unsigned_integer (DBBC_ADDR, 2) << 2; */
1190 /* OBSOLETE /* Collect buffer contents from the target, stopping when we reach */
1191 /* OBSOLETE the word recorded when execution resumed. */ */
1193 /* OBSOLETE count = 0; */
1194 /* OBSOLETE while (last_trace > 0) */
1196 /* OBSOLETE QUIT; */
1197 /* OBSOLETE trace_word = */
1198 /* OBSOLETE read_memory_unsigned_integer (TRACE_BUFFER_BASE + last_trace, 4); */
1199 /* OBSOLETE trace_addr = trace_word & 0xffff; */
1200 /* OBSOLETE last_trace -= 4; */
1201 /* OBSOLETE /* Ignore an apparently nonsensical entry. */ */
1202 /* OBSOLETE if (trace_addr == 0xffd5) */
1203 /* OBSOLETE continue; */
1204 /* OBSOLETE tmpspace[count++] = trace_word; */
1205 /* OBSOLETE if (trace_addr == last_pc) */
1206 /* OBSOLETE break; */
1207 /* OBSOLETE if (count > 65535) */
1208 /* OBSOLETE break; */
1211 /* OBSOLETE /* Move the data to the host-side trace buffer, adjusting counts to */
1212 /* OBSOLETE include the last instruction executed and transforming the address */
1213 /* OBSOLETE into something that GDB likes. */ */
1215 /* OBSOLETE for (i = 0; i < count; ++i) */
1217 /* OBSOLETE trace_word = tmpspace[i]; */
1218 /* OBSOLETE next_word = ((i == 0) ? 0 : tmpspace[i - 1]); */
1219 /* OBSOLETE trace_addr = trace_word & 0xffff; */
1220 /* OBSOLETE next_cnt = (next_word >> 24) & 0xff; */
1221 /* OBSOLETE j = trace_data.size + count - i - 1; */
1222 /* OBSOLETE trace_data.addrs[j] = (trace_addr << 2) + 0x1000000; */
1223 /* OBSOLETE trace_data.counts[j] = next_cnt + 1; */
1226 /* OBSOLETE oldsize = trace_data.size; */
1227 /* OBSOLETE trace_data.size += count; */
1229 /* OBSOLETE xfree (tmpspace); */
1231 /* OBSOLETE if (trace_display) */
1232 /* OBSOLETE display_trace (oldsize, trace_data.size); */
1235 /* OBSOLETE static void */
1236 /* OBSOLETE tdisassemble_command (char *arg, int from_tty) */
1238 /* OBSOLETE int i, count; */
1239 /* OBSOLETE CORE_ADDR low, high; */
1240 /* OBSOLETE char *space_index; */
1242 /* OBSOLETE if (!arg) */
1244 /* OBSOLETE low = 0; */
1245 /* OBSOLETE high = trace_data.size; */
1247 /* OBSOLETE else if (!(space_index = (char *) strchr (arg, ' '))) */
1249 /* OBSOLETE low = parse_and_eval_address (arg); */
1250 /* OBSOLETE high = low + 5; */
1254 /* OBSOLETE /* Two arguments. */ */
1255 /* OBSOLETE *space_index = '\0'; */
1256 /* OBSOLETE low = parse_and_eval_address (arg); */
1257 /* OBSOLETE high = parse_and_eval_address (space_index + 1); */
1258 /* OBSOLETE if (high < low) */
1259 /* OBSOLETE high = low; */
1262 /* OBSOLETE printf_filtered ("Dump of trace from %s to %s:\n", */
1263 /* OBSOLETE paddr_u (low), */
1264 /* OBSOLETE paddr_u (high)); */
1266 /* OBSOLETE display_trace (low, high); */
1268 /* OBSOLETE printf_filtered ("End of trace dump.\n"); */
1269 /* OBSOLETE gdb_flush (gdb_stdout); */
1272 /* OBSOLETE static void */
1273 /* OBSOLETE display_trace (int low, int high) */
1275 /* OBSOLETE int i, count, trace_show_source, first, suppress; */
1276 /* OBSOLETE CORE_ADDR next_address; */
1278 /* OBSOLETE trace_show_source = default_trace_show_source; */
1279 /* OBSOLETE if (!have_full_symbols () && !have_partial_symbols ()) */
1281 /* OBSOLETE trace_show_source = 0; */
1282 /* OBSOLETE printf_filtered ("No symbol table is loaded. Use the \"file\" command.\n"); */
1283 /* OBSOLETE printf_filtered ("Trace will not display any source.\n"); */
1286 /* OBSOLETE first = 1; */
1287 /* OBSOLETE suppress = 0; */
1288 /* OBSOLETE for (i = low; i < high; ++i) */
1290 /* OBSOLETE next_address = trace_data.addrs[i]; */
1291 /* OBSOLETE count = trace_data.counts[i]; */
1292 /* OBSOLETE while (count-- > 0) */
1294 /* OBSOLETE QUIT; */
1295 /* OBSOLETE if (trace_show_source) */
1297 /* OBSOLETE struct symtab_and_line sal, sal_prev; */
1299 /* OBSOLETE sal_prev = find_pc_line (next_address - 4, 0); */
1300 /* OBSOLETE sal = find_pc_line (next_address, 0); */
1302 /* OBSOLETE if (sal.symtab) */
1304 /* OBSOLETE if (first || sal.line != sal_prev.line) */
1305 /* OBSOLETE print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); */
1306 /* OBSOLETE suppress = 0; */
1310 /* OBSOLETE if (!suppress) */
1311 /* OBSOLETE /* FIXME-32x64--assumes sal.pc fits in long. */ */
1312 /* OBSOLETE printf_filtered ("No source file for address %s.\n", */
1313 /* OBSOLETE local_hex_string ((unsigned long) sal.pc)); */
1314 /* OBSOLETE suppress = 1; */
1317 /* OBSOLETE first = 0; */
1318 /* OBSOLETE print_address (next_address, gdb_stdout); */
1319 /* OBSOLETE printf_filtered (":"); */
1320 /* OBSOLETE printf_filtered ("\t"); */
1321 /* OBSOLETE wrap_here (" "); */
1322 /* OBSOLETE next_address = next_address + print_insn (next_address, gdb_stdout); */
1323 /* OBSOLETE printf_filtered ("\n"); */
1324 /* OBSOLETE gdb_flush (gdb_stdout); */
1329 /* OBSOLETE extern void (*target_resume_hook) (void); */
1330 /* OBSOLETE extern void (*target_wait_loop_hook) (void); */
1333 /* OBSOLETE _initialize_d30v_tdep (void) */
1335 /* OBSOLETE tm_print_insn = print_insn_d30v; */
1337 /* OBSOLETE target_resume_hook = d30v_eva_prepare_to_trace; */
1338 /* OBSOLETE target_wait_loop_hook = d30v_eva_get_trace_data; */
1340 /* OBSOLETE add_info ("flags", print_flags_command, "Print d30v flags."); */
1342 /* OBSOLETE add_com ("trace", class_support, trace_command, */
1343 /* OBSOLETE "Enable tracing of instruction execution."); */
1345 /* OBSOLETE add_com ("untrace", class_support, untrace_command, */
1346 /* OBSOLETE "Disable tracing of instruction execution."); */
1348 /* OBSOLETE add_com ("tdisassemble", class_vars, tdisassemble_command, */
1349 /* OBSOLETE "Disassemble the trace buffer.\n\ */
1350 /* OBSOLETE Two optional arguments specify a range of trace buffer entries\n\ */
1351 /* OBSOLETE as reported by info trace (NOT addresses!)."); */
1353 /* OBSOLETE add_info ("trace", trace_info, */
1354 /* OBSOLETE "Display info about the trace data buffer."); */
1356 /* OBSOLETE add_show_from_set (add_set_cmd ("tracedisplay", no_class, */
1357 /* OBSOLETE var_integer, (char *) &trace_display, */
1358 /* OBSOLETE "Set automatic display of trace.\n", &setlist), */
1359 /* OBSOLETE &showlist); */
1360 /* OBSOLETE add_show_from_set (add_set_cmd ("tracesource", no_class, */
1361 /* OBSOLETE var_integer, (char *) &default_trace_show_source, */
1362 /* OBSOLETE "Set display of source code with trace.\n", &setlist), */
1363 /* OBSOLETE &showlist); */
This page took 0.060241 seconds and 4 git commands to generate.