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