| 1 | /* Pyramid target-dependent code for GDB. |
| 2 | Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GDB. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 19 | |
| 20 | #include "defs.h" |
| 21 | |
| 22 | /*** Prettier register printing. ***/ |
| 23 | |
| 24 | /* Print registers in the same format as pyramid's dbx, adb, sdb. */ |
| 25 | pyr_print_registers(reg_buf, regnum) |
| 26 | long *reg_buf[]; |
| 27 | { |
| 28 | register int regno; |
| 29 | int usp, ksp; |
| 30 | struct user u; |
| 31 | |
| 32 | for (regno = 0; regno < 16; regno++) { |
| 33 | printf_unfiltered/*_filtered*/ ("%6.6s: %8x %6.6s: %8x %6s: %8x %6s: %8x\n", |
| 34 | reg_names[regno], reg_buf[regno], |
| 35 | reg_names[regno+16], reg_buf[regno+16], |
| 36 | reg_names[regno+32], reg_buf[regno+32], |
| 37 | reg_names[regno+48], reg_buf[regno+48]); |
| 38 | } |
| 39 | usp = ptrace (3, inferior_pid, |
| 40 | (PTRACE_ARG3_TYPE) ((char *)&u.u_pcb.pcb_usp) - |
| 41 | ((char *)&u), 0); |
| 42 | ksp = ptrace (3, inferior_pid, |
| 43 | (PTRACE_ARG3_TYPE) ((char *)&u.u_pcb.pcb_ksp) - |
| 44 | ((char *)&u), 0); |
| 45 | printf_unfiltered/*_filtered*/ ("\n%6.6s: %8x %6.6s: %8x (%08x) %6.6s %8x\n", |
| 46 | reg_names[CSP_REGNUM],reg_buf[CSP_REGNUM], |
| 47 | reg_names[KSP_REGNUM], reg_buf[KSP_REGNUM], ksp, |
| 48 | "usp", usp); |
| 49 | } |
| 50 | |
| 51 | /* Print the register regnum, or all registers if regnum is -1. |
| 52 | fpregs is currently ignored. */ |
| 53 | |
| 54 | pyr_do_registers_info (regnum, fpregs) |
| 55 | int regnum; |
| 56 | int fpregs; |
| 57 | { |
| 58 | /* On a pyr, we know a virtual register can always fit in an long. |
| 59 | Here (and elsewhere) we take advantage of that. Yuk. */ |
| 60 | long raw_regs[MAX_REGISTER_RAW_SIZE*NUM_REGS]; |
| 61 | register int i; |
| 62 | |
| 63 | for (i = 0 ; i < 64 ; i++) { |
| 64 | read_relative_register_raw_bytes(i, raw_regs+i); |
| 65 | } |
| 66 | if (regnum == -1) |
| 67 | pyr_print_registers (raw_regs, regnum); |
| 68 | else |
| 69 | for (i = 0; i < NUM_REGS; i++) |
| 70 | if (i == regnum) { |
| 71 | long val = raw_regs[i]; |
| 72 | |
| 73 | fputs_filtered (reg_names[i], stdout); |
| 74 | printf_filtered(":"); |
| 75 | print_spaces_filtered (6 - strlen (reg_names[i]), stdout); |
| 76 | if (val == 0) |
| 77 | printf_filtered ("0"); |
| 78 | else |
| 79 | printf_filtered ("%s %d", local_hex_string_custom(val,"08"), val); |
| 80 | printf_filtered("\n"); |
| 81 | } |
| 82 | } |
| 83 | \f |
| 84 | /*** Debugging editions of various macros from m-pyr.h ****/ |
| 85 | |
| 86 | CORE_ADDR frame_locals_address (frame) |
| 87 | FRAME frame; |
| 88 | { |
| 89 | register int addr = find_saved_register (frame,CFP_REGNUM); |
| 90 | register int result = read_memory_integer (addr, 4); |
| 91 | #ifdef PYRAMID_CONTROL_FRAME_DEBUGGING |
| 92 | fprintf_unfiltered (stderr, |
| 93 | "\t[[..frame_locals:%8x, %s= %x @%x fcfp= %x foo= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n", |
| 94 | frame->frame, |
| 95 | reg_names[CFP_REGNUM], |
| 96 | result, addr, |
| 97 | frame->frame_cfp, (CFP_REGNUM), |
| 98 | |
| 99 | |
| 100 | read_register(13), read_register(29), read_register(61), |
| 101 | find_saved_register(frame, 61)); |
| 102 | #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ |
| 103 | |
| 104 | /* FIXME: I thought read_register (CFP_REGNUM) should be the right answer; |
| 105 | or at least CFP_REGNUM relative to FRAME (ie, result). |
| 106 | There seems to be a bug in the way the innermost frame is set up. */ |
| 107 | |
| 108 | return ((frame->next) ? result: frame->frame_cfp); |
| 109 | } |
| 110 | |
| 111 | CORE_ADDR frame_args_addr (frame) |
| 112 | FRAME frame; |
| 113 | { |
| 114 | register int addr = find_saved_register (frame,CFP_REGNUM); |
| 115 | register int result = read_memory_integer (addr, 4); |
| 116 | |
| 117 | #ifdef PYRAMID_CONTROL_FRAME_DEBUGGING |
| 118 | fprintf_unfiltered (stderr, |
| 119 | "\t[[..frame_args:%8x, %s= %x @%x fcfp= %x r_r= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n", |
| 120 | frame->frame, |
| 121 | reg_names[CFP_REGNUM], |
| 122 | result, addr, |
| 123 | frame->frame_cfp, read_register(CFP_REGNUM), |
| 124 | |
| 125 | read_register(13), read_register(29), read_register(61), |
| 126 | find_saved_register(frame, 61)); |
| 127 | #endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ |
| 128 | |
| 129 | /* FIXME: I thought read_register (CFP_REGNUM) should be the right answer; |
| 130 | or at least CFP_REGNUM relative to FRAME (ie, result). |
| 131 | There seems to be a bug in the way the innermost frame is set up. */ |
| 132 | return ((frame->next) ? result: frame->frame_cfp); |
| 133 | } |