* m68hc11-tdep.c (m68hc11_elf_make_msymbol_special): New function.
[deliverable/binutils-gdb.git] / gdb / m68hc11-tdep.c
1 /* Target-dependent code for Motorola 68HC11 & 68HC12
2 Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3 Contributed by Stephane Carrez, stcarrez@nerim.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 "symtab.h"
25 #include "gdbtypes.h"
26 #include "gdbcmd.h"
27 #include "gdbcore.h"
28 #include "gdb_string.h"
29 #include "value.h"
30 #include "inferior.h"
31 #include "dis-asm.h"
32 #include "symfile.h"
33 #include "objfiles.h"
34 #include "arch-utils.h"
35 #include "regcache.h"
36
37 #include "target.h"
38 #include "opcode/m68hc11.h"
39 #include "elf/m68hc11.h"
40 #include "elf-bfd.h"
41
42 /* Macros for setting and testing a bit in a minimal symbol.
43 For 68HC11/68HC12 we have two flags that tell which return
44 type the function is using. This is used for prologue and frame
45 analysis to compute correct stack frame layout.
46
47 The MSB of the minimal symbol's "info" field is used for this purpose.
48 This field is already being used to store the symbol size, so the
49 assumption is that the symbol size cannot exceed 2^30.
50
51 MSYMBOL_SET_RTC Actually sets the "RTC" bit.
52 MSYMBOL_SET_RTI Actually sets the "RTI" bit.
53 MSYMBOL_IS_RTC Tests the "RTC" bit in a minimal symbol.
54 MSYMBOL_IS_RTI Tests the "RTC" bit in a minimal symbol.
55 MSYMBOL_SIZE Returns the size of the minimal symbol,
56 i.e. the "info" field with the "special" bit
57 masked out. */
58
59 #define MSYMBOL_SET_RTC(msym) \
60 MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) \
61 | 0x80000000)
62
63 #define MSYMBOL_SET_RTI(msym) \
64 MSYMBOL_INFO (msym) = (char *) (((long) MSYMBOL_INFO (msym)) \
65 | 0x40000000)
66
67 #define MSYMBOL_IS_RTC(msym) \
68 (((long) MSYMBOL_INFO (msym) & 0x80000000) != 0)
69
70 #define MSYMBOL_IS_RTI(msym) \
71 (((long) MSYMBOL_INFO (msym) & 0x40000000) != 0)
72
73 #define MSYMBOL_SIZE(msym) \
74 ((long) MSYMBOL_INFO (msym) & 0x3fffffff)
75
76 enum insn_return_kind {
77 RETURN_RTS,
78 RETURN_RTC,
79 RETURN_RTI
80 };
81
82
83 /* Register numbers of various important registers.
84 Note that some of these values are "real" register numbers,
85 and correspond to the general registers of the machine,
86 and some are "phony" register numbers which are too large
87 to be actual register numbers as far as the user is concerned
88 but do serve to get the desired values when passed to read_register. */
89
90 #define HARD_X_REGNUM 0
91 #define HARD_D_REGNUM 1
92 #define HARD_Y_REGNUM 2
93 #define HARD_SP_REGNUM 3
94 #define HARD_PC_REGNUM 4
95
96 #define HARD_A_REGNUM 5
97 #define HARD_B_REGNUM 6
98 #define HARD_CCR_REGNUM 7
99
100 /* 68HC12 page number register.
101 Note: to keep a compatibility with gcc register naming, we must
102 not have to rename FP and other soft registers. The page register
103 is a real hard register and must therefore be counted by NUM_REGS.
104 For this it has the same number as Z register (which is not used). */
105 #define HARD_PAGE_REGNUM 8
106 #define M68HC11_LAST_HARD_REG (HARD_PAGE_REGNUM)
107
108 /* Z is replaced by X or Y by gcc during machine reorg.
109 ??? There is no way to get it and even know whether
110 it's in X or Y or in ZS. */
111 #define SOFT_Z_REGNUM 8
112
113 /* Soft registers. These registers are special. There are treated
114 like normal hard registers by gcc and gdb (ie, within dwarf2 info).
115 They are physically located in memory. */
116 #define SOFT_FP_REGNUM 9
117 #define SOFT_TMP_REGNUM 10
118 #define SOFT_ZS_REGNUM 11
119 #define SOFT_XY_REGNUM 12
120 #define SOFT_UNUSED_REGNUM 13
121 #define SOFT_D1_REGNUM 14
122 #define SOFT_D32_REGNUM (SOFT_D1_REGNUM+31)
123 #define M68HC11_MAX_SOFT_REGS 32
124
125 #define M68HC11_NUM_REGS (8)
126 #define M68HC11_NUM_PSEUDO_REGS (M68HC11_MAX_SOFT_REGS+5)
127 #define M68HC11_ALL_REGS (M68HC11_NUM_REGS+M68HC11_NUM_PSEUDO_REGS)
128
129 #define M68HC11_REG_SIZE (2)
130
131 struct insn_sequence;
132 struct gdbarch_tdep
133 {
134 /* Stack pointer correction value. For 68hc11, the stack pointer points
135 to the next push location. An offset of 1 must be applied to obtain
136 the address where the last value is saved. For 68hc12, the stack
137 pointer points to the last value pushed. No offset is necessary. */
138 int stack_correction;
139
140 /* Description of instructions in the prologue. */
141 struct insn_sequence *prologue;
142
143 /* True if the page memory bank register is available
144 and must be used. */
145 int use_page_register;
146
147 /* ELF flags for ABI. */
148 int elf_flags;
149 };
150
151 #define M6811_TDEP gdbarch_tdep (current_gdbarch)
152 #define STACK_CORRECTION (M6811_TDEP->stack_correction)
153 #define USE_PAGE_REGISTER (M6811_TDEP->use_page_register)
154
155 struct frame_extra_info
156 {
157 CORE_ADDR return_pc;
158 int frameless;
159 int size;
160 enum insn_return_kind return_kind;
161 };
162
163 /* Table of registers for 68HC11. This includes the hard registers
164 and the soft registers used by GCC. */
165 static char *
166 m68hc11_register_names[] =
167 {
168 "x", "d", "y", "sp", "pc", "a", "b",
169 "ccr", "page", "frame","tmp", "zs", "xy", 0,
170 "d1", "d2", "d3", "d4", "d5", "d6", "d7",
171 "d8", "d9", "d10", "d11", "d12", "d13", "d14",
172 "d15", "d16", "d17", "d18", "d19", "d20", "d21",
173 "d22", "d23", "d24", "d25", "d26", "d27", "d28",
174 "d29", "d30", "d31", "d32"
175 };
176
177 struct m68hc11_soft_reg
178 {
179 const char *name;
180 CORE_ADDR addr;
181 };
182
183 static struct m68hc11_soft_reg soft_regs[M68HC11_ALL_REGS];
184
185 #define M68HC11_FP_ADDR soft_regs[SOFT_FP_REGNUM].addr
186
187 static int soft_min_addr;
188 static int soft_max_addr;
189 static int soft_reg_initialized = 0;
190
191 /* Look in the symbol table for the address of a pseudo register
192 in memory. If we don't find it, pretend the register is not used
193 and not available. */
194 static void
195 m68hc11_get_register_info (struct m68hc11_soft_reg *reg, const char *name)
196 {
197 struct minimal_symbol *msymbol;
198
199 msymbol = lookup_minimal_symbol (name, NULL, NULL);
200 if (msymbol)
201 {
202 reg->addr = SYMBOL_VALUE_ADDRESS (msymbol);
203 reg->name = xstrdup (name);
204
205 /* Keep track of the address range for soft registers. */
206 if (reg->addr < (CORE_ADDR) soft_min_addr)
207 soft_min_addr = reg->addr;
208 if (reg->addr > (CORE_ADDR) soft_max_addr)
209 soft_max_addr = reg->addr;
210 }
211 else
212 {
213 reg->name = 0;
214 reg->addr = 0;
215 }
216 }
217
218 /* Initialize the table of soft register addresses according
219 to the symbol table. */
220 static void
221 m68hc11_initialize_register_info (void)
222 {
223 int i;
224
225 if (soft_reg_initialized)
226 return;
227
228 soft_min_addr = INT_MAX;
229 soft_max_addr = 0;
230 for (i = 0; i < M68HC11_ALL_REGS; i++)
231 {
232 soft_regs[i].name = 0;
233 }
234
235 m68hc11_get_register_info (&soft_regs[SOFT_FP_REGNUM], "_.frame");
236 m68hc11_get_register_info (&soft_regs[SOFT_TMP_REGNUM], "_.tmp");
237 m68hc11_get_register_info (&soft_regs[SOFT_ZS_REGNUM], "_.z");
238 soft_regs[SOFT_Z_REGNUM] = soft_regs[SOFT_ZS_REGNUM];
239 m68hc11_get_register_info (&soft_regs[SOFT_XY_REGNUM], "_.xy");
240
241 for (i = SOFT_D1_REGNUM; i < M68HC11_MAX_SOFT_REGS; i++)
242 {
243 char buf[10];
244
245 sprintf (buf, "_.d%d", i - SOFT_D1_REGNUM + 1);
246 m68hc11_get_register_info (&soft_regs[i], buf);
247 }
248
249 if (soft_regs[SOFT_FP_REGNUM].name == 0)
250 {
251 warning ("No frame soft register found in the symbol table.\n");
252 warning ("Stack backtrace will not work.\n");
253 }
254 soft_reg_initialized = 1;
255 }
256
257 /* Given an address in memory, return the soft register number if
258 that address corresponds to a soft register. Returns -1 if not. */
259 static int
260 m68hc11_which_soft_register (CORE_ADDR addr)
261 {
262 int i;
263
264 if (addr < soft_min_addr || addr > soft_max_addr)
265 return -1;
266
267 for (i = SOFT_FP_REGNUM; i < M68HC11_ALL_REGS; i++)
268 {
269 if (soft_regs[i].name && soft_regs[i].addr == addr)
270 return i;
271 }
272 return -1;
273 }
274
275 /* Fetch a pseudo register. The 68hc11 soft registers are treated like
276 pseudo registers. They are located in memory. Translate the register
277 fetch into a memory read. */
278 static void
279 m68hc11_pseudo_register_read (struct gdbarch *gdbarch,
280 struct regcache *regcache,
281 int regno, void *buf)
282 {
283 m68hc11_initialize_register_info ();
284
285 /* Fetch a soft register: translate into a memory read. */
286 if (soft_regs[regno].name)
287 {
288 target_read_memory (soft_regs[regno].addr, buf, 2);
289 }
290 else
291 {
292 memset (buf, 0, 2);
293 }
294 }
295
296 /* Store a pseudo register. Translate the register store
297 into a memory write. */
298 static void
299 m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
300 struct regcache *regcache,
301 int regno, const void *buf)
302 {
303 m68hc11_initialize_register_info ();
304
305 /* Store a soft register: translate into a memory write. */
306 if (soft_regs[regno].name)
307 {
308 const int regsize = 2;
309 char *tmp = alloca (regsize);
310 memcpy (tmp, buf, regsize);
311 target_write_memory (soft_regs[regno].addr, tmp, regsize);
312 }
313 }
314
315 static const char *
316 m68hc11_register_name (int reg_nr)
317 {
318 if (reg_nr < 0)
319 return NULL;
320 if (reg_nr >= M68HC11_ALL_REGS)
321 return NULL;
322
323 /* If we don't know the address of a soft register, pretend it
324 does not exist. */
325 if (reg_nr > M68HC11_LAST_HARD_REG && soft_regs[reg_nr].name == 0)
326 return NULL;
327 return m68hc11_register_names[reg_nr];
328 }
329
330 static const unsigned char *
331 m68hc11_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
332 {
333 static unsigned char breakpoint[] = {0x0};
334
335 *lenptr = sizeof (breakpoint);
336 return breakpoint;
337 }
338
339 /* Immediately after a function call, return the saved pc before the frame
340 is setup. */
341
342 static CORE_ADDR
343 m68hc11_saved_pc_after_call (struct frame_info *frame)
344 {
345 CORE_ADDR addr;
346
347 addr = read_register (HARD_SP_REGNUM) + STACK_CORRECTION;
348 addr &= 0x0ffff;
349 return read_memory_integer (addr, 2) & 0x0FFFF;
350 }
351
352 static CORE_ADDR
353 m68hc11_frame_saved_pc (struct frame_info *frame)
354 {
355 return frame->extra_info->return_pc;
356 }
357
358 static CORE_ADDR
359 m68hc11_frame_args_address (struct frame_info *frame)
360 {
361 CORE_ADDR addr;
362
363 addr = frame->frame + frame->extra_info->size + STACK_CORRECTION + 2;
364 if (frame->extra_info->return_kind == RETURN_RTC)
365 addr += 1;
366 else if (frame->extra_info->return_kind == RETURN_RTI)
367 addr += 7;
368
369 return addr;
370 }
371
372 static CORE_ADDR
373 m68hc11_frame_locals_address (struct frame_info *frame)
374 {
375 return frame->frame;
376 }
377
378 /* Discard from the stack the innermost frame, restoring all saved
379 registers. */
380
381 static void
382 m68hc11_pop_frame (void)
383 {
384 register struct frame_info *frame = get_current_frame ();
385 register CORE_ADDR fp, sp;
386 register int regnum;
387
388 if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
389 generic_pop_dummy_frame ();
390 else
391 {
392 fp = FRAME_FP (frame);
393 FRAME_INIT_SAVED_REGS (frame);
394
395 /* Copy regs from where they were saved in the frame. */
396 for (regnum = 0; regnum < M68HC11_ALL_REGS; regnum++)
397 if (frame->saved_regs[regnum])
398 write_register (regnum,
399 read_memory_integer (frame->saved_regs[regnum], 2));
400
401 write_register (HARD_PC_REGNUM, frame->extra_info->return_pc);
402 sp = (fp + frame->extra_info->size + 2) & 0x0ffff;
403 write_register (HARD_SP_REGNUM, sp);
404 }
405 flush_cached_frames ();
406 }
407
408 \f
409 /* 68HC11 & 68HC12 prologue analysis.
410
411 */
412 #define MAX_CODES 12
413
414 /* 68HC11 opcodes. */
415 #undef M6811_OP_PAGE2
416 #define M6811_OP_PAGE2 (0x18)
417 #define M6811_OP_LDX (0xde)
418 #define M6811_OP_PSHX (0x3c)
419 #define M6811_OP_STS (0x9f)
420 #define M6811_OP_TSX (0x30)
421 #define M6811_OP_XGDX (0x8f)
422 #define M6811_OP_ADDD (0xc3)
423 #define M6811_OP_TXS (0x35)
424 #define M6811_OP_DES (0x34)
425
426 /* 68HC12 opcodes. */
427 #define M6812_OP_PAGE2 (0x18)
428 #define M6812_OP_MOVW (0x01)
429 #define M6812_PB_PSHW (0xae)
430 #define M6812_OP_STS (0x7f)
431 #define M6812_OP_LEAS (0x1b)
432 #define M6812_OP_PSHX (0x34)
433 #define M6812_OP_PSHY (0x35)
434
435 /* Operand extraction. */
436 #define OP_DIRECT (0x100) /* 8-byte direct addressing. */
437 #define OP_IMM_LOW (0x200) /* Low part of 16-bit constant/address. */
438 #define OP_IMM_HIGH (0x300) /* High part of 16-bit constant/address. */
439 #define OP_PBYTE (0x400) /* 68HC12 indexed operand. */
440
441 /* Identification of the sequence. */
442 enum m6811_seq_type
443 {
444 P_LAST = 0,
445 P_SAVE_REG, /* Save a register on the stack. */
446 P_SET_FRAME, /* Setup the frame pointer. */
447 P_LOCAL_1, /* Allocate 1 byte for locals. */
448 P_LOCAL_2, /* Allocate 2 bytes for locals. */
449 P_LOCAL_N /* Allocate N bytes for locals. */
450 };
451
452 struct insn_sequence {
453 enum m6811_seq_type type;
454 unsigned length;
455 unsigned short code[MAX_CODES];
456 };
457
458 /* Sequence of instructions in the 68HC11 function prologue. */
459 static struct insn_sequence m6811_prologue[] = {
460 /* Sequences to save a soft-register. */
461 { P_SAVE_REG, 3, { M6811_OP_LDX, OP_DIRECT,
462 M6811_OP_PSHX } },
463 { P_SAVE_REG, 5, { M6811_OP_PAGE2, M6811_OP_LDX, OP_DIRECT,
464 M6811_OP_PAGE2, M6811_OP_PSHX } },
465
466 /* Sequences to allocate local variables. */
467 { P_LOCAL_N, 7, { M6811_OP_TSX,
468 M6811_OP_XGDX,
469 M6811_OP_ADDD, OP_IMM_HIGH, OP_IMM_LOW,
470 M6811_OP_XGDX,
471 M6811_OP_TXS } },
472 { P_LOCAL_N, 11, { M6811_OP_PAGE2, M6811_OP_TSX,
473 M6811_OP_PAGE2, M6811_OP_XGDX,
474 M6811_OP_ADDD, OP_IMM_HIGH, OP_IMM_LOW,
475 M6811_OP_PAGE2, M6811_OP_XGDX,
476 M6811_OP_PAGE2, M6811_OP_TXS } },
477 { P_LOCAL_1, 1, { M6811_OP_DES } },
478 { P_LOCAL_2, 1, { M6811_OP_PSHX } },
479 { P_LOCAL_2, 2, { M6811_OP_PAGE2, M6811_OP_PSHX } },
480
481 /* Initialize the frame pointer. */
482 { P_SET_FRAME, 2, { M6811_OP_STS, OP_DIRECT } },
483 { P_LAST, 0, { 0 } }
484 };
485
486
487 /* Sequence of instructions in the 68HC12 function prologue. */
488 static struct insn_sequence m6812_prologue[] = {
489 { P_SAVE_REG, 5, { M6812_OP_PAGE2, M6812_OP_MOVW, M6812_PB_PSHW,
490 OP_IMM_HIGH, OP_IMM_LOW } },
491 { P_SET_FRAME, 3, { M6812_OP_STS, OP_IMM_HIGH, OP_IMM_LOW } },
492 { P_LOCAL_N, 2, { M6812_OP_LEAS, OP_PBYTE } },
493 { P_LOCAL_2, 1, { M6812_OP_PSHX } },
494 { P_LOCAL_2, 1, { M6812_OP_PSHY } },
495 { P_LAST, 0 }
496 };
497
498
499 /* Analyze the sequence of instructions starting at the given address.
500 Returns a pointer to the sequence when it is recognized and
501 the optional value (constant/address) associated with it.
502 Advance the pc for the next sequence. */
503 static struct insn_sequence *
504 m68hc11_analyze_instruction (struct insn_sequence *seq, CORE_ADDR *pc,
505 CORE_ADDR *val)
506 {
507 unsigned char buffer[MAX_CODES];
508 unsigned bufsize;
509 unsigned j;
510 CORE_ADDR cur_val;
511 short v = 0;
512
513 bufsize = 0;
514 for (; seq->type != P_LAST; seq++)
515 {
516 cur_val = 0;
517 for (j = 0; j < seq->length; j++)
518 {
519 if (bufsize < j + 1)
520 {
521 buffer[bufsize] = read_memory_unsigned_integer (*pc + bufsize,
522 1);
523 bufsize++;
524 }
525 /* Continue while we match the opcode. */
526 if (seq->code[j] == buffer[j])
527 continue;
528
529 if ((seq->code[j] & 0xf00) == 0)
530 break;
531
532 /* Extract a sequence parameter (address or constant). */
533 switch (seq->code[j])
534 {
535 case OP_DIRECT:
536 cur_val = (CORE_ADDR) buffer[j];
537 break;
538
539 case OP_IMM_HIGH:
540 cur_val = cur_val & 0x0ff;
541 cur_val |= (buffer[j] << 8);
542 break;
543
544 case OP_IMM_LOW:
545 cur_val &= 0x0ff00;
546 cur_val |= buffer[j];
547 break;
548
549 case OP_PBYTE:
550 if ((buffer[j] & 0xE0) == 0x80)
551 {
552 v = buffer[j] & 0x1f;
553 if (v & 0x10)
554 v |= 0xfff0;
555 }
556 else if ((buffer[j] & 0xfe) == 0xf0)
557 {
558 v = read_memory_unsigned_integer (*pc + j + 1, 1);
559 if (buffer[j] & 1)
560 v |= 0xff00;
561 *pc = *pc + 1;
562 }
563 else if (buffer[j] == 0xf2)
564 {
565 v = read_memory_unsigned_integer (*pc + j + 1, 2);
566 *pc = *pc + 2;
567 }
568 cur_val = v;
569 break;
570 }
571 }
572
573 /* We have a full match. */
574 if (j == seq->length)
575 {
576 *val = cur_val;
577 *pc = *pc + j;
578 return seq;
579 }
580 }
581 return 0;
582 }
583
584 /* Return the instruction that the function at the PC is using. */
585 static enum insn_return_kind
586 m68hc11_get_return_insn (CORE_ADDR pc)
587 {
588 struct minimal_symbol *sym;
589
590 /* A flag indicating that this is a STO_M68HC12_FAR or STO_M68HC12_INTERRUPT
591 function is stored by elfread.c in the high bit of the info field.
592 Use this to decide which instruction the function uses to return. */
593 sym = lookup_minimal_symbol_by_pc (pc);
594 if (sym == 0)
595 return RETURN_RTS;
596
597 if (MSYMBOL_IS_RTC (sym))
598 return RETURN_RTC;
599 else if (MSYMBOL_IS_RTI (sym))
600 return RETURN_RTI;
601 else
602 return RETURN_RTS;
603 }
604
605
606 /* Analyze the function prologue to find some information
607 about the function:
608 - the PC of the first line (for m68hc11_skip_prologue)
609 - the offset of the previous frame saved address (from current frame)
610 - the soft registers which are pushed. */
611 static void
612 m68hc11_guess_from_prologue (CORE_ADDR pc, CORE_ADDR fp,
613 CORE_ADDR *first_line,
614 int *frame_offset, CORE_ADDR *pushed_regs)
615 {
616 CORE_ADDR save_addr;
617 CORE_ADDR func_end;
618 int size;
619 int found_frame_point;
620 int saved_reg;
621 CORE_ADDR first_pc;
622 int done = 0;
623 struct insn_sequence *seq_table;
624
625 first_pc = get_pc_function_start (pc);
626 size = 0;
627
628 m68hc11_initialize_register_info ();
629 if (first_pc == 0)
630 {
631 *frame_offset = 0;
632 *first_line = pc;
633 return;
634 }
635
636 seq_table = gdbarch_tdep (current_gdbarch)->prologue;
637
638 /* The 68hc11 stack is as follows:
639
640
641 | |
642 +-----------+
643 | |
644 | args |
645 | |
646 +-----------+
647 | PC-return |
648 +-----------+
649 | Old frame |
650 +-----------+
651 | |
652 | Locals |
653 | |
654 +-----------+ <--- current frame
655 | |
656
657 With most processors (like 68K) the previous frame can be computed
658 easily because it is always at a fixed offset (see link/unlink).
659 That is, locals are accessed with negative offsets, arguments are
660 accessed with positive ones. Since 68hc11 only supports offsets
661 in the range [0..255], the frame is defined at the bottom of
662 locals (see picture).
663
664 The purpose of the analysis made here is to find out the size
665 of locals in this function. An alternative to this is to use
666 DWARF2 info. This would be better but I don't know how to
667 access dwarf2 debug from this function.
668
669 Walk from the function entry point to the point where we save
670 the frame. While walking instructions, compute the size of bytes
671 which are pushed. This gives us the index to access the previous
672 frame.
673
674 We limit the search to 128 bytes so that the algorithm is bounded
675 in case of random and wrong code. We also stop and abort if
676 we find an instruction which is not supposed to appear in the
677 prologue (as generated by gcc 2.95, 2.96).
678 */
679 pc = first_pc;
680 func_end = pc + 128;
681 found_frame_point = 0;
682 *frame_offset = 0;
683 save_addr = fp + STACK_CORRECTION;
684 while (!done && pc + 2 < func_end)
685 {
686 struct insn_sequence *seq;
687 CORE_ADDR val;
688
689 seq = m68hc11_analyze_instruction (seq_table, &pc, &val);
690 if (seq == 0)
691 break;
692
693 if (seq->type == P_SAVE_REG)
694 {
695 if (found_frame_point)
696 {
697 saved_reg = m68hc11_which_soft_register (val);
698 if (saved_reg < 0)
699 break;
700
701 save_addr -= 2;
702 if (pushed_regs)
703 pushed_regs[saved_reg] = save_addr;
704 }
705 else
706 {
707 size += 2;
708 }
709 }
710 else if (seq->type == P_SET_FRAME)
711 {
712 found_frame_point = 1;
713 *frame_offset = size;
714 }
715 else if (seq->type == P_LOCAL_1)
716 {
717 size += 1;
718 }
719 else if (seq->type == P_LOCAL_2)
720 {
721 size += 2;
722 }
723 else if (seq->type == P_LOCAL_N)
724 {
725 /* Stack pointer is decremented for the allocation. */
726 if (val & 0x8000)
727 size -= (int) (val) | 0xffff0000;
728 else
729 size -= val;
730 }
731 }
732 *first_line = pc;
733 }
734
735 static CORE_ADDR
736 m68hc11_skip_prologue (CORE_ADDR pc)
737 {
738 CORE_ADDR func_addr, func_end;
739 struct symtab_and_line sal;
740 int frame_offset;
741
742 /* If we have line debugging information, then the end of the
743 prologue should be the first assembly instruction of the
744 first source line. */
745 if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
746 {
747 sal = find_pc_line (func_addr, 0);
748 if (sal.end && sal.end < func_end)
749 return sal.end;
750 }
751
752 m68hc11_guess_from_prologue (pc, 0, &pc, &frame_offset, 0);
753 return pc;
754 }
755
756 /* Given a GDB frame, determine the address of the calling function's frame.
757 This will be used to create a new GDB frame struct, and then
758 INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
759 */
760
761 static CORE_ADDR
762 m68hc11_frame_chain (struct frame_info *frame)
763 {
764 CORE_ADDR addr;
765
766 if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
767 return frame->frame; /* dummy frame same as caller's frame */
768
769 if (frame->extra_info->return_pc == 0
770 || inside_entry_file (frame->extra_info->return_pc))
771 return (CORE_ADDR) 0;
772
773 if (frame->frame == 0)
774 {
775 return (CORE_ADDR) 0;
776 }
777
778 addr = frame->frame + frame->extra_info->size + STACK_CORRECTION - 2;
779 addr = read_memory_unsigned_integer (addr, 2) & 0x0FFFF;
780 return addr;
781 }
782
783 /* Put here the code to store, into a struct frame_saved_regs, the
784 addresses of the saved registers of frame described by FRAME_INFO.
785 This includes special registers such as pc and fp saved in special
786 ways in the stack frame. sp is even more special: the address we
787 return for it IS the sp for the next frame. */
788 static void
789 m68hc11_frame_init_saved_regs (struct frame_info *fi)
790 {
791 CORE_ADDR pc;
792 CORE_ADDR addr;
793
794 if (fi->saved_regs == NULL)
795 frame_saved_regs_zalloc (fi);
796 else
797 memset (fi->saved_regs, 0, sizeof (fi->saved_regs));
798
799 pc = fi->pc;
800 fi->extra_info->return_kind = m68hc11_get_return_insn (pc);
801 m68hc11_guess_from_prologue (pc, fi->frame, &pc, &fi->extra_info->size,
802 fi->saved_regs);
803
804 addr = fi->frame + fi->extra_info->size + STACK_CORRECTION;
805 if (soft_regs[SOFT_FP_REGNUM].name)
806 fi->saved_regs[SOFT_FP_REGNUM] = addr - 2;
807
808 /* Take into account how the function was called/returns. */
809 if (fi->extra_info->return_kind == RETURN_RTC)
810 {
811 fi->saved_regs[HARD_PAGE_REGNUM] = addr;
812 addr++;
813 }
814 else if (fi->extra_info->return_kind == RETURN_RTI)
815 {
816 fi->saved_regs[HARD_CCR_REGNUM] = addr;
817 fi->saved_regs[HARD_D_REGNUM] = addr + 1;
818 fi->saved_regs[HARD_X_REGNUM] = addr + 3;
819 fi->saved_regs[HARD_Y_REGNUM] = addr + 5;
820 addr += 7;
821 }
822 fi->saved_regs[HARD_SP_REGNUM] = addr;
823 fi->saved_regs[HARD_PC_REGNUM] = fi->saved_regs[HARD_SP_REGNUM];
824 }
825
826 static void
827 m68hc11_init_extra_frame_info (int fromleaf, struct frame_info *fi)
828 {
829 CORE_ADDR addr;
830
831 fi->extra_info = (struct frame_extra_info *)
832 frame_obstack_alloc (sizeof (struct frame_extra_info));
833
834 if (fi->next)
835 fi->pc = FRAME_SAVED_PC (fi->next);
836
837 m68hc11_frame_init_saved_regs (fi);
838
839 if (fromleaf)
840 {
841 fi->extra_info->return_kind = m68hc11_get_return_insn (fi->pc);
842 fi->extra_info->return_pc = m68hc11_saved_pc_after_call (fi);
843 }
844 else
845 {
846 addr = fi->saved_regs[HARD_PC_REGNUM];
847 addr = read_memory_unsigned_integer (addr, 2) & 0x0ffff;
848
849 /* Take into account the 68HC12 specific call (PC + page). */
850 if (fi->extra_info->return_kind == RETURN_RTC
851 && addr >= 0x08000 && addr < 0x0c000
852 && USE_PAGE_REGISTER)
853 {
854 CORE_ADDR page_addr = fi->saved_regs[HARD_PAGE_REGNUM];
855
856 unsigned page = read_memory_unsigned_integer (page_addr, 1);
857 addr -= 0x08000;
858 addr += ((page & 0x0ff) << 14);
859 addr += 0x1000000;
860 }
861 fi->extra_info->return_pc = addr;
862 }
863 }
864
865 /* Same as 'info reg' but prints the registers in a different way. */
866 static void
867 show_regs (char *args, int from_tty)
868 {
869 int ccr = read_register (HARD_CCR_REGNUM);
870 int i;
871 int nr;
872
873 printf_filtered ("PC=%04x SP=%04x FP=%04x CCR=%02x %c%c%c%c%c%c%c%c\n",
874 (int) read_register (HARD_PC_REGNUM),
875 (int) read_register (HARD_SP_REGNUM),
876 (int) read_register (SOFT_FP_REGNUM),
877 ccr,
878 ccr & M6811_S_BIT ? 'S' : '-',
879 ccr & M6811_X_BIT ? 'X' : '-',
880 ccr & M6811_H_BIT ? 'H' : '-',
881 ccr & M6811_I_BIT ? 'I' : '-',
882 ccr & M6811_N_BIT ? 'N' : '-',
883 ccr & M6811_Z_BIT ? 'Z' : '-',
884 ccr & M6811_V_BIT ? 'V' : '-',
885 ccr & M6811_C_BIT ? 'C' : '-');
886
887 printf_filtered ("D=%04x IX=%04x IY=%04x",
888 (int) read_register (HARD_D_REGNUM),
889 (int) read_register (HARD_X_REGNUM),
890 (int) read_register (HARD_Y_REGNUM));
891
892 if (USE_PAGE_REGISTER)
893 {
894 printf_filtered (" Page=%02x",
895 (int) read_register (HARD_PAGE_REGNUM));
896 }
897 printf_filtered ("\n");
898
899 nr = 0;
900 for (i = SOFT_D1_REGNUM; i < M68HC11_ALL_REGS; i++)
901 {
902 /* Skip registers which are not defined in the symbol table. */
903 if (soft_regs[i].name == 0)
904 continue;
905
906 printf_filtered ("D%d=%04x",
907 i - SOFT_D1_REGNUM + 1,
908 (int) read_register (i));
909 nr++;
910 if ((nr % 8) == 7)
911 printf_filtered ("\n");
912 else
913 printf_filtered (" ");
914 }
915 if (nr && (nr % 8) != 7)
916 printf_filtered ("\n");
917 }
918
919 static CORE_ADDR
920 m68hc11_stack_align (CORE_ADDR addr)
921 {
922 return ((addr + 1) & -2);
923 }
924
925 static CORE_ADDR
926 m68hc11_push_arguments (int nargs,
927 struct value **args,
928 CORE_ADDR sp,
929 int struct_return,
930 CORE_ADDR struct_addr)
931 {
932 int stack_alloc;
933 int argnum;
934 int first_stack_argnum;
935 int stack_offset;
936 struct type *type;
937 char *val;
938 int len;
939
940 stack_alloc = 0;
941 first_stack_argnum = 0;
942 if (struct_return)
943 {
944 /* The struct is allocated on the stack and gdb used the stack
945 pointer for the address of that struct. We must apply the
946 stack offset on the address. */
947 write_register (HARD_D_REGNUM, struct_addr + STACK_CORRECTION);
948 }
949 else if (nargs > 0)
950 {
951 type = VALUE_TYPE (args[0]);
952 len = TYPE_LENGTH (type);
953
954 /* First argument is passed in D and X registers. */
955 if (len <= 4)
956 {
957 LONGEST v = extract_unsigned_integer (VALUE_CONTENTS (args[0]), len);
958 first_stack_argnum = 1;
959 write_register (HARD_D_REGNUM, v);
960 if (len > 2)
961 {
962 v >>= 16;
963 write_register (HARD_X_REGNUM, v);
964 }
965 }
966 }
967 for (argnum = first_stack_argnum; argnum < nargs; argnum++)
968 {
969 type = VALUE_TYPE (args[argnum]);
970 stack_alloc += (TYPE_LENGTH (type) + 1) & -2;
971 }
972 sp -= stack_alloc;
973
974 stack_offset = STACK_CORRECTION;
975 for (argnum = first_stack_argnum; argnum < nargs; argnum++)
976 {
977 type = VALUE_TYPE (args[argnum]);
978 len = TYPE_LENGTH (type);
979
980 val = (char*) VALUE_CONTENTS (args[argnum]);
981 write_memory (sp + stack_offset, val, len);
982 stack_offset += len;
983 if (len & 1)
984 {
985 static char zero = 0;
986
987 write_memory (sp + stack_offset, &zero, 1);
988 stack_offset++;
989 }
990 }
991 return sp;
992 }
993
994
995 /* Return a location where we can set a breakpoint that will be hit
996 when an inferior function call returns. */
997 CORE_ADDR
998 m68hc11_call_dummy_address (void)
999 {
1000 return entry_point_address ();
1001 }
1002
1003 static struct type *
1004 m68hc11_register_virtual_type (int reg_nr)
1005 {
1006 switch (reg_nr)
1007 {
1008 case HARD_PAGE_REGNUM:
1009 case HARD_A_REGNUM:
1010 case HARD_B_REGNUM:
1011 case HARD_CCR_REGNUM:
1012 return builtin_type_uint8;
1013
1014 default:
1015 return builtin_type_uint16;
1016 }
1017 }
1018
1019 static void
1020 m68hc11_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
1021 {
1022 /* The struct address computed by gdb is on the stack.
1023 It uses the stack pointer so we must apply the stack
1024 correction offset. */
1025 write_register (HARD_D_REGNUM, addr + STACK_CORRECTION);
1026 }
1027
1028 static void
1029 m68hc11_store_return_value (struct type *type, char *valbuf)
1030 {
1031 int len;
1032
1033 len = TYPE_LENGTH (type);
1034
1035 /* First argument is passed in D and X registers. */
1036 if (len <= 4)
1037 {
1038 LONGEST v = extract_unsigned_integer (valbuf, len);
1039
1040 write_register (HARD_D_REGNUM, v);
1041 if (len > 2)
1042 {
1043 v >>= 16;
1044 write_register (HARD_X_REGNUM, v);
1045 }
1046 }
1047 else
1048 error ("return of value > 4 is not supported.");
1049 }
1050
1051
1052 /* Given a return value in `regbuf' with a type `type',
1053 extract and copy its value into `valbuf'. */
1054
1055 static void
1056 m68hc11_extract_return_value (struct type *type,
1057 char *regbuf,
1058 char *valbuf)
1059 {
1060 int len = TYPE_LENGTH (type);
1061
1062 switch (len)
1063 {
1064 case 1:
1065 memcpy (valbuf, &regbuf[HARD_D_REGNUM * 2 + 1], len);
1066 break;
1067
1068 case 2:
1069 memcpy (valbuf, &regbuf[HARD_D_REGNUM * 2], len);
1070 break;
1071
1072 case 3:
1073 memcpy (&valbuf[0], &regbuf[HARD_X_REGNUM * 2 + 1], 1);
1074 memcpy (&valbuf[1], &regbuf[HARD_D_REGNUM * 2], 2);
1075 break;
1076
1077 case 4:
1078 memcpy (&valbuf[0], &regbuf[HARD_X_REGNUM * 2], 2);
1079 memcpy (&valbuf[2], &regbuf[HARD_D_REGNUM * 2], 2);
1080 break;
1081
1082 default:
1083 error ("bad size for return value");
1084 }
1085 }
1086
1087 /* Should call_function allocate stack space for a struct return? */
1088 static int
1089 m68hc11_use_struct_convention (int gcc_p, struct type *type)
1090 {
1091 return (TYPE_CODE (type) == TYPE_CODE_STRUCT
1092 || TYPE_CODE (type) == TYPE_CODE_UNION
1093 || TYPE_LENGTH (type) > 4);
1094 }
1095
1096 static int
1097 m68hc11_return_value_on_stack (struct type *type)
1098 {
1099 return TYPE_LENGTH (type) > 4;
1100 }
1101
1102 /* Extract from an array REGBUF containing the (raw) register state
1103 the address in which a function should return its structure value,
1104 as a CORE_ADDR (or an expression that can be used as one). */
1105 static CORE_ADDR
1106 m68hc11_extract_struct_value_address (char *regbuf)
1107 {
1108 return extract_address (&regbuf[HARD_D_REGNUM * 2],
1109 REGISTER_RAW_SIZE (HARD_D_REGNUM));
1110 }
1111
1112 /* Function: push_return_address (pc)
1113 Set up the return address for the inferior function call.
1114 Needed for targets where we don't actually execute a JSR/BSR instruction */
1115
1116 static CORE_ADDR
1117 m68hc11_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
1118 {
1119 char valbuf[2];
1120
1121 pc = CALL_DUMMY_ADDRESS ();
1122 sp -= 2;
1123 store_unsigned_integer (valbuf, 2, pc);
1124 write_memory (sp + STACK_CORRECTION, valbuf, 2);
1125 return sp;
1126 }
1127
1128 /* Index within `registers' of the first byte of the space for
1129 register N. */
1130 static int
1131 m68hc11_register_byte (int reg_nr)
1132 {
1133 return (reg_nr * M68HC11_REG_SIZE);
1134 }
1135
1136 static int
1137 m68hc11_register_raw_size (int reg_nr)
1138 {
1139 switch (reg_nr)
1140 {
1141 case HARD_PAGE_REGNUM:
1142 case HARD_A_REGNUM:
1143 case HARD_B_REGNUM:
1144 case HARD_CCR_REGNUM:
1145 return 1;
1146
1147 default:
1148 return M68HC11_REG_SIZE;
1149 }
1150 }
1151
1152 /* Test whether the ELF symbol corresponds to a function using rtc or
1153 rti to return. */
1154
1155 static void
1156 m68hc11_elf_make_msymbol_special (asymbol *sym, struct minimal_symbol *msym)
1157 {
1158 unsigned char flags;
1159
1160 flags = ((elf_symbol_type *)sym)->internal_elf_sym.st_other;
1161 if (flags & STO_M68HC12_FAR)
1162 MSYMBOL_SET_RTC (msym);
1163 if (flags & STO_M68HC12_INTERRUPT)
1164 MSYMBOL_SET_RTI (msym);
1165 }
1166
1167 static int
1168 gdb_print_insn_m68hc11 (bfd_vma memaddr, disassemble_info *info)
1169 {
1170 if (TARGET_ARCHITECTURE->arch == bfd_arch_m68hc11)
1171 return print_insn_m68hc11 (memaddr, info);
1172 else
1173 return print_insn_m68hc12 (memaddr, info);
1174 }
1175
1176 static struct gdbarch *
1177 m68hc11_gdbarch_init (struct gdbarch_info info,
1178 struct gdbarch_list *arches)
1179 {
1180 static LONGEST m68hc11_call_dummy_words[] =
1181 {0};
1182 struct gdbarch *gdbarch;
1183 struct gdbarch_tdep *tdep;
1184 int elf_flags;
1185
1186 soft_reg_initialized = 0;
1187
1188 /* Extract the elf_flags if available. */
1189 if (info.abfd != NULL
1190 && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
1191 elf_flags = elf_elfheader (info.abfd)->e_flags;
1192 else
1193 elf_flags = 0;
1194
1195 /* try to find a pre-existing architecture */
1196 for (arches = gdbarch_list_lookup_by_info (arches, &info);
1197 arches != NULL;
1198 arches = gdbarch_list_lookup_by_info (arches->next, &info))
1199 {
1200 if (gdbarch_tdep (arches->gdbarch)->elf_flags != elf_flags)
1201 continue;
1202
1203 return arches->gdbarch;
1204 }
1205
1206 /* Need a new architecture. Fill in a target specific vector. */
1207 tdep = (struct gdbarch_tdep *) xmalloc (sizeof (struct gdbarch_tdep));
1208 gdbarch = gdbarch_alloc (&info, tdep);
1209 tdep->elf_flags = elf_flags;
1210
1211 switch (info.bfd_arch_info->arch)
1212 {
1213 case bfd_arch_m68hc11:
1214 tdep->stack_correction = 1;
1215 tdep->use_page_register = 0;
1216 tdep->prologue = m6811_prologue;
1217 break;
1218
1219 case bfd_arch_m68hc12:
1220 tdep->stack_correction = 0;
1221 tdep->use_page_register = elf_flags & E_M68HC12_BANKS;
1222 tdep->prologue = m6812_prologue;
1223 break;
1224
1225 default:
1226 break;
1227 }
1228
1229 /* Initially set everything according to the ABI.
1230 Use 16-bit integers since it will be the case for most
1231 programs. The size of these types should normally be set
1232 according to the dwarf2 debug information. */
1233 set_gdbarch_short_bit (gdbarch, 16);
1234 set_gdbarch_int_bit (gdbarch, elf_flags & E_M68HC11_I32 ? 32 : 16);
1235 set_gdbarch_float_bit (gdbarch, 32);
1236 set_gdbarch_double_bit (gdbarch, elf_flags & E_M68HC11_F64 ? 64 : 32);
1237 set_gdbarch_long_double_bit (gdbarch, elf_flags & E_M68HC11_F64 ? 64 : 32);
1238 set_gdbarch_long_bit (gdbarch, 32);
1239 set_gdbarch_ptr_bit (gdbarch, 16);
1240 set_gdbarch_long_long_bit (gdbarch, 64);
1241
1242 /* Set register info. */
1243 set_gdbarch_fp0_regnum (gdbarch, -1);
1244 set_gdbarch_max_register_raw_size (gdbarch, 2);
1245 set_gdbarch_max_register_virtual_size (gdbarch, 2);
1246 set_gdbarch_register_raw_size (gdbarch, m68hc11_register_raw_size);
1247 set_gdbarch_register_virtual_size (gdbarch, m68hc11_register_raw_size);
1248 set_gdbarch_register_byte (gdbarch, m68hc11_register_byte);
1249 set_gdbarch_frame_init_saved_regs (gdbarch, m68hc11_frame_init_saved_regs);
1250 set_gdbarch_frame_args_skip (gdbarch, 0);
1251
1252 set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
1253 set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
1254 set_gdbarch_read_fp (gdbarch, generic_target_read_fp);
1255 set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
1256 set_gdbarch_write_sp (gdbarch, generic_target_write_sp);
1257
1258 set_gdbarch_num_regs (gdbarch, M68HC11_NUM_REGS);
1259 set_gdbarch_num_pseudo_regs (gdbarch, M68HC11_NUM_PSEUDO_REGS);
1260 set_gdbarch_sp_regnum (gdbarch, HARD_SP_REGNUM);
1261 set_gdbarch_fp_regnum (gdbarch, SOFT_FP_REGNUM);
1262 set_gdbarch_pc_regnum (gdbarch, HARD_PC_REGNUM);
1263 set_gdbarch_register_name (gdbarch, m68hc11_register_name);
1264 set_gdbarch_register_size (gdbarch, 2);
1265 set_gdbarch_register_bytes (gdbarch, M68HC11_ALL_REGS * 2);
1266 set_gdbarch_register_virtual_type (gdbarch, m68hc11_register_virtual_type);
1267 set_gdbarch_pseudo_register_read (gdbarch, m68hc11_pseudo_register_read);
1268 set_gdbarch_pseudo_register_write (gdbarch, m68hc11_pseudo_register_write);
1269
1270 set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
1271 set_gdbarch_call_dummy_length (gdbarch, 0);
1272 set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
1273 set_gdbarch_call_dummy_address (gdbarch, m68hc11_call_dummy_address);
1274 set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1); /*???*/
1275 set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
1276 set_gdbarch_call_dummy_start_offset (gdbarch, 0);
1277 set_gdbarch_pc_in_call_dummy (gdbarch, generic_pc_in_call_dummy);
1278 set_gdbarch_call_dummy_words (gdbarch, m68hc11_call_dummy_words);
1279 set_gdbarch_sizeof_call_dummy_words (gdbarch,
1280 sizeof (m68hc11_call_dummy_words));
1281 set_gdbarch_call_dummy_p (gdbarch, 1);
1282 set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
1283 set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
1284 set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
1285 set_gdbarch_deprecated_extract_return_value (gdbarch, m68hc11_extract_return_value);
1286 set_gdbarch_push_arguments (gdbarch, m68hc11_push_arguments);
1287 set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
1288 set_gdbarch_push_return_address (gdbarch, m68hc11_push_return_address);
1289 set_gdbarch_return_value_on_stack (gdbarch, m68hc11_return_value_on_stack);
1290
1291 set_gdbarch_store_struct_return (gdbarch, m68hc11_store_struct_return);
1292 set_gdbarch_store_return_value (gdbarch, m68hc11_store_return_value);
1293 set_gdbarch_deprecated_extract_struct_value_address (gdbarch, m68hc11_extract_struct_value_address);
1294 set_gdbarch_register_convertible (gdbarch, generic_register_convertible_not);
1295
1296
1297 set_gdbarch_frame_chain (gdbarch, m68hc11_frame_chain);
1298 set_gdbarch_frame_chain_valid (gdbarch, generic_file_frame_chain_valid);
1299 set_gdbarch_frame_saved_pc (gdbarch, m68hc11_frame_saved_pc);
1300 set_gdbarch_frame_args_address (gdbarch, m68hc11_frame_args_address);
1301 set_gdbarch_frame_locals_address (gdbarch, m68hc11_frame_locals_address);
1302 set_gdbarch_saved_pc_after_call (gdbarch, m68hc11_saved_pc_after_call);
1303 set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
1304
1305 set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid);
1306 set_gdbarch_get_saved_register (gdbarch, generic_get_saved_register);
1307
1308 set_gdbarch_store_struct_return (gdbarch, m68hc11_store_struct_return);
1309 set_gdbarch_store_return_value (gdbarch, m68hc11_store_return_value);
1310 set_gdbarch_deprecated_extract_struct_value_address
1311 (gdbarch, m68hc11_extract_struct_value_address);
1312 set_gdbarch_use_struct_convention (gdbarch, m68hc11_use_struct_convention);
1313 set_gdbarch_init_extra_frame_info (gdbarch, m68hc11_init_extra_frame_info);
1314 set_gdbarch_pop_frame (gdbarch, m68hc11_pop_frame);
1315 set_gdbarch_skip_prologue (gdbarch, m68hc11_skip_prologue);
1316 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1317 set_gdbarch_decr_pc_after_break (gdbarch, 0);
1318 set_gdbarch_function_start_offset (gdbarch, 0);
1319 set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc);
1320 set_gdbarch_stack_align (gdbarch, m68hc11_stack_align);
1321 set_gdbarch_print_insn (gdbarch, gdb_print_insn_m68hc11);
1322
1323 /* Minsymbol frobbing. */
1324 set_gdbarch_elf_make_msymbol_special (gdbarch,
1325 m68hc11_elf_make_msymbol_special);
1326
1327 set_gdbarch_believe_pcc_promotion (gdbarch, 1);
1328
1329 return gdbarch;
1330 }
1331
1332 void
1333 _initialize_m68hc11_tdep (void)
1334 {
1335 register_gdbarch_init (bfd_arch_m68hc11, m68hc11_gdbarch_init);
1336 register_gdbarch_init (bfd_arch_m68hc12, m68hc11_gdbarch_init);
1337
1338 add_com ("regs", class_vars, show_regs, "Print all registers");
1339 }
1340
This page took 0.07393 seconds and 4 git commands to generate.