| 1 | /* Target-dependent code for Motorola 68HC11 |
| 2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
| 3 | Contributed by Stephane Carrez, stcarrez@worldnet.fr |
| 4 | |
| 5 | This file is part of GDB. |
| 6 | |
| 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. |
| 11 | |
| 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. |
| 16 | |
| 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, Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | |
| 22 | #include "defs.h" |
| 23 | #include "frame.h" |
| 24 | #include "obstack.h" |
| 25 | #include "symtab.h" |
| 26 | #include "gdbtypes.h" |
| 27 | #include "gdbcmd.h" |
| 28 | #include "gdbcore.h" |
| 29 | #include "gdb_string.h" |
| 30 | #include "value.h" |
| 31 | #include "inferior.h" |
| 32 | #include "dis-asm.h" |
| 33 | #include "symfile.h" |
| 34 | #include "objfiles.h" |
| 35 | #include "arch-utils.h" |
| 36 | |
| 37 | #include "target.h" |
| 38 | #include "opcode/m68hc11.h" |
| 39 | |
| 40 | /* Register numbers of various important registers. |
| 41 | Note that some of these values are "real" register numbers, |
| 42 | and correspond to the general registers of the machine, |
| 43 | and some are "phony" register numbers which are too large |
| 44 | to be actual register numbers as far as the user is concerned |
| 45 | but do serve to get the desired values when passed to read_register. */ |
| 46 | |
| 47 | #define HARD_X_REGNUM 0 |
| 48 | #define HARD_D_REGNUM 1 |
| 49 | #define HARD_Y_REGNUM 2 |
| 50 | #define HARD_SP_REGNUM 3 |
| 51 | #define HARD_PC_REGNUM 4 |
| 52 | |
| 53 | #define HARD_A_REGNUM 5 |
| 54 | #define HARD_B_REGNUM 6 |
| 55 | #define HARD_CCR_REGNUM 7 |
| 56 | #define M68HC11_LAST_HARD_REG (HARD_CCR_REGNUM) |
| 57 | |
| 58 | /* Z is replaced by X or Y by gcc during machine reorg. |
| 59 | ??? There is no way to get it and even know whether |
| 60 | it's in X or Y or in ZS. */ |
| 61 | #define SOFT_Z_REGNUM 8 |
| 62 | |
| 63 | /* Soft registers. These registers are special. There are treated |
| 64 | like normal hard registers by gcc and gdb (ie, within dwarf2 info). |
| 65 | They are physically located in memory. */ |
| 66 | #define SOFT_FP_REGNUM 9 |
| 67 | #define SOFT_TMP_REGNUM 10 |
| 68 | #define SOFT_ZS_REGNUM 11 |
| 69 | #define SOFT_XY_REGNUM 12 |
| 70 | #define SOFT_D1_REGNUM 13 |
| 71 | #define SOFT_D32_REGNUM (SOFT_D1_REGNUM+31) |
| 72 | #define M68HC11_MAX_SOFT_REGS 32 |
| 73 | |
| 74 | #define M68HC11_NUM_REGS (8) |
| 75 | #define M68HC11_NUM_PSEUDO_REGS (M68HC11_MAX_SOFT_REGS+5) |
| 76 | #define M68HC11_ALL_REGS (M68HC11_NUM_REGS+M68HC11_NUM_PSEUDO_REGS) |
| 77 | |
| 78 | #define M68HC11_REG_SIZE (2) |
| 79 | |
| 80 | struct gdbarch_tdep |
| 81 | { |
| 82 | /* from the elf header */ |
| 83 | int elf_flags; |
| 84 | }; |
| 85 | |
| 86 | struct frame_extra_info |
| 87 | { |
| 88 | int frame_reg; |
| 89 | CORE_ADDR return_pc; |
| 90 | CORE_ADDR dummy; |
| 91 | int frameless; |
| 92 | int size; |
| 93 | }; |
| 94 | |
| 95 | /* Table of registers for 68HC11. This includes the hard registers |
| 96 | and the soft registers used by GCC. */ |
| 97 | static char * |
| 98 | m68hc11_register_names[] = |
| 99 | { |
| 100 | "x", "d", "y", "sp", "pc", "a", "b", |
| 101 | "ccr", "z", "frame","tmp", "zs", "xy", |
| 102 | "d1", "d2", "d3", "d4", "d5", "d6", "d7", |
| 103 | "d8", "d9", "d10", "d11", "d12", "d13", "d14", |
| 104 | "d15", "d16", "d17", "d18", "d19", "d20", "d21", |
| 105 | "d22", "d23", "d24", "d25", "d26", "d27", "d28", |
| 106 | "d29", "d30", "d31", "d32" |
| 107 | }; |
| 108 | |
| 109 | struct m68hc11_soft_reg |
| 110 | { |
| 111 | const char *name; |
| 112 | CORE_ADDR addr; |
| 113 | }; |
| 114 | |
| 115 | static struct m68hc11_soft_reg soft_regs[M68HC11_ALL_REGS]; |
| 116 | |
| 117 | #define M68HC11_FP_ADDR soft_regs[SOFT_FP_REGNUM].addr |
| 118 | |
| 119 | static int soft_min_addr; |
| 120 | static int soft_max_addr; |
| 121 | static int soft_reg_initialized = 0; |
| 122 | |
| 123 | /* Stack pointer correction value. For 68hc11, the stack pointer points |
| 124 | to the next push location. An offset of 1 must be applied to obtain |
| 125 | the address where the last value is saved. For 68hc12, the stack |
| 126 | pointer points to the last value pushed. No offset is necessary. */ |
| 127 | static int stack_correction = 1; |
| 128 | |
| 129 | /* Look in the symbol table for the address of a pseudo register |
| 130 | in memory. If we don't find it, pretend the register is not used |
| 131 | and not available. */ |
| 132 | static void |
| 133 | m68hc11_get_register_info (struct m68hc11_soft_reg *reg, const char *name) |
| 134 | { |
| 135 | struct minimal_symbol *msymbol; |
| 136 | |
| 137 | msymbol = lookup_minimal_symbol (name, NULL, NULL); |
| 138 | if (msymbol) |
| 139 | { |
| 140 | reg->addr = SYMBOL_VALUE_ADDRESS (msymbol); |
| 141 | reg->name = xstrdup (name); |
| 142 | |
| 143 | /* Keep track of the address range for soft registers. */ |
| 144 | if (reg->addr < (CORE_ADDR) soft_min_addr) |
| 145 | soft_min_addr = reg->addr; |
| 146 | if (reg->addr > (CORE_ADDR) soft_max_addr) |
| 147 | soft_max_addr = reg->addr; |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | reg->name = 0; |
| 152 | reg->addr = 0; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /* Initialize the table of soft register addresses according |
| 157 | to the symbol table. */ |
| 158 | static void |
| 159 | m68hc11_initialize_register_info (void) |
| 160 | { |
| 161 | int i; |
| 162 | |
| 163 | if (soft_reg_initialized) |
| 164 | return; |
| 165 | |
| 166 | soft_min_addr = INT_MAX; |
| 167 | soft_max_addr = 0; |
| 168 | for (i = 0; i < M68HC11_ALL_REGS; i++) |
| 169 | { |
| 170 | soft_regs[i].name = 0; |
| 171 | } |
| 172 | |
| 173 | m68hc11_get_register_info (&soft_regs[SOFT_FP_REGNUM], "_.frame"); |
| 174 | m68hc11_get_register_info (&soft_regs[SOFT_TMP_REGNUM], "_.tmp"); |
| 175 | m68hc11_get_register_info (&soft_regs[SOFT_ZS_REGNUM], "_.z"); |
| 176 | soft_regs[SOFT_Z_REGNUM] = soft_regs[SOFT_ZS_REGNUM]; |
| 177 | m68hc11_get_register_info (&soft_regs[SOFT_XY_REGNUM], "_.xy"); |
| 178 | |
| 179 | for (i = SOFT_D1_REGNUM; i < M68HC11_MAX_SOFT_REGS; i++) |
| 180 | { |
| 181 | char buf[10]; |
| 182 | |
| 183 | sprintf (buf, "_.d%d", i - SOFT_D1_REGNUM + 1); |
| 184 | m68hc11_get_register_info (&soft_regs[i], buf); |
| 185 | } |
| 186 | |
| 187 | if (soft_regs[SOFT_FP_REGNUM].name == 0) |
| 188 | { |
| 189 | warning ("No frame soft register found in the symbol table.\n"); |
| 190 | warning ("Stack backtrace will not work.\n"); |
| 191 | } |
| 192 | soft_reg_initialized = 1; |
| 193 | } |
| 194 | |
| 195 | /* Given an address in memory, return the soft register number if |
| 196 | that address corresponds to a soft register. Returns -1 if not. */ |
| 197 | static int |
| 198 | m68hc11_which_soft_register (CORE_ADDR addr) |
| 199 | { |
| 200 | int i; |
| 201 | |
| 202 | if (addr < soft_min_addr || addr > soft_max_addr) |
| 203 | return -1; |
| 204 | |
| 205 | for (i = SOFT_FP_REGNUM; i < M68HC11_ALL_REGS; i++) |
| 206 | { |
| 207 | if (soft_regs[i].name && soft_regs[i].addr == addr) |
| 208 | return i; |
| 209 | } |
| 210 | return -1; |
| 211 | } |
| 212 | |
| 213 | /* Fetch a pseudo register. The 68hc11 soft registers are treated like |
| 214 | pseudo registers. They are located in memory. Translate the register |
| 215 | fetch into a memory read. */ |
| 216 | void |
| 217 | m68hc11_fetch_pseudo_register (int regno) |
| 218 | { |
| 219 | char buf[MAX_REGISTER_RAW_SIZE]; |
| 220 | |
| 221 | m68hc11_initialize_register_info (); |
| 222 | |
| 223 | /* Fetch a soft register: translate into a memory read. */ |
| 224 | if (soft_regs[regno].name) |
| 225 | { |
| 226 | target_read_memory (soft_regs[regno].addr, buf, 2); |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | memset (buf, 0, 2); |
| 231 | } |
| 232 | supply_register (regno, buf); |
| 233 | } |
| 234 | |
| 235 | /* Store a pseudo register. Translate the register store |
| 236 | into a memory write. */ |
| 237 | static void |
| 238 | m68hc11_store_pseudo_register (int regno) |
| 239 | { |
| 240 | m68hc11_initialize_register_info (); |
| 241 | |
| 242 | /* Store a soft register: translate into a memory write. */ |
| 243 | if (soft_regs[regno].name) |
| 244 | { |
| 245 | char buf[MAX_REGISTER_RAW_SIZE]; |
| 246 | |
| 247 | read_register_gen (regno, buf); |
| 248 | target_write_memory (soft_regs[regno].addr, buf, 2); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | static char * |
| 253 | m68hc11_register_name (int reg_nr) |
| 254 | { |
| 255 | if (reg_nr < 0) |
| 256 | return NULL; |
| 257 | if (reg_nr >= M68HC11_ALL_REGS) |
| 258 | return NULL; |
| 259 | |
| 260 | /* If we don't know the address of a soft register, pretend it |
| 261 | does not exist. */ |
| 262 | if (reg_nr > M68HC11_LAST_HARD_REG && soft_regs[reg_nr].name == 0) |
| 263 | return NULL; |
| 264 | return m68hc11_register_names[reg_nr]; |
| 265 | } |
| 266 | |
| 267 | static unsigned char * |
| 268 | m68hc11_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) |
| 269 | { |
| 270 | static unsigned char breakpoint[] = {0x0}; |
| 271 | |
| 272 | *lenptr = sizeof (breakpoint); |
| 273 | return breakpoint; |
| 274 | } |
| 275 | |
| 276 | /* Immediately after a function call, return the saved pc before the frame |
| 277 | is setup. */ |
| 278 | |
| 279 | static CORE_ADDR |
| 280 | m68hc11_saved_pc_after_call (struct frame_info *frame) |
| 281 | { |
| 282 | CORE_ADDR addr; |
| 283 | |
| 284 | addr = read_register (HARD_SP_REGNUM) + stack_correction; |
| 285 | addr &= 0x0ffff; |
| 286 | return read_memory_integer (addr, 2) & 0x0FFFF; |
| 287 | } |
| 288 | |
| 289 | static CORE_ADDR |
| 290 | m68hc11_frame_saved_pc (struct frame_info *frame) |
| 291 | { |
| 292 | return frame->extra_info->return_pc; |
| 293 | } |
| 294 | |
| 295 | static CORE_ADDR |
| 296 | m68hc11_frame_args_address (struct frame_info *frame) |
| 297 | { |
| 298 | return frame->frame; |
| 299 | } |
| 300 | |
| 301 | static CORE_ADDR |
| 302 | m68hc11_frame_locals_address (struct frame_info *frame) |
| 303 | { |
| 304 | return frame->frame; |
| 305 | } |
| 306 | |
| 307 | /* Discard from the stack the innermost frame, restoring all saved |
| 308 | registers. */ |
| 309 | |
| 310 | static void |
| 311 | m68hc11_pop_frame (void) |
| 312 | { |
| 313 | register struct frame_info *frame = get_current_frame (); |
| 314 | register CORE_ADDR fp, sp; |
| 315 | register int regnum; |
| 316 | |
| 317 | if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)) |
| 318 | generic_pop_dummy_frame (); |
| 319 | else |
| 320 | { |
| 321 | fp = FRAME_FP (frame); |
| 322 | FRAME_INIT_SAVED_REGS (frame); |
| 323 | |
| 324 | /* Copy regs from where they were saved in the frame. */ |
| 325 | for (regnum = 0; regnum < M68HC11_ALL_REGS; regnum++) |
| 326 | if (frame->saved_regs[regnum]) |
| 327 | write_register (regnum, |
| 328 | read_memory_integer (frame->saved_regs[regnum], 2)); |
| 329 | |
| 330 | write_register (HARD_PC_REGNUM, frame->extra_info->return_pc); |
| 331 | sp = fp + frame->extra_info->size; |
| 332 | write_register (HARD_SP_REGNUM, sp); |
| 333 | } |
| 334 | flush_cached_frames (); |
| 335 | } |
| 336 | |
| 337 | /* Analyze the function prologue to find some information |
| 338 | about the function: |
| 339 | - the PC of the first line (for m68hc11_skip_prologue) |
| 340 | - the offset of the previous frame saved address (from current frame) |
| 341 | - the soft registers which are pushed. */ |
| 342 | static void |
| 343 | m68hc11_guess_from_prologue (CORE_ADDR pc, CORE_ADDR fp, |
| 344 | CORE_ADDR *first_line, |
| 345 | int *frame_offset, CORE_ADDR *pushed_regs) |
| 346 | { |
| 347 | CORE_ADDR save_addr; |
| 348 | CORE_ADDR func_end; |
| 349 | unsigned char op0, op1, op2; |
| 350 | int add_sp_mode; |
| 351 | int sp_adjust = 0; |
| 352 | int size; |
| 353 | int found_frame_point; |
| 354 | int saved_reg; |
| 355 | CORE_ADDR first_pc; |
| 356 | |
| 357 | first_pc = get_pc_function_start (pc); |
| 358 | size = 0; |
| 359 | |
| 360 | m68hc11_initialize_register_info (); |
| 361 | if (first_pc == 0) |
| 362 | { |
| 363 | *frame_offset = 0; |
| 364 | *first_line = pc; |
| 365 | return; |
| 366 | } |
| 367 | |
| 368 | #define OP_PAGE2 (0x18) |
| 369 | #define OP_LDX (0xde) |
| 370 | #define OP_LDY (0xde) |
| 371 | #define OP_PSHX (0x3c) |
| 372 | #define OP_PSHY (0x3c) |
| 373 | #define OP_STS (0x9f) |
| 374 | #define OP_TSX (0x30) |
| 375 | #define OP_TSY (0x30) |
| 376 | #define OP_XGDX (0x8f) |
| 377 | #define OP_XGDY (0x8f) |
| 378 | #define OP_ADDD (0xc3) |
| 379 | #define OP_TXS (0x35) |
| 380 | #define OP_TYS (0x35) |
| 381 | #define OP_DES (0x34) |
| 382 | |
| 383 | /* The 68hc11 stack is as follows: |
| 384 | |
| 385 | |
| 386 | | | |
| 387 | +-----------+ |
| 388 | | | |
| 389 | | args | |
| 390 | | | |
| 391 | +-----------+ |
| 392 | | PC-return | |
| 393 | +-----------+ |
| 394 | | Old frame | |
| 395 | +-----------+ |
| 396 | | | |
| 397 | | Locals | |
| 398 | | | |
| 399 | +-----------+ <--- current frame |
| 400 | | | |
| 401 | |
| 402 | With most processors (like 68K) the previous frame can be computed |
| 403 | easily because it is always at a fixed offset (see link/unlink). |
| 404 | That is, locals are accessed with negative offsets, arguments are |
| 405 | accessed with positive ones. Since 68hc11 only supports offsets |
| 406 | in the range [0..255], the frame is defined at the bottom of |
| 407 | locals (see picture). |
| 408 | |
| 409 | The purpose of the analysis made here is to find out the size |
| 410 | of locals in this function. An alternative to this is to use |
| 411 | DWARF2 info. This would be better but I don't know how to |
| 412 | access dwarf2 debug from this function. |
| 413 | |
| 414 | Walk from the function entry point to the point where we save |
| 415 | the frame. While walking instructions, compute the size of bytes |
| 416 | which are pushed. This gives us the index to access the previous |
| 417 | frame. |
| 418 | |
| 419 | We limit the search to 128 bytes so that the algorithm is bounded |
| 420 | in case of random and wrong code. We also stop and abort if |
| 421 | we find an instruction which is not supposed to appear in the |
| 422 | prologue (as generated by gcc 2.95, 2.96). |
| 423 | */ |
| 424 | pc = first_pc; |
| 425 | func_end = pc + 128; |
| 426 | add_sp_mode = 0; |
| 427 | found_frame_point = 0; |
| 428 | while (pc + 2 < func_end) |
| 429 | { |
| 430 | op0 = read_memory_unsigned_integer (pc, 1); |
| 431 | op1 = read_memory_unsigned_integer (pc + 1, 1); |
| 432 | op2 = read_memory_unsigned_integer (pc + 2, 1); |
| 433 | |
| 434 | /* ldx *frame */ |
| 435 | if (op0 == OP_LDX && op1 == M68HC11_FP_ADDR) |
| 436 | { |
| 437 | pc += 2; |
| 438 | } |
| 439 | |
| 440 | /* ldy *frame */ |
| 441 | else if (op0 == OP_PAGE2 && op1 == OP_LDY |
| 442 | && op2 == M68HC11_FP_ADDR) |
| 443 | { |
| 444 | pc += 3; |
| 445 | } |
| 446 | |
| 447 | /* pshx */ |
| 448 | else if (op0 == OP_PSHX) |
| 449 | { |
| 450 | pc += 1; |
| 451 | size += 2; |
| 452 | } |
| 453 | |
| 454 | /* pshy */ |
| 455 | else if (op0 == OP_PAGE2 && op1 == OP_PSHX) |
| 456 | { |
| 457 | pc += 2; |
| 458 | size += 2; |
| 459 | } |
| 460 | |
| 461 | /* sts *frame */ |
| 462 | else if (op0 == OP_STS && op1 == M68HC11_FP_ADDR) |
| 463 | { |
| 464 | found_frame_point = 1; |
| 465 | pc += 2; |
| 466 | break; |
| 467 | } |
| 468 | else if (op0 == OP_TSX && op1 == OP_XGDX) |
| 469 | { |
| 470 | add_sp_mode = 1; |
| 471 | pc += 2; |
| 472 | } |
| 473 | /* des to allocate 1 byte on the stack */ |
| 474 | else if (op0 == OP_DES) |
| 475 | { |
| 476 | pc += 1; |
| 477 | size += 1; |
| 478 | } |
| 479 | else if (op0 == OP_PAGE2 && op1 == OP_TSY && op2 == OP_PAGE2) |
| 480 | { |
| 481 | op0 = read_memory_unsigned_integer (pc + 3, 1); |
| 482 | if (op0 != OP_XGDY) |
| 483 | break; |
| 484 | |
| 485 | add_sp_mode = 2; |
| 486 | pc += 4; |
| 487 | } |
| 488 | else if (add_sp_mode && op0 == OP_ADDD) |
| 489 | { |
| 490 | sp_adjust = read_memory_unsigned_integer (pc + 1, 2); |
| 491 | if (sp_adjust & 0x8000) |
| 492 | sp_adjust |= 0xffff0000L; |
| 493 | |
| 494 | sp_adjust = -sp_adjust; |
| 495 | add_sp_mode |= 4; |
| 496 | pc += 3; |
| 497 | } |
| 498 | else if (add_sp_mode == (1 | 4) && op0 == OP_XGDX |
| 499 | && op1 == OP_TXS) |
| 500 | { |
| 501 | size += sp_adjust; |
| 502 | pc += 2; |
| 503 | add_sp_mode = 0; |
| 504 | } |
| 505 | else if (add_sp_mode == (2 | 4) && op0 == OP_PAGE2 |
| 506 | && op1 == OP_XGDY && op2 == OP_PAGE2) |
| 507 | { |
| 508 | op0 = read_memory_unsigned_integer (pc + 3, 1); |
| 509 | if (op0 != OP_TYS) |
| 510 | break; |
| 511 | |
| 512 | size += sp_adjust; |
| 513 | pc += 4; |
| 514 | add_sp_mode = 0; |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | break; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | if (found_frame_point == 0) |
| 523 | { |
| 524 | *frame_offset = 0; |
| 525 | } |
| 526 | else |
| 527 | { |
| 528 | *frame_offset = size; |
| 529 | } |
| 530 | |
| 531 | /* Now, look forward to see how many registers are pushed on the stack. |
| 532 | We look only for soft registers so there must be a first LDX *REG |
| 533 | before a PSHX. */ |
| 534 | saved_reg = -1; |
| 535 | save_addr = fp; |
| 536 | while (pc + 2 < func_end) |
| 537 | { |
| 538 | op0 = read_memory_unsigned_integer (pc, 1); |
| 539 | op1 = read_memory_unsigned_integer (pc + 1, 1); |
| 540 | op2 = read_memory_unsigned_integer (pc + 2, 1); |
| 541 | if (op0 == OP_LDX) |
| 542 | { |
| 543 | saved_reg = m68hc11_which_soft_register (op1); |
| 544 | if (saved_reg < 0 || saved_reg == SOFT_FP_REGNUM) |
| 545 | break; |
| 546 | |
| 547 | pc += 2; |
| 548 | } |
| 549 | else if (op0 == OP_PAGE2 && op1 == OP_LDY) |
| 550 | { |
| 551 | saved_reg = m68hc11_which_soft_register (op2); |
| 552 | if (saved_reg < 0 || saved_reg == SOFT_FP_REGNUM) |
| 553 | break; |
| 554 | |
| 555 | pc += 3; |
| 556 | } |
| 557 | else if (op0 == OP_PSHX) |
| 558 | { |
| 559 | /* If there was no load, this is a push for a function call. */ |
| 560 | if (saved_reg < 0 || saved_reg >= M68HC11_ALL_REGS) |
| 561 | break; |
| 562 | |
| 563 | /* Keep track of the address where that register is saved |
| 564 | on the stack. */ |
| 565 | save_addr -= 2; |
| 566 | if (pushed_regs) |
| 567 | pushed_regs[saved_reg] = save_addr; |
| 568 | |
| 569 | pc += 1; |
| 570 | saved_reg = -1; |
| 571 | } |
| 572 | else if (op0 == OP_PAGE2 && op1 == OP_PSHY) |
| 573 | { |
| 574 | if (saved_reg < 0 || saved_reg >= M68HC11_ALL_REGS) |
| 575 | break; |
| 576 | |
| 577 | /* Keep track of the address where that register is saved |
| 578 | on the stack. */ |
| 579 | save_addr -= 2; |
| 580 | if (pushed_regs) |
| 581 | pushed_regs[saved_reg] = save_addr; |
| 582 | |
| 583 | pc += 2; |
| 584 | saved_reg = -1; |
| 585 | } |
| 586 | else |
| 587 | { |
| 588 | break; |
| 589 | } |
| 590 | } |
| 591 | *first_line = pc; |
| 592 | } |
| 593 | |
| 594 | static CORE_ADDR |
| 595 | m68hc11_skip_prologue (CORE_ADDR pc) |
| 596 | { |
| 597 | CORE_ADDR func_addr, func_end; |
| 598 | struct symtab_and_line sal; |
| 599 | int frame_offset; |
| 600 | |
| 601 | /* If we have line debugging information, then the end of the |
| 602 | prologue should be the first assembly instruction of the |
| 603 | first source line. */ |
| 604 | if (find_pc_partial_function (pc, NULL, &func_addr, &func_end)) |
| 605 | { |
| 606 | sal = find_pc_line (func_addr, 0); |
| 607 | if (sal.end && sal.end < func_end) |
| 608 | return sal.end; |
| 609 | } |
| 610 | |
| 611 | m68hc11_guess_from_prologue (pc, 0, &pc, &frame_offset, 0); |
| 612 | return pc; |
| 613 | } |
| 614 | |
| 615 | /* Given a GDB frame, determine the address of the calling function's frame. |
| 616 | This will be used to create a new GDB frame struct, and then |
| 617 | INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame. |
| 618 | */ |
| 619 | |
| 620 | static CORE_ADDR |
| 621 | m68hc11_frame_chain (struct frame_info *frame) |
| 622 | { |
| 623 | CORE_ADDR addr; |
| 624 | |
| 625 | if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)) |
| 626 | return frame->frame; /* dummy frame same as caller's frame */ |
| 627 | |
| 628 | if (frame->extra_info->return_pc == 0 |
| 629 | || inside_entry_file (frame->extra_info->return_pc)) |
| 630 | return (CORE_ADDR) 0; |
| 631 | |
| 632 | if (frame->frame == 0) |
| 633 | { |
| 634 | return (CORE_ADDR) 0; |
| 635 | } |
| 636 | |
| 637 | addr = frame->frame + frame->extra_info->size + stack_correction - 2; |
| 638 | addr = read_memory_unsigned_integer (addr, 2) & 0x0FFFF; |
| 639 | if (addr == 0) |
| 640 | { |
| 641 | return (CORE_ADDR) 0; |
| 642 | } |
| 643 | |
| 644 | return addr; |
| 645 | } |
| 646 | |
| 647 | /* Put here the code to store, into a struct frame_saved_regs, the |
| 648 | addresses of the saved registers of frame described by FRAME_INFO. |
| 649 | This includes special registers such as pc and fp saved in special |
| 650 | ways in the stack frame. sp is even more special: the address we |
| 651 | return for it IS the sp for the next frame. */ |
| 652 | static void |
| 653 | m68hc11_frame_init_saved_regs (struct frame_info *fi) |
| 654 | { |
| 655 | CORE_ADDR pc; |
| 656 | CORE_ADDR addr; |
| 657 | |
| 658 | if (fi->saved_regs == NULL) |
| 659 | frame_saved_regs_zalloc (fi); |
| 660 | else |
| 661 | memset (fi->saved_regs, 0, sizeof (fi->saved_regs)); |
| 662 | |
| 663 | pc = fi->pc; |
| 664 | m68hc11_guess_from_prologue (pc, fi->frame, &pc, &fi->extra_info->size, |
| 665 | fi->saved_regs); |
| 666 | |
| 667 | addr = fi->frame + fi->extra_info->size + stack_correction; |
| 668 | fi->saved_regs[SOFT_FP_REGNUM] = addr - 2; |
| 669 | fi->saved_regs[HARD_SP_REGNUM] = addr; |
| 670 | fi->saved_regs[HARD_PC_REGNUM] = fi->saved_regs[HARD_SP_REGNUM]; |
| 671 | } |
| 672 | |
| 673 | static void |
| 674 | m68hc11_init_extra_frame_info (int fromleaf, struct frame_info *fi) |
| 675 | { |
| 676 | CORE_ADDR addr; |
| 677 | |
| 678 | fi->extra_info = (struct frame_extra_info *) |
| 679 | frame_obstack_alloc (sizeof (struct frame_extra_info)); |
| 680 | |
| 681 | if (fi->next) |
| 682 | fi->pc = FRAME_SAVED_PC (fi->next); |
| 683 | |
| 684 | m68hc11_frame_init_saved_regs (fi); |
| 685 | |
| 686 | if (fromleaf) |
| 687 | { |
| 688 | fi->extra_info->return_pc = m68hc11_saved_pc_after_call (fi); |
| 689 | } |
| 690 | else |
| 691 | { |
| 692 | addr = fi->frame + fi->extra_info->size + stack_correction; |
| 693 | addr = read_memory_unsigned_integer (addr, 2) & 0x0ffff; |
| 694 | fi->extra_info->return_pc = addr; |
| 695 | #if 0 |
| 696 | printf ("Pc@0x%04x, FR 0x%04x, size %d, read ret @0x%04x -> 0x%04x\n", |
| 697 | fi->pc, |
| 698 | fi->frame, fi->size, |
| 699 | addr & 0x0ffff, |
| 700 | fi->return_pc); |
| 701 | #endif |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | /* Same as 'info reg' but prints the registers in a different way. */ |
| 706 | static void |
| 707 | show_regs (char *args, int from_tty) |
| 708 | { |
| 709 | int ccr = read_register (HARD_CCR_REGNUM); |
| 710 | int i; |
| 711 | int nr; |
| 712 | |
| 713 | printf_filtered ("PC=%04x SP=%04x FP=%04x CCR=%02x %c%c%c%c%c%c%c%c\n", |
| 714 | (int) read_register (HARD_PC_REGNUM), |
| 715 | (int) read_register (HARD_SP_REGNUM), |
| 716 | (int) read_register (SOFT_FP_REGNUM), |
| 717 | ccr, |
| 718 | ccr & M6811_S_BIT ? 'S' : '-', |
| 719 | ccr & M6811_X_BIT ? 'X' : '-', |
| 720 | ccr & M6811_H_BIT ? 'H' : '-', |
| 721 | ccr & M6811_I_BIT ? 'I' : '-', |
| 722 | ccr & M6811_N_BIT ? 'N' : '-', |
| 723 | ccr & M6811_Z_BIT ? 'Z' : '-', |
| 724 | ccr & M6811_V_BIT ? 'V' : '-', |
| 725 | ccr & M6811_C_BIT ? 'C' : '-'); |
| 726 | |
| 727 | printf_filtered ("D=%04x IX=%04x IY=%04x\n", |
| 728 | (int) read_register (HARD_D_REGNUM), |
| 729 | (int) read_register (HARD_X_REGNUM), |
| 730 | (int) read_register (HARD_Y_REGNUM)); |
| 731 | |
| 732 | nr = 0; |
| 733 | for (i = SOFT_D1_REGNUM; i < M68HC11_ALL_REGS; i++) |
| 734 | { |
| 735 | /* Skip registers which are not defined in the symbol table. */ |
| 736 | if (soft_regs[i].name == 0) |
| 737 | continue; |
| 738 | |
| 739 | printf_filtered ("D%d=%04x", |
| 740 | i - SOFT_D1_REGNUM + 1, |
| 741 | (int) read_register (i)); |
| 742 | nr++; |
| 743 | if ((nr % 8) == 7) |
| 744 | printf_filtered ("\n"); |
| 745 | else |
| 746 | printf_filtered (" "); |
| 747 | } |
| 748 | if (nr && (nr % 8) != 7) |
| 749 | printf_filtered ("\n"); |
| 750 | } |
| 751 | |
| 752 | static CORE_ADDR |
| 753 | m68hc11_stack_align (CORE_ADDR addr) |
| 754 | { |
| 755 | return ((addr + 1) & -2); |
| 756 | } |
| 757 | |
| 758 | static CORE_ADDR |
| 759 | m68hc11_push_arguments (int nargs, |
| 760 | value_ptr *args, |
| 761 | CORE_ADDR sp, |
| 762 | int struct_return, |
| 763 | CORE_ADDR struct_addr) |
| 764 | { |
| 765 | int stack_alloc; |
| 766 | int argnum; |
| 767 | int first_stack_argnum; |
| 768 | int stack_offset; |
| 769 | struct type *type; |
| 770 | char *val; |
| 771 | int len; |
| 772 | |
| 773 | stack_alloc = 0; |
| 774 | first_stack_argnum = 0; |
| 775 | if (struct_return) |
| 776 | { |
| 777 | /* The struct is allocated on the stack and gdb used the stack |
| 778 | pointer for the address of that struct. We must apply the |
| 779 | stack offset on the address. */ |
| 780 | write_register (HARD_D_REGNUM, struct_addr + stack_correction); |
| 781 | } |
| 782 | else if (nargs > 0) |
| 783 | { |
| 784 | type = VALUE_TYPE (args[0]); |
| 785 | len = TYPE_LENGTH (type); |
| 786 | |
| 787 | /* First argument is passed in D and X registers. */ |
| 788 | if (len <= 4) |
| 789 | { |
| 790 | LONGEST v = extract_unsigned_integer (VALUE_CONTENTS (args[0]), len); |
| 791 | first_stack_argnum = 1; |
| 792 | write_register (HARD_D_REGNUM, v); |
| 793 | if (len > 2) |
| 794 | { |
| 795 | v >>= 16; |
| 796 | write_register (HARD_X_REGNUM, v); |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | for (argnum = first_stack_argnum; argnum < nargs; argnum++) |
| 801 | { |
| 802 | type = VALUE_TYPE (args[argnum]); |
| 803 | stack_alloc += (TYPE_LENGTH (type) + 1) & -2; |
| 804 | } |
| 805 | sp -= stack_alloc; |
| 806 | |
| 807 | stack_offset = stack_correction; |
| 808 | for (argnum = first_stack_argnum; argnum < nargs; argnum++) |
| 809 | { |
| 810 | type = VALUE_TYPE (args[argnum]); |
| 811 | len = TYPE_LENGTH (type); |
| 812 | |
| 813 | val = (char*) VALUE_CONTENTS (args[argnum]); |
| 814 | write_memory (sp + stack_offset, val, len); |
| 815 | stack_offset += len; |
| 816 | if (len & 1) |
| 817 | { |
| 818 | static char zero = 0; |
| 819 | |
| 820 | write_memory (sp + stack_offset, &zero, 1); |
| 821 | stack_offset++; |
| 822 | } |
| 823 | } |
| 824 | return sp; |
| 825 | } |
| 826 | |
| 827 | |
| 828 | /* Return a location where we can set a breakpoint that will be hit |
| 829 | when an inferior function call returns. */ |
| 830 | CORE_ADDR |
| 831 | m68hc11_call_dummy_address (void) |
| 832 | { |
| 833 | return entry_point_address (); |
| 834 | } |
| 835 | |
| 836 | static struct type * |
| 837 | m68hc11_register_virtual_type (int reg_nr) |
| 838 | { |
| 839 | return builtin_type_uint16; |
| 840 | } |
| 841 | |
| 842 | static void |
| 843 | m68hc11_store_struct_return (CORE_ADDR addr, CORE_ADDR sp) |
| 844 | { |
| 845 | /* The struct address computed by gdb is on the stack. |
| 846 | It uses the stack pointer so we must apply the stack |
| 847 | correction offset. */ |
| 848 | write_register (HARD_D_REGNUM, addr + stack_correction); |
| 849 | } |
| 850 | |
| 851 | static void |
| 852 | m68hc11_store_return_value (struct type *type, char *valbuf) |
| 853 | { |
| 854 | int len; |
| 855 | |
| 856 | len = TYPE_LENGTH (type); |
| 857 | |
| 858 | /* First argument is passed in D and X registers. */ |
| 859 | if (len <= 4) |
| 860 | { |
| 861 | LONGEST v = extract_unsigned_integer (valbuf, len); |
| 862 | |
| 863 | write_register (HARD_D_REGNUM, v); |
| 864 | if (len > 2) |
| 865 | { |
| 866 | v >>= 16; |
| 867 | write_register (HARD_X_REGNUM, v); |
| 868 | } |
| 869 | } |
| 870 | else |
| 871 | error ("return of value > 4 is not supported."); |
| 872 | } |
| 873 | |
| 874 | |
| 875 | /* Given a return value in `regbuf' with a type `type', |
| 876 | extract and copy its value into `valbuf'. */ |
| 877 | |
| 878 | static void |
| 879 | m68hc11_extract_return_value (struct type *type, |
| 880 | char *regbuf, |
| 881 | char *valbuf) |
| 882 | { |
| 883 | int len = TYPE_LENGTH (type); |
| 884 | |
| 885 | switch (len) |
| 886 | { |
| 887 | case 1: |
| 888 | memcpy (valbuf, ®buf[HARD_D_REGNUM * 2 + 1], len); |
| 889 | break; |
| 890 | |
| 891 | case 2: |
| 892 | memcpy (valbuf, ®buf[HARD_D_REGNUM * 2], len); |
| 893 | break; |
| 894 | |
| 895 | case 3: |
| 896 | memcpy (&valbuf[0], ®buf[HARD_X_REGNUM * 2 + 1], 1); |
| 897 | memcpy (&valbuf[1], ®buf[HARD_D_REGNUM * 2], 2); |
| 898 | break; |
| 899 | |
| 900 | case 4: |
| 901 | memcpy (&valbuf[0], ®buf[HARD_X_REGNUM * 2], 2); |
| 902 | memcpy (&valbuf[2], ®buf[HARD_D_REGNUM * 2], 2); |
| 903 | break; |
| 904 | |
| 905 | default: |
| 906 | error ("bad size for return value"); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | /* Should call_function allocate stack space for a struct return? */ |
| 911 | static int |
| 912 | m68hc11_use_struct_convention (int gcc_p, struct type *type) |
| 913 | { |
| 914 | return (TYPE_CODE (type) == TYPE_CODE_STRUCT |
| 915 | || TYPE_CODE (type) == TYPE_CODE_UNION |
| 916 | || TYPE_LENGTH (type) > 4); |
| 917 | } |
| 918 | |
| 919 | static int |
| 920 | m68hc11_return_value_on_stack (struct type *type) |
| 921 | { |
| 922 | return TYPE_LENGTH (type) > 4; |
| 923 | } |
| 924 | |
| 925 | /* Extract from an array REGBUF containing the (raw) register state |
| 926 | the address in which a function should return its structure value, |
| 927 | as a CORE_ADDR (or an expression that can be used as one). */ |
| 928 | static CORE_ADDR |
| 929 | m68hc11_extract_struct_value_address (char *regbuf) |
| 930 | { |
| 931 | return extract_address (®buf[HARD_D_REGNUM * 2], |
| 932 | REGISTER_RAW_SIZE (HARD_D_REGNUM)); |
| 933 | } |
| 934 | |
| 935 | /* Function: push_return_address (pc) |
| 936 | Set up the return address for the inferior function call. |
| 937 | Needed for targets where we don't actually execute a JSR/BSR instruction */ |
| 938 | |
| 939 | static CORE_ADDR |
| 940 | m68hc11_push_return_address (CORE_ADDR pc, CORE_ADDR sp) |
| 941 | { |
| 942 | char valbuf[2]; |
| 943 | |
| 944 | pc = CALL_DUMMY_ADDRESS (); |
| 945 | sp -= 2; |
| 946 | store_unsigned_integer (valbuf, 2, pc); |
| 947 | write_memory (sp + stack_correction, valbuf, 2); |
| 948 | return sp; |
| 949 | } |
| 950 | |
| 951 | /* Index within `registers' of the first byte of the space for |
| 952 | register N. */ |
| 953 | static int |
| 954 | m68hc11_register_byte (int reg_nr) |
| 955 | { |
| 956 | return (reg_nr * M68HC11_REG_SIZE); |
| 957 | } |
| 958 | |
| 959 | static int |
| 960 | m68hc11_register_raw_size (int reg_nr) |
| 961 | { |
| 962 | return M68HC11_REG_SIZE; |
| 963 | } |
| 964 | |
| 965 | static struct gdbarch * |
| 966 | m68hc11_gdbarch_init (struct gdbarch_info info, |
| 967 | struct gdbarch_list *arches) |
| 968 | { |
| 969 | static LONGEST m68hc11_call_dummy_words[] = |
| 970 | {0}; |
| 971 | struct gdbarch *gdbarch; |
| 972 | struct gdbarch_tdep *tdep; |
| 973 | int elf_flags; |
| 974 | |
| 975 | /* Extract the elf_flags if available */ |
| 976 | elf_flags = 0; |
| 977 | |
| 978 | soft_reg_initialized = 0; |
| 979 | |
| 980 | /* try to find a pre-existing architecture */ |
| 981 | for (arches = gdbarch_list_lookup_by_info (arches, &info); |
| 982 | arches != NULL; |
| 983 | arches = gdbarch_list_lookup_by_info (arches->next, &info)) |
| 984 | { |
| 985 | /* MIPS needs to be pedantic about which ABI the object is |
| 986 | using. */ |
| 987 | if (gdbarch_tdep (current_gdbarch)->elf_flags != elf_flags) |
| 988 | continue; |
| 989 | return arches->gdbarch; |
| 990 | } |
| 991 | |
| 992 | /* Need a new architecture. Fill in a target specific vector. */ |
| 993 | tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep)); |
| 994 | gdbarch = gdbarch_alloc (&info, tdep); |
| 995 | tdep->elf_flags = elf_flags; |
| 996 | |
| 997 | /* Initially set everything according to the ABI. */ |
| 998 | set_gdbarch_short_bit (gdbarch, 16); |
| 999 | set_gdbarch_int_bit (gdbarch, 32); |
| 1000 | set_gdbarch_float_bit (gdbarch, 32); |
| 1001 | set_gdbarch_double_bit (gdbarch, 64); |
| 1002 | set_gdbarch_long_double_bit (gdbarch, 64); |
| 1003 | set_gdbarch_long_bit (gdbarch, 32); |
| 1004 | set_gdbarch_ptr_bit (gdbarch, 16); |
| 1005 | set_gdbarch_long_long_bit (gdbarch, 64); |
| 1006 | |
| 1007 | /* Set register info. */ |
| 1008 | set_gdbarch_fp0_regnum (gdbarch, -1); |
| 1009 | set_gdbarch_max_register_raw_size (gdbarch, 2); |
| 1010 | set_gdbarch_max_register_virtual_size (gdbarch, 2); |
| 1011 | set_gdbarch_register_raw_size (gdbarch, m68hc11_register_raw_size); |
| 1012 | set_gdbarch_register_virtual_size (gdbarch, m68hc11_register_raw_size); |
| 1013 | set_gdbarch_register_byte (gdbarch, m68hc11_register_byte); |
| 1014 | set_gdbarch_frame_init_saved_regs (gdbarch, m68hc11_frame_init_saved_regs); |
| 1015 | set_gdbarch_frame_args_skip (gdbarch, 0); |
| 1016 | |
| 1017 | set_gdbarch_read_pc (gdbarch, generic_target_read_pc); |
| 1018 | set_gdbarch_write_pc (gdbarch, generic_target_write_pc); |
| 1019 | set_gdbarch_read_fp (gdbarch, generic_target_read_fp); |
| 1020 | set_gdbarch_write_fp (gdbarch, generic_target_write_fp); |
| 1021 | set_gdbarch_read_sp (gdbarch, generic_target_read_sp); |
| 1022 | set_gdbarch_write_sp (gdbarch, generic_target_write_sp); |
| 1023 | |
| 1024 | set_gdbarch_num_regs (gdbarch, M68HC11_NUM_REGS); |
| 1025 | set_gdbarch_num_pseudo_regs (gdbarch, M68HC11_NUM_PSEUDO_REGS); |
| 1026 | set_gdbarch_sp_regnum (gdbarch, HARD_SP_REGNUM); |
| 1027 | set_gdbarch_fp_regnum (gdbarch, SOFT_FP_REGNUM); |
| 1028 | set_gdbarch_pc_regnum (gdbarch, HARD_PC_REGNUM); |
| 1029 | set_gdbarch_register_name (gdbarch, m68hc11_register_name); |
| 1030 | set_gdbarch_register_size (gdbarch, 2); |
| 1031 | set_gdbarch_register_bytes (gdbarch, M68HC11_ALL_REGS * 2); |
| 1032 | set_gdbarch_register_virtual_type (gdbarch, m68hc11_register_virtual_type); |
| 1033 | set_gdbarch_fetch_pseudo_register (gdbarch, m68hc11_fetch_pseudo_register); |
| 1034 | set_gdbarch_store_pseudo_register (gdbarch, m68hc11_store_pseudo_register); |
| 1035 | |
| 1036 | set_gdbarch_use_generic_dummy_frames (gdbarch, 1); |
| 1037 | set_gdbarch_call_dummy_length (gdbarch, 0); |
| 1038 | set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT); |
| 1039 | set_gdbarch_call_dummy_address (gdbarch, m68hc11_call_dummy_address); |
| 1040 | set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1); /*???*/ |
| 1041 | set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0); |
| 1042 | set_gdbarch_call_dummy_start_offset (gdbarch, 0); |
| 1043 | set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy); |
| 1044 | set_gdbarch_call_dummy_words (gdbarch, m68hc11_call_dummy_words); |
| 1045 | set_gdbarch_sizeof_call_dummy_words (gdbarch, |
| 1046 | sizeof (m68hc11_call_dummy_words)); |
| 1047 | set_gdbarch_call_dummy_p (gdbarch, 1); |
| 1048 | set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0); |
| 1049 | set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register); |
| 1050 | set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy); |
| 1051 | set_gdbarch_extract_return_value (gdbarch, m68hc11_extract_return_value); |
| 1052 | set_gdbarch_push_arguments (gdbarch, m68hc11_push_arguments); |
| 1053 | set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame); |
| 1054 | set_gdbarch_push_return_address (gdbarch, m68hc11_push_return_address); |
| 1055 | set_gdbarch_return_value_on_stack (gdbarch, m68hc11_return_value_on_stack); |
| 1056 | |
| 1057 | set_gdbarch_store_struct_return (gdbarch, m68hc11_store_struct_return); |
| 1058 | set_gdbarch_store_return_value (gdbarch, m68hc11_store_return_value); |
| 1059 | set_gdbarch_extract_struct_value_address (gdbarch, |
| 1060 | m68hc11_extract_struct_value_address); |
| 1061 | set_gdbarch_register_convertible (gdbarch, generic_register_convertible_not); |
| 1062 | |
| 1063 | |
| 1064 | set_gdbarch_frame_chain (gdbarch, m68hc11_frame_chain); |
| 1065 | set_gdbarch_frame_chain_valid (gdbarch, generic_file_frame_chain_valid); |
| 1066 | set_gdbarch_frame_saved_pc (gdbarch, m68hc11_frame_saved_pc); |
| 1067 | set_gdbarch_frame_args_address (gdbarch, m68hc11_frame_args_address); |
| 1068 | set_gdbarch_frame_locals_address (gdbarch, m68hc11_frame_locals_address); |
| 1069 | set_gdbarch_saved_pc_after_call (gdbarch, m68hc11_saved_pc_after_call); |
| 1070 | set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown); |
| 1071 | |
| 1072 | set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid); |
| 1073 | set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register); |
| 1074 | |
| 1075 | set_gdbarch_store_struct_return (gdbarch, m68hc11_store_struct_return); |
| 1076 | set_gdbarch_store_return_value (gdbarch, m68hc11_store_return_value); |
| 1077 | set_gdbarch_extract_struct_value_address |
| 1078 | (gdbarch, m68hc11_extract_struct_value_address); |
| 1079 | set_gdbarch_use_struct_convention (gdbarch, m68hc11_use_struct_convention); |
| 1080 | set_gdbarch_init_extra_frame_info (gdbarch, m68hc11_init_extra_frame_info); |
| 1081 | set_gdbarch_pop_frame (gdbarch, m68hc11_pop_frame); |
| 1082 | set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue); |
| 1083 | set_gdbarch_inner_than (gdbarch, core_addr_lessthan); |
| 1084 | set_gdbarch_decr_pc_after_break (gdbarch, 0); |
| 1085 | set_gdbarch_function_start_offset (gdbarch, 0); |
| 1086 | set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc); |
| 1087 | set_gdbarch_stack_align (gdbarch, m68hc11_stack_align); |
| 1088 | |
| 1089 | set_gdbarch_believe_pcc_promotion (gdbarch, 1); |
| 1090 | set_gdbarch_ieee_float (gdbarch, 1); |
| 1091 | |
| 1092 | return gdbarch; |
| 1093 | } |
| 1094 | |
| 1095 | void |
| 1096 | _initialize_m68hc11_tdep (void) |
| 1097 | { |
| 1098 | register_gdbarch_init (bfd_arch_m68hc11, m68hc11_gdbarch_init); |
| 1099 | if (!tm_print_insn) /* Someone may have already set it */ |
| 1100 | tm_print_insn = print_insn_m68hc11; |
| 1101 | |
| 1102 | add_com ("regs", class_vars, show_regs, "Print all registers"); |
| 1103 | } |
| 1104 | |