daily update
[deliverable/binutils-gdb.git] / gdb / tic6x-tdep.c
CommitLineData
8cd64e00
YQ
1/* Target dependent code for GDB on TI C6x systems.
2
3 Copyright (C) 2010, 2011.
4 Free Software Foundation, Inc.
5 Contributed by Andrew Jenner <andrew@codesourcery.com>
6 Contributed by Yao Qi <yao@codesourcery.com>
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22
23#include "defs.h"
24#include "frame.h"
25#include "frame-unwind.h"
26#include "frame-base.h"
27#include "trad-frame.h"
28#include "dwarf2-frame.h"
29#include "symtab.h"
30#include "inferior.h"
31#include "gdbtypes.h"
32#include "gdbcore.h"
33#include "gdbcmd.h"
34#include "target.h"
35#include "dis-asm.h"
36#include "regcache.h"
37#include "value.h"
38#include "symfile.h"
39#include "arch-utils.h"
40#include "floatformat.h"
41#include "glibc-tdep.h"
42#include "infcall.h"
43#include "regset.h"
44#include "tramp-frame.h"
45#include "linux-tdep.h"
46#include "solib.h"
47#include "objfiles.h"
48#include "gdb_assert.h"
49#include "osabi.h"
50#include "tic6x-tdep.h"
51#include "language.h"
52#include "target-descriptions.h"
53
54#include "features/tic6x-c64xp.c"
55#include "features/tic6x-c64x.c"
56#include "features/tic6x-c62x.c"
57
58#define TIC6X_OPCODE_SIZE 4
59#define TIC6X_FETCH_PACKET_SIZE 32
60
61#define INST_S_BIT(INST) ((INST >> 1) & 1)
62#define INST_X_BIT(INST) ((INST >> 12) & 1)
63
64struct tic6x_unwind_cache
65{
66 /* The frame's base, optionally used by the high-level debug info. */
67 CORE_ADDR base;
68
69 /* The previous frame's inner most stack address. Used as this
70 frame ID's stack_addr. */
71 CORE_ADDR cfa;
72
73 /* The address of the first instruction in this function */
74 CORE_ADDR pc;
75
76 /* Which register holds the return address for the frame. */
77 int return_regnum;
78
79 /* The offset of register saved on stack. If register is not saved, the
80 corresponding element is -1. */
81 CORE_ADDR reg_saved[TIC6X_NUM_CORE_REGS];
82};
83
84
85/* Name of TI C6x core registers. */
86static const char *const tic6x_register_names[] =
87{
88 "A0", "A1", "A2", "A3", /* 0 1 2 3 */
89 "A4", "A5", "A6", "A7", /* 4 5 6 7 */
90 "A8", "A9", "A10", "A11", /* 8 9 10 11 */
91 "A12", "A13", "A14", "A15", /* 12 13 14 15 */
92 "B0", "B1", "B2", "B3", /* 16 17 18 19 */
93 "B4", "B5", "B6", "B7", /* 20 21 22 23 */
94 "B8", "B9", "B10", "B11", /* 24 25 26 27 */
95 "B12", "B13", "B14", "B15", /* 28 29 30 31 */
96 "CSR", "PC", /* 32 33 */
97};
98
99/* This array maps the arguments to the register number which passes argument
100 in function call according to C6000 ELF ABI. */
101static const int arg_regs[] = { 4, 20, 6, 22, 8, 24, 10, 26, 12, 28 };
102
103/* This is the implementation of gdbarch method register_name. */
104
105static const char *
106tic6x_register_name (struct gdbarch *gdbarch, int regno)
107{
108 if (regno < 0)
109 return NULL;
110
111 if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
112 return tdesc_register_name (gdbarch, regno);
113 else if (regno >= ARRAY_SIZE (tic6x_register_names))
114 return "";
115 else
116 return tic6x_register_names[regno];
117}
118
119/* This is the implementation of gdbarch method register_type. */
120
121static struct type *
122tic6x_register_type (struct gdbarch *gdbarch, int regno)
123{
124
125 if (regno == TIC6X_PC_REGNUM)
126 return builtin_type (gdbarch)->builtin_func_ptr;
127 else
128 return builtin_type (gdbarch)->builtin_uint32;
129}
130
131static void
132tic6x_setup_default (struct tic6x_unwind_cache *cache)
133{
134 int i;
135
136 for (i = 0; i < TIC6X_NUM_CORE_REGS; i++)
137 cache->reg_saved[i] = -1;
138}
139
140static unsigned long tic6x_fetch_instruction (struct gdbarch *, CORE_ADDR);
141static int tic6x_register_number (int reg, int side, int crosspath);
142
143/* Do a full analysis of the prologue at START_PC and update CACHE accordingly.
144 Bail out early if CURRENT_PC is reached. Returns the address of the first
145 instruction after the prologue. */
146
147CORE_ADDR
148tic6x_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR start_pc,
149 const CORE_ADDR current_pc,
150 struct tic6x_unwind_cache *cache,
151 struct frame_info *this_frame)
152{
153 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
154 unsigned long inst;
155 unsigned int src_reg, base_reg, dst_reg;
156 int i;
157 CORE_ADDR pc = start_pc;
158 CORE_ADDR return_pc = start_pc;
159 int frame_base_offset_to_sp = 0;
160 /* Counter of non-stw instructions after first insn ` sub sp, xxx, sp'. */
161 int non_stw_insn_counter = 0;
162
163 if (start_pc >= current_pc)
164 return_pc = current_pc;
165
166 cache->base = 0;
167
168 /* The landmarks in prologue is one or two SUB instructions to SP.
169 Instructions on setting up dsbt are in the last part of prologue, if
170 needed. In maxim, prologue can be divided to three parts by two
171 `sub sp, xx, sp' insns. */
172
173 /* Step 1: Look for the 1st and 2nd insn `sub sp, xx, sp', in which, the
174 2nd one is optional. */
175 while (pc < current_pc)
176 {
177 int offset = 0;
178
179 unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
180
181 if ((inst & 0x1ffc) == 0x1dc0 || (inst & 0x1ffc) == 0x1bc0
182 || (inst & 0x0ffc) == 0x9c0)
183 {
184 /* SUBAW/SUBAH/SUB, and src1 is ucst 5. */
185 unsigned int src2 = tic6x_register_number ((inst >> 18) & 0x1f,
186 INST_S_BIT (inst), 0);
187 unsigned int dst = tic6x_register_number ((inst >> 23) & 0x1f,
188 INST_S_BIT (inst), 0);
189
190 if (src2 == TIC6X_SP_REGNUM && dst == TIC6X_SP_REGNUM)
191 {
192 /* Extract const from insn SUBAW/SUBAH/SUB, and translate it to
193 offset. The constant offset is decoded in bit 13-17 in all
194 these three kinds of instructions. */
195 unsigned int ucst5 = (inst >> 13) & 0x1f;
196
197 if ((inst & 0x1ffc) == 0x1dc0) /* SUBAW */
198 frame_base_offset_to_sp += ucst5 << 2;
199 else if ((inst & 0x1ffc) == 0x1bc0) /* SUBAH */
200 frame_base_offset_to_sp += ucst5 << 1;
201 else if ((inst & 0x0ffc) == 0x9c0) /* SUB */
202 frame_base_offset_to_sp += ucst5;
203 else
204 gdb_assert_not_reached ("unexpected instruction");
205
206 return_pc = pc + 4;
207 }
208 }
209 else if ((inst & 0x174) == 0x74) /* stw SRC, *+b15(uconst) */
210 {
211 /* The y bit determines which file base is read from. */
212 base_reg = tic6x_register_number ((inst >> 18) & 0x1f,
213 (inst >> 7) & 1, 0);
214
215 if (base_reg == TIC6X_SP_REGNUM)
216 {
217 src_reg = tic6x_register_number ((inst >> 23) & 0x1f,
218 INST_S_BIT (inst), 0);
219
220 cache->reg_saved[src_reg] = ((inst >> 13) & 0x1f) << 2;
221
222 return_pc = pc + 4;
223 }
224 non_stw_insn_counter = 0;
225 }
226 else
227 {
228 non_stw_insn_counter++;
229 /* Following instruction sequence may be emitted in prologue:
230
231 <+0>: subah .D2 b15,28,b15
232 <+4>: or .L2X 0,a4,b0
233 <+8>: || stw .D2T2 b14,*+b15(56)
234 <+12>:[!b0] b .S1 0xe50e4c1c <sleep+220>
235 <+16>:|| stw .D2T1 a10,*+b15(48)
236 <+20>:stw .D2T2 b3,*+b15(52)
237 <+24>:stw .D2T1 a4,*+b15(40)
238
239 we should look forward for next instruction instead of breaking loop
240 here. So far, we allow almost two sequential non-stw instructions
241 in prologue. */
242 if (non_stw_insn_counter >= 2)
243 break;
244 }
245
246
247 pc += 4;
248 }
249 /* Step 2: Skip insn on setting up dsbt if it is. Usually, it looks like,
250 ldw .D2T2 *+b14(0),b14 */
251 inst = tic6x_fetch_instruction (gdbarch, pc);
252 /* The s bit determines which file dst will be loaded into, same effect as
253 other places. */
254 dst_reg = tic6x_register_number ((inst >> 23) & 0x1f, (inst >> 1) & 1, 0);
255 /* The y bit (bit 7), instead of s bit, determines which file base be
256 used. */
257 base_reg = tic6x_register_number ((inst >> 18) & 0x1f, (inst >> 7) & 1, 0);
258
259 if ((inst & 0x164) == 0x64 /* ldw */
260 && dst_reg == TIC6X_DP_REGNUM /* dst is B14 */
261 && base_reg == TIC6X_DP_REGNUM) /* baseR is B14 */
262 {
263 return_pc = pc + 4;
264 }
265
266 if (this_frame)
267 {
268 cache->base = get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM);
269
270 if (cache->reg_saved[TIC6X_FP_REGNUM] != -1)
271 {
272 /* If the FP now holds an offset from the CFA then this is a frame
273 which uses the frame pointer. */
274
275 cache->cfa = get_frame_register_unsigned (this_frame,
276 TIC6X_FP_REGNUM);
277 }
278 else
279 {
280 /* FP doesn't hold an offset from the CFA. If SP still holds an
281 offset from the CFA then we might be in a function which omits
282 the frame pointer. */
283
284 cache->cfa = cache->base + frame_base_offset_to_sp;
285 }
286 }
287
288 /* Adjust all the saved registers such that they contain addresses
289 instead of offsets. */
290 for (i = 0; i < TIC6X_NUM_CORE_REGS; i++)
291 if (cache->reg_saved[i] != -1)
292 cache->reg_saved[i] = cache->base + cache->reg_saved[i];
293
294 return return_pc;
295}
296
297/* This is the implementation of gdbarch method skip_prologue. */
298
299CORE_ADDR
300tic6x_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
301{
302 CORE_ADDR limit_pc;
303 CORE_ADDR func_addr;
304 struct tic6x_unwind_cache cache;
305
306 /* See if we can determine the end of the prologue via the symbol table.
307 If so, then return either PC, or the PC after the prologue, whichever is
308 greater. */
309 if (find_pc_partial_function (start_pc, NULL, &func_addr, NULL))
310 {
311 CORE_ADDR post_prologue_pc
312 = skip_prologue_using_sal (gdbarch, func_addr);
313 if (post_prologue_pc != 0)
314 return max (start_pc, post_prologue_pc);
315 }
316
317 /* Can't determine prologue from the symbol table, need to examine
318 instructions. */
319 return tic6x_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache,
320 NULL);
321}
322
323/* This is the implementation of gdbarch method breakpiont_from_pc. */
324
325const unsigned char*
326tic6x_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *bp_addr,
327 int *bp_size)
328{
329 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
330
331 *bp_size = 4;
332
333 if (tdep == NULL || tdep->breakpoint == NULL)
334 {
335 if (BFD_ENDIAN_BIG == gdbarch_byte_order_for_code (gdbarch))
336 return tic6x_bkpt_illegal_opcode_be;
337 else
338 return tic6x_bkpt_illegal_opcode_le;
339 }
340 else
341 return tdep->breakpoint;
342}
343
344/* This is the implementation of gdbarch method print_insn. */
345
346static int
347tic6x_print_insn (bfd_vma memaddr, disassemble_info *info)
348{
349 return print_insn_tic6x (memaddr, info);
350}
351
352static void
353tic6x_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
354 struct dwarf2_frame_state_reg *reg,
355 struct frame_info *this_frame)
356{
357 /* Mark the PC as the destination for the return address. */
358 if (regnum == gdbarch_pc_regnum (gdbarch))
359 reg->how = DWARF2_FRAME_REG_RA;
360
361 /* Mark the stack pointer as the call frame address. */
362 else if (regnum == gdbarch_sp_regnum (gdbarch))
363 reg->how = DWARF2_FRAME_REG_CFA;
364
365 /* The above was taken from the default init_reg in dwarf2-frame.c
366 while the below is c6x specific. */
367
368 /* Callee save registers. The ABI designates A10-A15 and B10-B15 as
369 callee-save. */
370 else if ((regnum >= 10 && regnum <= 15) || (regnum >= 26 && regnum <= 31))
371 reg->how = DWARF2_FRAME_REG_SAME_VALUE;
372 else
373 /* All other registers are caller-save. */
374 reg->how = DWARF2_FRAME_REG_UNDEFINED;
375}
376
377/* This is the implementation of gdbarch method unwind_pc. */
378
379static CORE_ADDR
380tic6x_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
381{
382 gdb_byte buf[8];
383
384 frame_unwind_register (next_frame, TIC6X_PC_REGNUM, buf);
385 return extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr);
386}
387
388/* This is the implementation of gdbarch method unwind_sp. */
389
390static CORE_ADDR
391tic6x_unwind_sp (struct gdbarch *gdbarch, struct frame_info *this_frame)
392{
393 return frame_unwind_register_unsigned (this_frame, TIC6X_SP_REGNUM);
394}
395
396
397/* Frame base handling. */
398
399struct tic6x_unwind_cache*
400tic6x_frame_unwind_cache (struct frame_info *this_frame,
401 void **this_prologue_cache)
402{
403 struct gdbarch *gdbarch = get_frame_arch (this_frame);
404 CORE_ADDR current_pc;
405 struct tic6x_unwind_cache *cache;
406 int i;
407
408 if (*this_prologue_cache)
409 return *this_prologue_cache;
410
411 cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
412 (*this_prologue_cache) = cache;
413
414 cache->return_regnum = TIC6X_RA_REGNUM;
415
416 tic6x_setup_default (cache);
417
418 cache->pc = get_frame_func (this_frame);
419 current_pc = get_frame_pc (this_frame);
420
421 /* Prologue analysis does the rest... */
422 if (cache->pc != 0)
423 tic6x_analyze_prologue (gdbarch, cache->pc, current_pc, cache, this_frame);
424
425 return cache;
426}
427
428static void
429tic6x_frame_this_id (struct frame_info *this_frame, void **this_cache,
430 struct frame_id *this_id)
431{
432 struct tic6x_unwind_cache *cache =
433 tic6x_frame_unwind_cache (this_frame, this_cache);
434
435 /* This marks the outermost frame. */
436 if (cache->base == 0)
437 return;
438
439 (*this_id) = frame_id_build (cache->cfa, cache->pc);
440}
441
442static struct value *
443tic6x_frame_prev_register (struct frame_info *this_frame, void **this_cache,
444 int regnum)
445{
446 struct tic6x_unwind_cache *cache =
447 tic6x_frame_unwind_cache (this_frame, this_cache);
448
449 gdb_assert (regnum >= 0);
450
451 /* The PC of the previous frame is stored in the RA register of
452 the current frame. Frob regnum so that we pull the value from
453 the correct place. */
454 if (regnum == TIC6X_PC_REGNUM)
455 regnum = cache->return_regnum;
456
457 if (regnum == TIC6X_SP_REGNUM && cache->cfa)
458 return frame_unwind_got_constant (this_frame, regnum, cache->cfa);
459
460 /* If we've worked out where a register is stored then load it from
461 there. */
462 if (regnum < TIC6X_NUM_CORE_REGS && cache->reg_saved[regnum] != -1)
463 return frame_unwind_got_memory (this_frame, regnum,
464 cache->reg_saved[regnum]);
465
466 return frame_unwind_got_register (this_frame, regnum, regnum);
467}
468
469static CORE_ADDR
470tic6x_frame_base_address (struct frame_info *this_frame, void **this_cache)
471{
472 struct tic6x_unwind_cache *info
473 = tic6x_frame_unwind_cache (this_frame, this_cache);
474 return info->base;
475}
476
477static const struct frame_unwind tic6x_frame_unwind =
478{
479 NORMAL_FRAME,
480 default_frame_unwind_stop_reason,
481 tic6x_frame_this_id,
482 tic6x_frame_prev_register,
483 NULL,
484 default_frame_sniffer
485};
486
487static const struct frame_base tic6x_frame_base =
488{
489 &tic6x_frame_unwind,
490 tic6x_frame_base_address,
491 tic6x_frame_base_address,
492 tic6x_frame_base_address
493};
494
495
496static struct tic6x_unwind_cache *
497tic6x_make_stub_cache (struct frame_info *this_frame)
498{
499 struct tic6x_unwind_cache *cache;
500
501 cache = FRAME_OBSTACK_ZALLOC (struct tic6x_unwind_cache);
502
503 cache->return_regnum = TIC6X_RA_REGNUM;
504
505 tic6x_setup_default (cache);
506
507 cache->cfa = get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM);
508
509 return cache;
510}
511
512static void
513tic6x_stub_this_id (struct frame_info *this_frame, void **this_cache,
514 struct frame_id *this_id)
515{
516 struct tic6x_unwind_cache *cache;
517
518 if (*this_cache == NULL)
519 *this_cache = tic6x_make_stub_cache (this_frame);
520 cache = *this_cache;
521
522 *this_id = frame_id_build (cache->cfa, get_frame_pc (this_frame));
523}
524
525static int
526tic6x_stub_unwind_sniffer (const struct frame_unwind *self,
527 struct frame_info *this_frame,
528 void **this_prologue_cache)
529{
530 CORE_ADDR addr_in_block;
531
532 addr_in_block = get_frame_address_in_block (this_frame);
533 if (in_plt_section (addr_in_block, NULL))
534 return 1;
535
536 return 0;
537}
538
539static const struct frame_unwind tic6x_stub_unwind =
540{
541 NORMAL_FRAME,
542 default_frame_unwind_stop_reason,
543 tic6x_stub_this_id,
544 tic6x_frame_prev_register,
545 NULL,
546 tic6x_stub_unwind_sniffer
547};
548
549/* Return the instruction on address PC. */
550
551static unsigned long
552tic6x_fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR pc)
553{
554 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
555 return read_memory_unsigned_integer (pc, TIC6X_OPCODE_SIZE, byte_order);
556}
557
558/* Compute the condition of INST if it is a conditional instruction. Always
559 return 1 if INST is not a conditional instruction. */
560
561static int
562tic6x_condition_true (struct frame_info *frame, unsigned long inst)
563{
564 int register_number;
565 int register_value;
566 static const int register_numbers[8] = { -1, 16, 17, 18, 1, 2, 0, -1 };
567
568 register_number = register_numbers[(inst >> 29) & 7];
569 if (register_number == -1)
570 return 1;
571
572 register_value = get_frame_register_signed (frame, register_number);
573 if ((inst & 0x10000000) != 0)
574 return register_value == 0;
575 return register_value != 0;
576}
577
578/* Get the register number by decoding raw bits REG, SIDE, and CROSSPATH in
579 instruction. */
580
581static int
582tic6x_register_number (int reg, int side, int crosspath)
583{
584 int r = (reg & 15) | ((crosspath ^ side) << 4);
585 if ((reg & 16) != 0) /* A16 - A31, B16 - B31 */
586 r += 37;
587 return r;
588}
589
590static int
591tic6x_extract_signed_field (int value, int low_bit, int bits)
592{
593 int mask = (1 << bits) - 1;
594 int r = (value >> low_bit) & mask;
595 if ((r & (1 << (bits - 1))) != 0)
596 r -= mask + 1;
597 return r;
598}
599
600/* Determine where to set a single step breakpoint. */
601
602static CORE_ADDR
603tic6x_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
604{
605 struct gdbarch *gdbarch = get_frame_arch (frame);
606 unsigned long inst;
607 int offset;
608 int register_number;
609 int last = 0;
610
611 do
612 {
613 inst = tic6x_fetch_instruction (gdbarch, pc);
614
615 last = !(inst & 1);
616
617 if (inst == TIC6X_INST_SWE)
618 {
619 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
620
621 if (tdep->syscall_next_pc != NULL)
622 return tdep->syscall_next_pc (frame);
623 }
624
625 if (tic6x_condition_true (frame, inst))
626 {
627 if ((inst & 0x0000007c) == 0x00000010)
628 {
629 /* B with displacement */
630 pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
631 pc += tic6x_extract_signed_field (inst, 7, 21) << 2;
632 break;
633 }
634 if ((inst & 0x0f83effc) == 0x00000360)
635 {
636 /* B with register */
637
638 register_number = tic6x_register_number ((inst >> 18) & 0x1f,
639 INST_S_BIT (inst),
640 INST_X_BIT (inst));
641 pc = get_frame_register_unsigned (frame, register_number);
642 break;
643 }
644 if ((inst & 0x00001ffc) == 0x00001020)
645 {
646 /* BDEC */
647 register_number = tic6x_register_number ((inst >> 23) & 0x1f,
648 INST_S_BIT (inst), 0);
649 if (get_frame_register_signed (frame, register_number) >= 0)
650 {
651 pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
652 pc += tic6x_extract_signed_field (inst, 7, 10) << 2;
653 }
654 break;
655 }
656 if ((inst & 0x00001ffc) == 0x00000120)
657 {
658 /* BNOP with displacement */
659 pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
660 pc += tic6x_extract_signed_field (inst, 16, 12) << 2;
661 break;
662 }
663 if ((inst & 0x0f830ffe) == 0x00800362)
664 {
665 /* BNOP with register */
666 register_number = tic6x_register_number ((inst >> 18) & 0x1f,
667 1, INST_X_BIT (inst));
668 pc = get_frame_register_unsigned (frame, register_number);
669 break;
670 }
671 if ((inst & 0x00001ffc) == 0x00000020)
672 {
673 /* BPOS */
674 register_number = tic6x_register_number ((inst >> 23) & 0x1f,
675 INST_S_BIT (inst), 0);
676 if (get_frame_register_signed (frame, register_number) >= 0)
677 {
678 pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
679 pc += tic6x_extract_signed_field (inst, 13, 10) << 2;
680 }
681 break;
682 }
683 if ((inst & 0xf000007c) == 0x10000010)
684 {
685 /* CALLP */
686 pc &= ~(TIC6X_FETCH_PACKET_SIZE - 1);
687 pc += tic6x_extract_signed_field (inst, 7, 21) << 2;
688 break;
689 }
690 }
691 pc += TIC6X_OPCODE_SIZE;
692 }
693 while (!last);
694 return pc;
695}
696
697/* This is the implementation of gdbarch method software_single_step. */
698
699int
700tic6x_software_single_step (struct frame_info *frame)
701{
702 struct gdbarch *gdbarch = get_frame_arch (frame);
703 struct address_space *aspace = get_frame_address_space (frame);
704 CORE_ADDR next_pc = tic6x_get_next_pc (frame, get_frame_pc (frame));
705
706 insert_single_step_breakpoint (gdbarch, aspace, next_pc);
707
708 return 1;
709}
710
711/* This is the implementation of gdbarch method frame_align. */
712
713static CORE_ADDR
714tic6x_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
715{
716 return align_down (addr, 8);
717}
718
719/* This is the implementation of gdbarch method register_to_value. */
720
721static int
722tic6x_register_to_value (struct frame_info *frame, int regnum,
723 struct type *type, gdb_byte * to,
724 int *optimizedp, int *unavailablep)
725{
726 get_frame_register (frame, regnum, (char *) to);
727 *optimizedp = *unavailablep = 0;
728 return 1;
729}
730
731/* This is the implementation of gdbarch method value_to_register. */
732
733static void
734tic6x_value_to_register (struct frame_info *frame, int regnum,
735 struct type *type, const gdb_byte *from)
736{
737 put_frame_register (frame, regnum, from);
738}
739
740/* Given a return value in REGCACHE with a type VALTYPE, extract and copy its
741 value into VALBUF. */
742
743static void
744tic6x_extract_return_value (struct type *valtype, struct regcache *regcache,
745 enum bfd_endian byte_order, gdb_byte *valbuf)
746{
747 int len = TYPE_LENGTH (valtype);
748
749 /* pointer types are returned in register A4,
750 up to 32-bit types in A4
751 up to 64-bit types in A5:A4 */
752 if (len <= 4)
753 {
754 /* In big-endian,
755 - one-byte structure or union occupies the LSB of single even register.
756 - for two-byte structure or union, the first byte occupies byte 1 of
757 register and the second byte occupies byte 0.
758 so, we read the contents in VAL from the LSBs of register. */
759 if (len < 3 && byte_order == BFD_ENDIAN_BIG)
760 regcache_cooked_read_part (regcache, TIC6X_A4_REGNUM, 4 - len, len,
761 valbuf);
762 else
763 regcache_cooked_read (regcache, TIC6X_A4_REGNUM, valbuf);
764 }
765 else if (len <= 8)
766 {
767 /* For a 5-8 byte structure or union in big-endian, the first byte
768 occupies byte 3 (the MSB) of the upper (odd) register and the
769 remaining bytes fill the decreasingly significant bytes. 5-7
770 byte structures or unions have padding in the LSBs of the
771 lower (even) register. */
772 if (byte_order == BFD_ENDIAN_BIG)
773 {
774 regcache_cooked_read (regcache, TIC6X_A4_REGNUM, valbuf + 4);
775 regcache_cooked_read (regcache, TIC6X_A5_REGNUM, valbuf);
776 }
777 else
778 {
779 regcache_cooked_read (regcache, TIC6X_A4_REGNUM, valbuf);
780 regcache_cooked_read (regcache, TIC6X_A5_REGNUM, valbuf + 4);
781 }
782 }
783}
784
785/* Write into appropriate registers a function return value
786 of type TYPE, given in virtual format. */
787
788static void
789tic6x_store_return_value (struct type *valtype, struct regcache *regcache,
790 enum bfd_endian byte_order, const gdb_byte *valbuf)
791{
792 int len = TYPE_LENGTH (valtype);
793
794 /* return values of up to 8 bytes are returned in A5:A4 */
795
796 if (len <= 4)
797 {
798 if (len < 3 && byte_order == BFD_ENDIAN_BIG)
799 regcache_cooked_write_part (regcache, TIC6X_A4_REGNUM, 4 - len, len,
800 valbuf);
801 else
802 regcache_cooked_write (regcache, TIC6X_A4_REGNUM, valbuf);
803 }
804 else if (len <= 8)
805 {
806 if (byte_order == BFD_ENDIAN_BIG)
807 {
808 regcache_cooked_write (regcache, TIC6X_A4_REGNUM, valbuf + 4);
809 regcache_cooked_write (regcache, TIC6X_A5_REGNUM, valbuf);
810 }
811 else
812 {
813 regcache_cooked_write (regcache, TIC6X_A4_REGNUM, valbuf);
814 regcache_cooked_write (regcache, TIC6X_A5_REGNUM, valbuf + 4);
815 }
816 }
817}
818
819/* This is the implementation of gdbarch method return_value. */
820
821static enum return_value_convention
822tic6x_return_value (struct gdbarch *gdbarch, struct type *func_type,
823 struct type *type, struct regcache *regcache,
824 gdb_byte *readbuf, const gdb_byte *writebuf)
825{
826 if (TYPE_LENGTH (type) > 8)
827 return RETURN_VALUE_STRUCT_CONVENTION;
828
829 if (readbuf)
830 tic6x_extract_return_value (type, regcache,
831 gdbarch_byte_order (gdbarch), readbuf);
832 if (writebuf)
833 tic6x_store_return_value (type, regcache,
834 gdbarch_byte_order (gdbarch), writebuf);
835
836 return RETURN_VALUE_REGISTER_CONVENTION;
837}
838
839/* This is the implementation of gdbarch method dummy_id. */
840
841static struct frame_id
842tic6x_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
843{
844 return frame_id_build
845 (get_frame_register_unsigned (this_frame, TIC6X_SP_REGNUM),
846 get_frame_pc (this_frame));
847}
848
849/* Get the alignment requirement of TYPE. */
850
851static int
852tic6x_arg_type_alignment (struct type *type)
853{
854 int len = TYPE_LENGTH (check_typedef (type));
855 enum type_code typecode = TYPE_CODE (check_typedef (type));
856
857 if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
858 {
859 /* The stack alignment of a structure (and union) passed by value is the
860 smallest power of two greater than or equal to its size.
861 This cannot exceed 8 bytes, which is the largest allowable size for
862 a structure passed by value. */
863
864 if (len <= 2)
865 return len;
866 else if (len <= 4)
867 return 4;
868 else if (len <= 8)
869 return 8;
870 else
871 gdb_assert_not_reached ("unexpected length of data");
872 }
873 else
874 {
875 if (len <= 4)
876 return 4;
877 else if (len == 8)
878 {
879 if (typecode == TYPE_CODE_COMPLEX)
880 return 4;
881 else
882 return 8;
883 }
884 else if (len == 16)
885 {
886 if (typecode == TYPE_CODE_COMPLEX)
887 return 8;
888 else
889 return 16;
890 }
891 else
892 internal_error (__FILE__, __LINE__, _("unexpected length %d of type"),
893 len);
894 }
895}
896
897/* This is the implementation of gdbarch method push_dummy_call. */
898
899static CORE_ADDR
900tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
901 struct regcache *regcache, CORE_ADDR bp_addr,
902 int nargs, struct value **args, CORE_ADDR sp,
903 int struct_return, CORE_ADDR struct_addr)
904{
905 int argreg = 0;
906 int argnum;
907 int len = 0;
908 int stack_offset = 4;
909 int references_offset = 4;
910 CORE_ADDR func_addr = find_function_addr (function, NULL);
911 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
912 struct type *func_type = value_type (function);
913 /* The first arg passed on stack. Mostly the first 10 args are passed by
914 registers. */
915 int first_arg_on_stack = 10;
916 /* If this inf-call is a cpp method call, and return value is passed by
917 reference, this flag is set to 1, otherwise set to 0. We need this flag
918 because computation of the return location in
919 infcall.c:call_function_by_hand is wrong for C6000 ELF ABI. In
920 call_function_by_hand, the language is considered first, and then
921 target ABI is considered. If language_pass_by_reference returns true,
922 the return location is passed as the first parameter to the function,
923 which is conflict with C6000 ELF ABI. If this flag is true, we should
924 adjust args and return locations accordingly to comply with C6000 ELF
925 ABI. */
926 int cplus_return_struct_by_reference = 0;
927
928 if (current_language->la_language == language_cplus)
929 {
930 struct type *values_type;
931
932 find_function_addr (function, &values_type);
933
934 if (values_type)
935 {
936 CHECK_TYPEDEF (values_type);
937 if (language_pass_by_reference (values_type))
938 cplus_return_struct_by_reference = 1;
939 }
940
941 }
942 /* Set the return address register to point to the entry point of
943 the program, where a breakpoint lies in wait. */
944 regcache_cooked_write_unsigned (regcache, TIC6X_RA_REGNUM, bp_addr);
945
946 /* The caller must pass an argument in A3 containing a destination address
947 for the returned value. The callee returns the object by copying it to
948 the address in A3. */
949 if (struct_return)
950 regcache_cooked_write_unsigned (regcache, 3, struct_addr);
951 else if (cplus_return_struct_by_reference)
952 /* When cplus_return_struct_by_reference is 1, means local variable
953 lang_struct_return in call_function_by_hand is 1, so struct is
954 returned by reference, even STRUCT_RETURN is 0. Note that STRUCT_ADDR
955 is still valid in this case. */
956 regcache_cooked_write_unsigned (regcache, 3, struct_addr);
957
958 /* Determine the type of this function. */
959 func_type = check_typedef (func_type);
960 if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
961 func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
962
963 gdb_assert (TYPE_CODE (func_type) == TYPE_CODE_FUNC
964 || TYPE_CODE (func_type) == TYPE_CODE_METHOD);
965
966 /* For a variadic C function, the last explicitly declared argument and all
967 remaining arguments are passed on the stack. */
968 if (TYPE_VARARGS (func_type))
969 first_arg_on_stack = TYPE_NFIELDS (func_type) - 1;
970
971 /* Now make space on the stack for the args. If
972 cplus_return_struct_by_reference is 1, means GDB pass an extra parameter
973 in ARGS, which is useless here, skip it. */
974 for (argnum = cplus_return_struct_by_reference; argnum < nargs; argnum++)
975 {
976 int len = align_up (TYPE_LENGTH (value_type (args[argnum])), 4);
977 if (argnum >= 10 - argreg)
978 references_offset += len;
979 stack_offset += len;
980 }
981 sp -= stack_offset;
982 /* SP should be 8-byte aligned, see C6000 ABI section 4.4.1
983 Stack Alignment. */
984 sp = align_down (sp, 8);
985 stack_offset = 4;
986
987 /* Now load as many as possible of the first arguments into
988 registers, and push the rest onto the stack. Loop through args
989 from first to last. */
990 for (argnum = cplus_return_struct_by_reference; argnum < nargs; argnum++)
991 {
992 const gdb_byte *val;
993 struct value *arg = args[argnum];
994 struct type *arg_type = check_typedef (value_type (arg));
995 int len = TYPE_LENGTH (arg_type);
996 enum type_code typecode = TYPE_CODE (arg_type);
997
998 val = value_contents (arg);
999
1000 /* Copy the argument to general registers or the stack in
1001 register-sized pieces. */
1002 if (argreg < first_arg_on_stack)
1003 {
1004 if (len <= 4)
1005 {
1006 if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
1007 {
1008 /* In big-endian,
1009 - one-byte structure or union occupies the LSB of single
1010 even register.
1011 - for two-byte structure or union, the first byte
1012 occupies byte 1 of register and the second byte occupies
1013 byte 0.
1014 so, we write the contents in VAL to the lsp of
1015 register. */
1016 if (len < 3 && byte_order == BFD_ENDIAN_BIG)
1017 regcache_cooked_write_part (regcache, arg_regs[argreg],
1018 4 - len, len, val);
1019 else
1020 regcache_cooked_write (regcache, arg_regs[argreg], val);
1021 }
1022 else
1023 {
1024 /* The argument is being passed by value in a single
1025 register. */
1026 CORE_ADDR regval = extract_unsigned_integer (val, len,
1027 byte_order);
1028
1029 regcache_cooked_write_unsigned (regcache, arg_regs[argreg],
1030 regval);
1031 }
1032 }
1033 else
1034 {
1035 if (len <= 8)
1036 {
1037 if (typecode == TYPE_CODE_STRUCT
1038 || typecode == TYPE_CODE_UNION)
1039 {
1040 /* For a 5-8 byte structure or union in big-endian, the
1041 first byte occupies byte 3 (the MSB) of the upper (odd)
1042 register and the remaining bytes fill the decreasingly
1043 significant bytes. 5-7 byte structures or unions have
1044 padding in the LSBs of the lower (even) register. */
1045 if (byte_order == BFD_ENDIAN_BIG)
1046 {
1047 regcache_cooked_write (regcache,
1048 arg_regs[argreg] + 1, val);
1049 regcache_cooked_write_part (regcache,
1050 arg_regs[argreg], 0,
1051 len - 4, val + 4);
1052 }
1053 else
1054 {
1055 regcache_cooked_write (regcache, arg_regs[argreg],
1056 val);
1057 regcache_cooked_write_part (regcache,
1058 arg_regs[argreg] + 1, 0,
1059 len - 4, val + 4);
1060 }
1061 }
1062 else
1063 {
1064 /* The argument is being passed by value in a pair of
1065 registers. */
1066 ULONGEST regval = extract_unsigned_integer (val, len,
1067 byte_order);
1068
1069 regcache_cooked_write_unsigned (regcache,
1070 arg_regs[argreg],
1071 regval);
1072 regcache_cooked_write_unsigned (regcache,
1073 arg_regs[argreg] + 1,
1074 regval >> 32);
1075 }
1076 }
1077 else
1078 {
1079 /* The argument is being passed by reference in a single
1080 register. */
1081 CORE_ADDR addr;
1082
1083 /* It is not necessary to adjust REFERENCES_OFFSET to
1084 8-byte aligned in some cases, in which 4-byte alignment
1085 is sufficient. For simplicity, we adjust
1086 REFERENCES_OFFSET to 8-byte aligned. */
1087 references_offset = align_up (references_offset, 8);
1088
1089 addr = sp + references_offset;
1090 write_memory (addr, val, len);
1091 references_offset += align_up (len, 4);
1092 regcache_cooked_write_unsigned (regcache, arg_regs[argreg],
1093 addr);
1094 }
1095 }
1096 argreg++;
1097 }
1098 else
1099 {
1100 /* The argument is being passed on the stack. */
1101 CORE_ADDR addr;
1102
1103 /* There are six different cases of alignment, and these rules can
1104 be found in tic6x_arg_type_alignment:
1105
1106 1) 4-byte aligned if size is less than or equal to 4 byte, such
1107 as short, int, struct, union etc.
1108 2) 8-byte aligned if size is less than or equal to 8-byte, such
1109 as double, long long,
1110 3) 4-byte aligned if it is of type _Complex float, even its size
1111 is 8-byte.
1112 4) 8-byte aligned if it is of type _Complex double or _Complex
1113 long double, even its size is 16-byte. Because, the address of
1114 variable is passed as reference.
1115 5) struct and union larger than 8-byte are passed by reference, so
1116 it is 4-byte aligned.
1117 6) struct and union of size between 4 byte and 8 byte varies.
1118 alignment of struct variable is the alignment of its first field,
1119 while alignment of union variable is the max of all its fields'
1120 alignment. */
1121
1122 if (len <= 4)
1123 ; /* Default is 4-byte aligned. Nothing to be done. */
1124 else if (len <= 8)
1125 stack_offset = align_up (stack_offset,
1126 tic6x_arg_type_alignment (arg_type));
1127 else if (len == 16)
1128 {
1129 /* _Complex double or _Complex long double */
1130 if (typecode == TYPE_CODE_COMPLEX)
1131 {
1132 /* The argument is being passed by reference on stack. */
1133 CORE_ADDR addr;
1134 references_offset = align_up (references_offset, 8);
1135
1136 addr = sp + references_offset;
1137 /* Store variable on stack. */
1138 write_memory (addr, val, len);
1139
1140 references_offset += align_up (len, 4);
1141
1142 /* Pass the address of variable on stack as reference. */
1143 store_unsigned_integer ((gdb_byte *) val, 4, byte_order,
1144 addr);
1145 len = 4;
1146
1147 }
1148 else
1149 internal_error (__FILE__, __LINE__,
1150 _("unexpected type %d of arg %d"),
1151 typecode, argnum);
1152 }
1153 else
1154 internal_error (__FILE__, __LINE__,
1155 _("unexpected length %d of arg %d"), len, argnum);
1156
1157 addr = sp + stack_offset;
1158 write_memory (addr, val, len);
1159 stack_offset += align_up (len, 4);
1160 }
1161 }
1162
1163 regcache_cooked_write_signed (regcache, TIC6X_SP_REGNUM, sp);
1164
1165 /* Return adjusted stack pointer. */
1166 return sp;
1167}
1168
1169/* This is the implementation of gdbarch method in_function_epilogue_p. */
1170
1171static int
1172tic6x_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
1173{
1174 unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
1175 /* Normally, the epilogue is composed by instruction `b .S2 b3'. */
1176 if ((inst & 0x0f83effc) == 0x360)
1177 {
1178 unsigned int src2 = tic6x_register_number ((inst >> 18) & 0x1f,
1179 INST_S_BIT (inst),
1180 INST_X_BIT (inst));
1181 if (src2 == TIC6X_RA_REGNUM)
1182 return 1;
1183 }
1184
1185 return 0;
1186}
1187
1188/* This is the implementation of gdbarch method get_longjmp_target. */
1189
1190static int
1191tic6x_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
1192{
1193 struct gdbarch *gdbarch = get_frame_arch (frame);
1194 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
1195 CORE_ADDR jb_addr;
1196 char buf[4];
1197
1198 /* JMP_BUF is passed by reference in A4. */
1199 jb_addr = get_frame_register_unsigned (frame, 4);
1200
1201 /* JMP_BUF contains 13 elements of type int, and return address is stored
1202 in the last slot. */
1203 if (target_read_memory (jb_addr + 12 * 4, buf, 4))
1204 return 0;
1205
1206 *pc = extract_unsigned_integer (buf, 4, byte_order);
1207
1208 return 1;
1209}
1210
1211static struct gdbarch *
1212tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1213{
1214 struct gdbarch *gdbarch;
1215 struct gdbarch_tdep *tdep;
1216 struct tdesc_arch_data *tdesc_data = NULL;
1217 const struct target_desc *tdesc = info.target_desc;
1218 int has_gp = 0;
1219
1220 /* Check any target description for validity. */
1221 if (tdesc_has_registers (tdesc))
1222 {
1223 const struct tdesc_feature *feature;
1224 int valid_p, i;
1225
1226 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.core");
1227
1228 if (feature == NULL)
1229 return NULL;
1230
1231 tdesc_data = tdesc_data_alloc ();
1232
1233 valid_p = 1;
1234 for (i = 0; i < 32; i++) /* A0 - A15, B0 - B15 */
1235 valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
1236 tic6x_register_names[i]);
1237
1238 /* CSR */
1239 valid_p &= tdesc_numbered_register (feature, tdesc_data, i++,
1240 tic6x_register_names[TIC6X_CSR_REGNUM]);
1241 valid_p &= tdesc_numbered_register (feature, tdesc_data, i++,
1242 tic6x_register_names[TIC6X_PC_REGNUM]);
1243
1244 if (!valid_p)
1245 {
1246 tdesc_data_cleanup (tdesc_data);
1247 return NULL;
1248 }
1249
1250 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.gp");
1251 if (feature)
1252 {
1253 int j = 0;
1254 static const char *const gp[] =
1255 {
1256 "A16", "A17", "A18", "A19", "A20", "A21", "A22", "A23",
1257 "A24", "A25", "A26", "A27", "A28", "A29", "A30", "A31",
1258 "B16", "B17", "B18", "B19", "B20", "B21", "B22", "B23",
1259 "B24", "B25", "B26", "B27", "B28", "B29", "B30", "B31",
1260 };
1261
1262 has_gp = 1;
1263 valid_p = 1;
1264 for (j = 0; j < 32; j++) /* A16 - A31, B16 - B31 */
1265 valid_p &= tdesc_numbered_register (feature, tdesc_data, i++,
1266 gp[j]);
1267
1268 if (!valid_p)
1269 {
1270 tdesc_data_cleanup (tdesc_data);
1271 return NULL;
1272 }
1273 }
1274
1275 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.tic6x.c6xp");
1276 if (feature)
1277 {
1278 valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "TSR");
1279 valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "ILC");
1280 valid_p &= tdesc_numbered_register (feature, tdesc_data, i++, "RILC");
1281
1282 if (!valid_p)
1283 {
1284 tdesc_data_cleanup (tdesc_data);
1285 return NULL;
1286 }
1287 }
1288
1289 }
1290
1291 /* Find a candidate among extant architectures. */
1292 for (arches = gdbarch_list_lookup_by_info (arches, &info);
1293 arches != NULL;
1294 arches = gdbarch_list_lookup_by_info (arches->next, &info))
1295 {
1296 tdep = gdbarch_tdep (arches->gdbarch);
1297
1298 if (has_gp != tdep->has_gp)
1299 continue;
1300
1301 if (tdep && tdep->breakpoint)
1302 return arches->gdbarch;
1303 }
1304
1305 tdep = xcalloc (1, sizeof (struct gdbarch_tdep));
1306
1307 tdep->has_gp = has_gp;
1308 gdbarch = gdbarch_alloc (&info, tdep);
1309
1310 /* Data type sizes. */
1311 set_gdbarch_ptr_bit (gdbarch, 32);
1312 set_gdbarch_addr_bit (gdbarch, 32);
1313 set_gdbarch_short_bit (gdbarch, 16);
1314 set_gdbarch_int_bit (gdbarch, 32);
1315 set_gdbarch_long_bit (gdbarch, 32);
1316 set_gdbarch_long_long_bit (gdbarch, 64);
1317 set_gdbarch_float_bit (gdbarch, 32);
1318 set_gdbarch_double_bit (gdbarch, 64);
1319
1320 set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
1321 set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
1322
1323 /* The register set. */
1324 set_gdbarch_num_regs (gdbarch, TIC6X_NUM_REGS);
1325 set_gdbarch_sp_regnum (gdbarch, TIC6X_SP_REGNUM);
1326 set_gdbarch_pc_regnum (gdbarch, TIC6X_PC_REGNUM);
1327
1328 set_gdbarch_register_name (gdbarch, tic6x_register_name);
1329 set_gdbarch_register_type (gdbarch, tic6x_register_type);
1330
1331 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1332
1333 set_gdbarch_skip_prologue (gdbarch, tic6x_skip_prologue);
1334 set_gdbarch_breakpoint_from_pc (gdbarch, tic6x_breakpoint_from_pc);
1335
1336 set_gdbarch_unwind_pc (gdbarch, tic6x_unwind_pc);
1337 set_gdbarch_unwind_sp (gdbarch, tic6x_unwind_sp);
1338
1339 /* Unwinding. */
1340 dwarf2_append_unwinders (gdbarch);
1341
1342 frame_unwind_append_unwinder (gdbarch, &tic6x_stub_unwind);
1343 frame_unwind_append_unwinder (gdbarch, &tic6x_frame_unwind);
1344
1345 dwarf2_frame_set_init_reg (gdbarch, tic6x_dwarf2_frame_init_reg);
1346
1347 /* Single stepping. */
1348 set_gdbarch_software_single_step (gdbarch, tic6x_software_single_step);
1349
1350 set_gdbarch_print_insn (gdbarch, tic6x_print_insn);
1351
1352 /* Call dummy code. */
1353 set_gdbarch_frame_align (gdbarch, tic6x_frame_align);
1354
1355 set_gdbarch_register_to_value (gdbarch, tic6x_register_to_value);
1356 set_gdbarch_value_to_register (gdbarch, tic6x_value_to_register);
1357
1358 set_gdbarch_return_value (gdbarch, tic6x_return_value);
1359
1360 set_gdbarch_dummy_id (gdbarch, tic6x_dummy_id);
1361
1362 /* Enable inferior call support. */
1363 set_gdbarch_push_dummy_call (gdbarch, tic6x_push_dummy_call);
1364
1365 set_gdbarch_get_longjmp_target (gdbarch, tic6x_get_longjmp_target);
1366
1367 set_gdbarch_in_function_epilogue_p (gdbarch, tic6x_in_function_epilogue_p);
1368
1369 /* Hook in ABI-specific overrides, if they have been registered. */
1370 gdbarch_init_osabi (info, gdbarch);
1371
1372 if (tdesc_data)
1373 tdesc_use_registers (gdbarch, tdesc, tdesc_data);
1374
1375 return gdbarch;
1376}
1377
1378void
1379_initialize_tic6x_tdep (void)
1380{
1381 register_gdbarch_init (bfd_arch_tic6x, tic6x_gdbarch_init);
1382
1383 initialize_tdesc_tic6x_c64xp ();
1384 initialize_tdesc_tic6x_c64x ();
1385 initialize_tdesc_tic6x_c62x ();
1386}
This page took 0.088701 seconds and 4 git commands to generate.