GDB (xrefs)

/tmp/gdb-8.1/gdb/ft32-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for FT32.
2
3 Copyright (C) 2009-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "frame.h"
22 #include "frame-unwind.h"
23 #include "frame-base.h"
24 #include "symtab.h"
25 #include "gdbtypes.h"
26 #include "gdbcmd.h"
27 #include "gdbcore.h"
28 #include "value.h"
29 #include "inferior.h"
30 #include "symfile.h"
31 #include "objfiles.h"
32 #include "osabi.h"
33 #include "language.h"
34 #include "arch-utils.h"
35 #include "regcache.h"
36 #include "trad-frame.h"
37 #include "dis-asm.h"
38 #include "record.h"
39
40 #include "opcode/ft32.h"
41
42 #include "ft32-tdep.h"
43 #include "gdb/sim-ft32.h"
44 #include <algorithm>
45
46 #define RAM_BIAS 0x800000 /* Bias added to RAM addresses. */
47
48 /* Use an invalid address -1 as 'not available' marker. */
49 enum { REG_UNAVAIL = (CORE_ADDR) (-1) };
50
51 struct ft32_frame_cache
52 {
53 /* Base address of the frame */
54 CORE_ADDR base;
55 /* Function this frame belongs to */
56 CORE_ADDR pc;
57 /* Total size of this frame */
58 LONGEST framesize;
59 /* Saved registers in this frame */
60 CORE_ADDR saved_regs[FT32_NUM_REGS];
61 /* Saved SP in this frame */
62 CORE_ADDR saved_sp;
63 /* Has the new frame been LINKed. */
64 bfd_boolean established;
65 };
66
67 /* Implement the "frame_align" gdbarch method. */
68
69 static CORE_ADDR
70 ft32_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
71 {
72 /* Align to the size of an instruction (so that they can safely be
73 pushed onto the stack. */
74 return sp & ~1;
75 }
76
77
78 constexpr gdb_byte ft32_break_insn[] = { 0x02, 0x00, 0x34, 0x00 };
79
80 typedef BP_MANIPULATION (ft32_break_insn) ft32_breakpoint;
81
82 /* FT32 register names. */
83
84 static const char *const ft32_register_names[] =
85 {
86 "fp", "sp",
87 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
88 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
89 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
90 "r24", "r25", "r26", "r27", "r28", "cc",
91 "pc"
92 };
93
94 /* Implement the "register_name" gdbarch method. */
95
96 static const char *
97 ft32_register_name (struct gdbarch *gdbarch, int reg_nr)
98 {
99 if (reg_nr < 0)
100 return NULL;
101 if (reg_nr >= FT32_NUM_REGS)
102 return NULL;
103 return ft32_register_names[reg_nr];
104 }
105
106 /* Implement the "register_type" gdbarch method. */
107
108 static struct type *
109 ft32_register_type (struct gdbarch *gdbarch, int reg_nr)
110 {
111 if (reg_nr == FT32_PC_REGNUM)
112 return gdbarch_tdep (gdbarch)->pc_type;
113 else if (reg_nr == FT32_SP_REGNUM || reg_nr == FT32_FP_REGNUM)
114 return builtin_type (gdbarch)->builtin_data_ptr;
115 else
116 return builtin_type (gdbarch)->builtin_int32;
117 }
118
119 /* Write into appropriate registers a function return value
120 of type TYPE, given in virtual format. */
121
122 static void
123 ft32_store_return_value (struct type *type, struct regcache *regcache,
124 const gdb_byte *valbuf)
125 {
126 struct gdbarch *gdbarch = regcache->arch ();
127 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
128 CORE_ADDR regval;
129 int len = TYPE_LENGTH (type);
130
131 /* Things always get returned in RET1_REGNUM, RET2_REGNUM. */
132 regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
133 regcache_cooked_write_unsigned (regcache, FT32_R0_REGNUM, regval);
134 if (len > 4)
135 {
136 regval = extract_unsigned_integer (valbuf + 4,
137 len - 4, byte_order);
138 regcache_cooked_write_unsigned (regcache, FT32_R1_REGNUM, regval);
139 }
140 }
141
142 /* Fetch a single 32-bit instruction from address a. If memory contains
143 a compressed instruction pair, return the expanded instruction. */
144
145 static ULONGEST
146 ft32_fetch_instruction (CORE_ADDR a, int *isize,
147 enum bfd_endian byte_order)
148 {
149 unsigned int sc[2];
150 ULONGEST inst;
151
152 CORE_ADDR a4 = a & ~3;
153 inst = read_code_unsigned_integer (a4, 4, byte_order);
154 *isize = ft32_decode_shortcode (a4, inst, sc) ? 2 : 4;
155 if (*isize == 2)
156 return sc[1 & (a >> 1)];
157 else
158 return inst;
159 }
160
161 /* Decode the instructions within the given address range. Decide
162 when we must have reached the end of the function prologue. If a
163 frame_info pointer is provided, fill in its saved_regs etc.
164
165 Returns the address of the first instruction after the prologue. */
166
167 static CORE_ADDR
168 ft32_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
169 struct ft32_frame_cache *cache,
170 struct gdbarch *gdbarch)
171 {
172 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
173 CORE_ADDR next_addr;
174 ULONGEST inst;
175 int isize = 0;
176 int regnum, pushreg;
177 struct bound_minimal_symbol msymbol;
178 const int first_saved_reg = 13; /* The first saved register. */
179 /* PROLOGS are addresses of the subroutine prologs, PROLOGS[n]
180 is the address of __prolog_$rN.
181 __prolog_$rN pushes registers from 13 through n inclusive.
182 So for example CALL __prolog_$r15 is equivalent to:
183 PUSH $r13
184 PUSH $r14
185 PUSH $r15
186 Note that PROLOGS[0] through PROLOGS[12] are unused. */
187 CORE_ADDR prologs[32];
188
189 cache->saved_regs[FT32_PC_REGNUM] = 0;
190 cache->framesize = 0;
191
192 for (regnum = first_saved_reg; regnum < 32; regnum++)
193 {
194 char prolog_symbol[32];
195
196 snprintf (prolog_symbol, sizeof (prolog_symbol), "__prolog_$r%02d",
197 regnum);
198 msymbol = lookup_minimal_symbol (prolog_symbol, NULL, NULL);
199 if (msymbol.minsym)
200 prologs[regnum] = BMSYMBOL_VALUE_ADDRESS (msymbol);
201 else
202 prologs[regnum] = 0;
203 }
204
205 if (start_addr >= end_addr)
206 return end_addr;
207
208 cache->established = 0;
209 for (next_addr = start_addr; next_addr < end_addr; next_addr += isize)
210 {
211 inst = ft32_fetch_instruction (next_addr, &isize, byte_order);
212
213 if (FT32_IS_PUSH (inst))
214 {
215 pushreg = FT32_PUSH_REG (inst);
216 cache->framesize += 4;
217 cache->saved_regs[FT32_R0_REGNUM + pushreg] = cache->framesize;
218 }
219 else if (FT32_IS_CALL (inst))
220 {
221 for (regnum = first_saved_reg; regnum < 32; regnum++)
222 {
223 if ((4 * (inst & 0x3ffff)) == prologs[regnum])
224 {
225 for (pushreg = first_saved_reg; pushreg <= regnum;
226 pushreg++)
227 {
228 cache->framesize += 4;
229 cache->saved_regs[FT32_R0_REGNUM + pushreg] =
230 cache->framesize;
231 }
232 }
233 }
234 break;
235 }
236 else
237 break;
238 }
239 for (regnum = FT32_R0_REGNUM; regnum < FT32_PC_REGNUM; regnum++)
240 {
241 if (cache->saved_regs[regnum] != REG_UNAVAIL)
242 cache->saved_regs[regnum] =
243 cache->framesize - cache->saved_regs[regnum];
244 }
245 cache->saved_regs[FT32_PC_REGNUM] = cache->framesize;
246
247 /* It is a LINK? */
248 if (next_addr < end_addr)
249 {
250 inst = ft32_fetch_instruction (next_addr, &isize, byte_order);
251 if (FT32_IS_LINK (inst))
252 {
253 cache->established = 1;
254 for (regnum = FT32_R0_REGNUM; regnum < FT32_PC_REGNUM; regnum++)
255 {
256 if (cache->saved_regs[regnum] != REG_UNAVAIL)
257 cache->saved_regs[regnum] += 4;
258 }
259 cache->saved_regs[FT32_PC_REGNUM] = cache->framesize + 4;
260 cache->saved_regs[FT32_FP_REGNUM] = 0;
261 cache->framesize += FT32_LINK_SIZE (inst);
262 next_addr += isize;
263 }
264 }
265
266 return next_addr;
267 }
268
269 /* Find the end of function prologue. */
270
271 static CORE_ADDR
272 ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
273 {
274 CORE_ADDR func_addr = 0, func_end = 0;
275 const char *func_name;
276
277 /* See if we can determine the end of the prologue via the symbol table.
278 If so, then return either PC, or the PC after the prologue, whichever
279 is greater. */
280 if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
281 {
282 CORE_ADDR post_prologue_pc
283 = skip_prologue_using_sal (gdbarch, func_addr);
284 if (post_prologue_pc != 0)
285 return std::max (pc, post_prologue_pc);
286 else
287 {
288 /* Can't determine prologue from the symbol table, need to examine
289 instructions. */
290 struct symtab_and_line sal;
291 struct symbol *sym;
292 struct ft32_frame_cache cache;
293 CORE_ADDR plg_end;
294
295 memset (&cache, 0, sizeof cache);
296
297 plg_end = ft32_analyze_prologue (func_addr,
298 func_end, &cache, gdbarch);
299 /* Found a function. */
300 sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
301 /* Don't use line number debug info for assembly source files. */
302 if ((sym != NULL) && SYMBOL_LANGUAGE (sym) != language_asm)
303 {
304 sal = find_pc_line (func_addr, 0);
305 if (sal.end && sal.end < func_end)
306 {
307 /* Found a line number, use it as end of prologue. */
308 return sal.end;
309 }
310 }
311 /* No useable line symbol. Use result of prologue parsing method. */
312 return plg_end;
313 }
314 }
315
316 /* No function symbol -- just return the PC. */
317 return pc;
318 }
319
320 /* Implementation of `pointer_to_address' gdbarch method.
321
322 On FT32 address space zero is RAM, address space 1 is flash.
323 RAM appears at address RAM_BIAS, flash at address 0. */
324
325 static CORE_ADDR
326 ft32_pointer_to_address (struct gdbarch *gdbarch,
327 struct type *type, const gdb_byte *buf)
328 {
329 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
330 CORE_ADDR addr
331 = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
332
333 if (TYPE_ADDRESS_CLASS_1 (type))
334 return addr;
335 else
336 return addr | RAM_BIAS;
337 }
338
339 /* Implementation of `address_class_type_flags' gdbarch method.
340
341 This method maps DW_AT_address_class attributes to a
342 type_instance_flag_value. */
343
344 static int
345 ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
346 {
347 /* The value 1 of the DW_AT_address_class attribute corresponds to the
348 __flash__ qualifier, meaning pointer to data in FT32 program memory.
349 */
350 if (dwarf2_addr_class == 1)
351 return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
352 return 0;
353 }
354
355 /* Implementation of `address_class_type_flags_to_name' gdbarch method.
356
357 Convert a type_instance_flag_value to an address space qualifier. */
358
359 static const char*
360 ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
361 {
362 if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
363 return "flash";
364 else
365 return NULL;
366 }
367
368 /* Implementation of `address_class_name_to_type_flags' gdbarch method.
369
370 Convert an address space qualifier to a type_instance_flag_value. */
371
372 static int
373 ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch,
374 const char* name,
375 int *type_flags_ptr)
376 {
377 if (strcmp (name, "flash") == 0)
378 {
379 *type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
380 return 1;
381 }
382 else
383 return 0;
384 }
385
386
387 /* Implement the "read_pc" gdbarch method. */
388
389 static CORE_ADDR
390 ft32_read_pc (struct regcache *regcache)
391 {
392 ULONGEST pc;
393
394 regcache_cooked_read_unsigned (regcache, FT32_PC_REGNUM, &pc);
395 return pc;
396 }
397
398 /* Implement the "write_pc" gdbarch method. */
399
400 static void
401 ft32_write_pc (struct regcache *regcache, CORE_ADDR val)
402 {
403 regcache_cooked_write_unsigned (regcache, FT32_PC_REGNUM, val);
404 }
405
406 /* Implement the "unwind_sp" gdbarch method. */
407
408 static CORE_ADDR
409 ft32_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
410 {
411 return frame_unwind_register_unsigned (next_frame, FT32_SP_REGNUM);
412 }
413
414 /* Given a return value in `regbuf' with a type `valtype',
415 extract and copy its value into `valbuf'. */
416
417 static void
418 ft32_extract_return_value (struct type *type, struct regcache *regcache,
419 gdb_byte *dst)
420 {
421 struct gdbarch *gdbarch = regcache->arch ();
422 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
423 bfd_byte *valbuf = dst;
424 int len = TYPE_LENGTH (type);
425 ULONGEST tmp;
426
427 /* By using store_unsigned_integer we avoid having to do
428 anything special for small big-endian values. */
429 regcache_cooked_read_unsigned (regcache, FT32_R0_REGNUM, &tmp);
430 store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), byte_order, tmp);
431
432 /* Ignore return values more than 8 bytes in size because the ft32
433 returns anything more than 8 bytes in the stack. */
434 if (len > 4)
435 {
436 regcache_cooked_read_unsigned (regcache, FT32_R1_REGNUM, &tmp);
437 store_unsigned_integer (valbuf + len - 4, 4, byte_order, tmp);
438 }
439 }
440
441 /* Implement the "return_value" gdbarch method. */
442
443 static enum return_value_convention
444 ft32_return_value (struct gdbarch *gdbarch, struct value *function,
445 struct type *valtype, struct regcache *regcache,
446 gdb_byte *readbuf, const gdb_byte *writebuf)
447 {
448 if (TYPE_LENGTH (valtype) > 8)
449 return RETURN_VALUE_STRUCT_CONVENTION;
450 else
451 {
452 if (readbuf != NULL)
453 ft32_extract_return_value (valtype, regcache, readbuf);
454 if (writebuf != NULL)
455 ft32_store_return_value (valtype, regcache, writebuf);
456 return RETURN_VALUE_REGISTER_CONVENTION;
457 }
458 }
459
460 /* Allocate and initialize a ft32_frame_cache object. */
461
462 static struct ft32_frame_cache *
463 ft32_alloc_frame_cache (void)
464 {
465 struct ft32_frame_cache *cache;
466 int i;
467
468 cache = FRAME_OBSTACK_ZALLOC (struct ft32_frame_cache);
469
470 for (i = 0; i < FT32_NUM_REGS; ++i)
471 cache->saved_regs[i] = REG_UNAVAIL;
472
473 return cache;
474 }
475
476 /* Populate a ft32_frame_cache object for this_frame. */
477
478 static struct ft32_frame_cache *
479 ft32_frame_cache (struct frame_info *this_frame, void **this_cache)
480 {
481 struct ft32_frame_cache *cache;
482 CORE_ADDR current_pc;
483 int i;
484
485 if (*this_cache)
486 return (struct ft32_frame_cache *) *this_cache;
487
488 cache = ft32_alloc_frame_cache ();
489 *this_cache = cache;
490
491 cache->base = get_frame_register_unsigned (this_frame, FT32_FP_REGNUM);
492 if (cache->base == 0)
493 return cache;
494
495 cache->pc = get_frame_func (this_frame);
496 current_pc = get_frame_pc (this_frame);
497 if (cache->pc)
498 {
499 struct gdbarch *gdbarch = get_frame_arch (this_frame);
500
501 ft32_analyze_prologue (cache->pc, current_pc, cache, gdbarch);
502 if (!cache->established)
503 cache->base = get_frame_register_unsigned (this_frame, FT32_SP_REGNUM);
504 }
505
506 cache->saved_sp = cache->base - 4;
507
508 for (i = 0; i < FT32_NUM_REGS; ++i)
509 if (cache->saved_regs[i] != REG_UNAVAIL)
510 cache->saved_regs[i] = cache->base + cache->saved_regs[i];
511
512 return cache;
513 }
514
515 /* Implement the "unwind_pc" gdbarch method. */
516
517 static CORE_ADDR
518 ft32_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
519 {
520 return frame_unwind_register_unsigned (next_frame, FT32_PC_REGNUM);
521 }
522
523 /* Given a GDB frame, determine the address of the calling function's
524 frame. This will be used to create a new GDB frame struct. */
525
526 static void
527 ft32_frame_this_id (struct frame_info *this_frame,
528 void **this_prologue_cache, struct frame_id *this_id)
529 {
530 struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
531 this_prologue_cache);
532
533 /* This marks the outermost frame. */
534 if (cache->base == 0)
535 return;
536
537 *this_id = frame_id_build (cache->saved_sp, cache->pc);
538 }
539
540 /* Get the value of register regnum in the previous stack frame. */
541
542 static struct value *
543 ft32_frame_prev_register (struct frame_info *this_frame,
544 void **this_prologue_cache, int regnum)
545 {
546 struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
547 this_prologue_cache);
548
549 gdb_assert (regnum >= 0);
550
551 if (regnum == FT32_SP_REGNUM && cache->saved_sp)
552 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
553
554 if (regnum < FT32_NUM_REGS && cache->saved_regs[regnum] != REG_UNAVAIL)
555 return frame_unwind_got_memory (this_frame, regnum,
556 RAM_BIAS | cache->saved_regs[regnum]);
557
558 return frame_unwind_got_register (this_frame, regnum, regnum);
559 }
560
561 static const struct frame_unwind ft32_frame_unwind =
562 {
563 NORMAL_FRAME,
564 default_frame_unwind_stop_reason,
565 ft32_frame_this_id,
566 ft32_frame_prev_register,
567 NULL,
568 default_frame_sniffer
569 };
570
571 /* Return the base address of this_frame. */
572
573 static CORE_ADDR
574 ft32_frame_base_address (struct frame_info *this_frame, void **this_cache)
575 {
576 struct ft32_frame_cache *cache = ft32_frame_cache (this_frame,
577 this_cache);
578
579 return cache->base;
580 }
581
582 static const struct frame_base ft32_frame_base =
583 {
584 &ft32_frame_unwind,
585 ft32_frame_base_address,
586 ft32_frame_base_address,
587 ft32_frame_base_address
588 };
589
590 static struct frame_id
591 ft32_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
592 {
593 CORE_ADDR sp = get_frame_register_unsigned (this_frame, FT32_SP_REGNUM);
594
595 return frame_id_build (sp, get_frame_pc (this_frame));
596 }
597
598 /* Allocate and initialize the ft32 gdbarch object. */
599
600 static struct gdbarch *
601 ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
602 {
603 struct gdbarch *gdbarch;
604 struct gdbarch_tdep *tdep;
605 struct type *void_type;
606 struct type *func_void_type;
607
608 /* If there is already a candidate, use it. */
609 arches = gdbarch_list_lookup_by_info (arches, &info);
610 if (arches != NULL)
611 return arches->gdbarch;
612
613 /* Allocate space for the new architecture. */
614 tdep = XCNEW (struct gdbarch_tdep);
615 gdbarch = gdbarch_alloc (&info, tdep);
616
617 /* Create a type for PC. We can't use builtin types here, as they may not
618 be defined. */
619 void_type = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
620 func_void_type = make_function_type (void_type, NULL);
621 tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
622 func_void_type);
623 TYPE_INSTANCE_FLAGS (tdep->pc_type) |= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
624
625 set_gdbarch_read_pc (gdbarch, ft32_read_pc);
626 set_gdbarch_write_pc (gdbarch, ft32_write_pc);
627 set_gdbarch_unwind_sp (gdbarch, ft32_unwind_sp);
628
629 set_gdbarch_num_regs (gdbarch, FT32_NUM_REGS);
630 set_gdbarch_sp_regnum (gdbarch, FT32_SP_REGNUM);
631 set_gdbarch_pc_regnum (gdbarch, FT32_PC_REGNUM);
632 set_gdbarch_register_name (gdbarch, ft32_register_name);
633 set_gdbarch_register_type (gdbarch, ft32_register_type);
634
635 set_gdbarch_return_value (gdbarch, ft32_return_value);
636
637 set_gdbarch_pointer_to_address (gdbarch, ft32_pointer_to_address);
638
639 set_gdbarch_skip_prologue (gdbarch, ft32_skip_prologue);
640 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
641 set_gdbarch_breakpoint_kind_from_pc (gdbarch, ft32_breakpoint::kind_from_pc);
642 set_gdbarch_sw_breakpoint_from_kind (gdbarch, ft32_breakpoint::bp_from_kind);
643 set_gdbarch_frame_align (gdbarch, ft32_frame_align);
644
645 frame_base_set_default (gdbarch, &ft32_frame_base);
646
647 /* Methods for saving / extracting a dummy frame's ID. The ID's
648 stack address must match the SP value returned by
649 PUSH_DUMMY_CALL, and saved by generic_save_dummy_frame_tos. */
650 set_gdbarch_dummy_id (gdbarch, ft32_dummy_id);
651
652 set_gdbarch_unwind_pc (gdbarch, ft32_unwind_pc);
653
654 /* Hook in ABI-specific overrides, if they have been registered. */
655 gdbarch_init_osabi (info, gdbarch);
656
657 /* Hook in the default unwinders. */
658 frame_unwind_append_unwinder (gdbarch, &ft32_frame_unwind);
659
660 /* Support simple overlay manager. */
661 set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
662
663 set_gdbarch_address_class_type_flags (gdbarch, ft32_address_class_type_flags);
664 set_gdbarch_address_class_name_to_type_flags
665 (gdbarch, ft32_address_class_name_to_type_flags);
666 set_gdbarch_address_class_type_flags_to_name
667 (gdbarch, ft32_address_class_type_flags_to_name);
668
669 return gdbarch;
670 }
671
672 /* Register this machine's init routine. */
673
674 void
675 _initialize_ft32_tdep (void)
676 {
677 register_gdbarch_init (bfd_arch_ft32, ft32_gdbarch_init);
678 }
set_gdbarch_num_regs
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition: gdbarch.c:2050
gdbarch
Definition: gdbarch.c:127
language_asm
Definition: defs.h:214
set_gdbarch_frame_align
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype frame_align)
Definition: gdbarch.c:3151
set_gdbarch_address_class_type_flags_to_name
void set_gdbarch_address_class_type_flags_to_name(struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype address_class_type_flags_to_name)
Definition: gdbarch.c:3541
_initialize_ft32_tdep
void _initialize_ft32_tdep(void)
Definition: ft32-tdep.c:675
ft32_write_pc
static void ft32_write_pc(struct regcache *regcache, CORE_ADDR val)
Definition: ft32-tdep.c:401
frame_id_build
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:624
ft32_frame_this_id
static void ft32_frame_this_id(struct frame_info *this_frame, void **this_prologue_cache, struct frame_id *this_id)
Definition: ft32-tdep.c:527
arch_type
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
Definition: gdbtypes.c:4941
get_frame_pc
CORE_ADDR get_frame_pc(struct frame_info *frame)
Definition: frame.c:2376
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
gdbarch_init_osabi
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: osabi.c:334
ft32_frame_cache
Definition: ft32-tdep.c:51
RAM_BIAS
#define RAM_BIAS
Definition: ft32-tdep.c:46
frame_unwind_got_memory
struct value * frame_unwind_got_memory(struct frame_info *frame, int regnum, CORE_ADDR addr)
Definition: frame-unwind.c:233
BMSYMBOL_VALUE_ADDRESS
#define BMSYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:691
ft32_frame_prev_register
static struct value * ft32_frame_prev_register(struct frame_info *this_frame, void **this_prologue_cache, int regnum)
Definition: ft32-tdep.c:543
symtab_and_line::end
CORE_ADDR end
Definition: symtab.h:1760
set_gdbarch_overlay_update
void set_gdbarch_overlay_update(struct gdbarch *gdbarch, gdbarch_overlay_update_ftype overlay_update)
Definition: gdbarch.c:4048
set_gdbarch_write_pc
void set_gdbarch_write_pc(struct gdbarch *gdbarch, gdbarch_write_pc_ftype write_pc)
Definition: gdbarch.c:1943
ft32_frame_align
static CORE_ADDR ft32_frame_align(struct gdbarch *gdbarch, CORE_ADDR sp)
Definition: ft32-tdep.c:70
RETURN_VALUE_STRUCT_CONVENTION
Definition: defs.h:258
frame_unwind_register_unsigned
ULONGEST frame_unwind_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1279
builtin_type
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition: gdbtypes.c:5217
ft32-tdep.h
memset
void * memset(T *s, int c, size_t n)=delete
make_function_type
struct type * make_function_type(struct type *type, struct type **typeptr)
Definition: gdbtypes.c:489
gdbarch_tdep
Definition: aarch64-tdep.h:55
return_value_convention
return_value_convention
Definition: defs.h:247
ft32_dummy_id
static struct frame_id ft32_dummy_id(struct gdbarch *gdbarch, struct frame_info *this_frame)
Definition: ft32-tdep.c:591
frame_info
Definition: frame.c:85
gdbarch_list_lookup_by_info
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
Definition: gdbarch.c:5309
skip_prologue_using_sal
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
Definition: symtab.c:3854
lookup_symbol
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition: symtab.c:1893
ft32_pointer_to_address
static CORE_ADDR ft32_pointer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
Definition: ft32-tdep.c:326
defs.h
gdbarch_tdep
struct gdbarch_tdep * gdbarch_tdep(struct gdbarch *gdbarch)
Definition: gdbarch.c:1491
ft32_frame_cache::saved_sp
CORE_ADDR saved_sp
Definition: ft32-tdep.c:62
ft32_alloc_frame_cache
static struct ft32_frame_cache * ft32_alloc_frame_cache(void)
Definition: ft32-tdep.c:463
frame_unwind_append_unwinder
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
Definition: frame-unwind.c:79
ft32_frame_cache::saved_regs
CORE_ADDR saved_regs[FT32_NUM_REGS]
Definition: ft32-tdep.c:60
builtin_type::builtin_int32
struct type * builtin_int32
Definition: gdbtypes.h:1538
FRAME_OBSTACK_ZALLOC
#define FRAME_OBSTACK_ZALLOC(TYPE)
Definition: frame.h:678
objfiles.h
arch-utils.h
frame_unwind_got_constant
struct value * frame_unwind_got_constant(struct frame_info *frame, int regnum, ULONGEST val)
Definition: frame-unwind.c:246
read_code_unsigned_integer
ULONGEST read_code_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition: corefile.c:346
TYPE_CODE_VOID
Definition: gdbtypes.h:124
ft32_unwind_pc
static CORE_ADDR ft32_unwind_pc(struct gdbarch *gdbarch, struct frame_info *next_frame)
Definition: ft32-tdep.c:518
symtab.h
frame_base_set_default
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
Definition: frame-base.c:95
name
const char *const name
Definition: aarch64-tdep.c:76
TYPE_INSTANCE_FLAGS
#define TYPE_INSTANCE_FLAGS(thistype)
Definition: gdbtypes.h:1222
ft32_frame_cache::established
bfd_boolean established
Definition: ft32-tdep.c:64
set_gdbarch_register_type
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype register_type)
Definition: gdbarch.c:2316
NORMAL_FRAME
Definition: frame.h:244
BP_MANIPULATION
typedef BP_MANIPULATION(ft32_break_insn)
Definition: ft32-tdep.c:80
ft32_unwind_sp
static CORE_ADDR ft32_unwind_sp(struct gdbarch *gdbarch, struct frame_info *next_frame)
Definition: ft32-tdep.c:409
find_pc_line
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition: symtab.c:3288
ft32_frame_cache::framesize
LONGEST framesize
Definition: ft32-tdep.c:58
trad-frame.h
extract_unsigned_integer
static ULONGEST extract_unsigned_integer(const gdb_byte *addr, int len, enum bfd_endian byte_order)
Definition: defs.h:577
regcache_cooked_read_unsigned
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition: regcache.c:777
osabi.h
regcache.h
set_gdbarch_sp_regnum
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
Definition: gdbarch.c:2156
bound_minimal_symbol
Definition: minsyms.h:29
ft32_frame_base_address
static CORE_ADDR ft32_frame_base_address(struct frame_info *this_frame, void **this_cache)
Definition: ft32-tdep.c:574
ft32_fetch_instruction
static ULONGEST ft32_fetch_instruction(CORE_ADDR a, int *isize, enum bfd_endian byte_order)
Definition: ft32-tdep.c:146
set_gdbarch_dummy_id
void set_gdbarch_dummy_id(struct gdbarch *gdbarch, gdbarch_dummy_id_ftype dummy_id)
Definition: gdbarch.c:2340
ft32_frame_cache::base
CORE_ADDR base
Definition: ft32-tdep.c:54
ft32_return_value
static enum return_value_convention ft32_return_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
Definition: ft32-tdep.c:444
frame.h
gdbarch_byte_order
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1509
inferior.h
arch_pointer_type
struct type * arch_pointer_type(struct gdbarch *gdbarch, int bit, const char *name, struct type *target_type)
Definition: gdbtypes.c:5061
TARGET_CHAR_BIT
#define TARGET_CHAR_BIT
Definition: host-defs.h:29
ft32_extract_return_value
static void ft32_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *dst)
Definition: ft32-tdep.c:418
type
Definition: gdbtypes.h:749
find_pc_partial_function
int find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr)
Definition: blockframe.c:320
ft32_frame_cache
static struct ft32_frame_cache * ft32_frame_cache(struct frame_info *this_frame, void **this_cache)
Definition: ft32-tdep.c:479
language.h
frame-unwind.h
set_gdbarch_unwind_pc
void set_gdbarch_unwind_pc(struct gdbarch *gdbarch, gdbarch_unwind_pc_ftype unwind_pc)
Definition: gdbarch.c:3079
default_frame_sniffer
int default_frame_sniffer(const struct frame_unwind *self, struct frame_info *this_frame, void **this_prologue_cache)
Definition: frame-unwind.c:174
REG_UNAVAIL
Definition: ft32-tdep.c:49
ft32_gdbarch_init
static struct gdbarch * ft32_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
Definition: ft32-tdep.c:601
ft32_skip_prologue
static CORE_ADDR ft32_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: ft32-tdep.c:272
set_gdbarch_read_pc
void set_gdbarch_read_pc(struct gdbarch *gdbarch, gdbarch_read_pc_ftype read_pc)
Definition: gdbarch.c:1919
simple_overlay_update
void simple_overlay_update(struct obj_section *osect)
Definition: symfile.c:3559
set_gdbarch_pointer_to_address
void set_gdbarch_pointer_to_address(struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype pointer_to_address)
Definition: gdbarch.c:2673
set_gdbarch_unwind_sp
void set_gdbarch_unwind_sp(struct gdbarch *gdbarch, gdbarch_unwind_sp_ftype unwind_sp)
Definition: gdbarch.c:3103
gdbarch_tdep::pc_type
struct type * pc_type
Definition: avr-tdep.c:202
gdbarch_list::gdbarch
struct gdbarch * gdbarch
Definition: gdbarch.h:1622
regnum
int regnum
Definition: aarch64-tdep.c:77
frame_base
Definition: frame-base.h:58
TYPE_ADDRESS_CLASS_1
#define TYPE_ADDRESS_CLASS_1(t)
Definition: gdbtypes.h:367
ft32_address_class_type_flags_to_name
static const char * ft32_address_class_type_flags_to_name(struct gdbarch *gdbarch, int type_flags)
Definition: ft32-tdep.c:360
get_frame_register_unsigned
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
ft32_break_insn
constexpr gdb_byte ft32_break_insn[]
Definition: ft32-tdep.c:78
frame-base.h
set_gdbarch_breakpoint_kind_from_pc
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc)
Definition: gdbarch.c:2871
block_symbol::symbol
struct symbol * symbol
Definition: symtab.h:1136
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
value
Definition: value.c:169
symtab_and_line
Definition: symtab.h:1746
TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
Definition: gdbtypes.h:193
core_addr_lessthan
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition: arch-utils.c:117
gdb_byte
bfd_byte gdb_byte
Definition: common-types.h:38
record.h
set_gdbarch_address_class_type_flags
void set_gdbarch_address_class_type_flags(struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype address_class_type_flags)
Definition: gdbarch.c:3517
ft32_frame_cache::pc
CORE_ADDR pc
Definition: ft32-tdep.c:56
ft32_frame_base
static const struct frame_base ft32_frame_base
Definition: ft32-tdep.c:582
XCNEW
#define XCNEW(T)
Definition: poison.h:121
gdbcore.h
set_gdbarch_address_class_name_to_type_flags
void set_gdbarch_address_class_name_to_type_flags(struct gdbarch *gdbarch, gdbarch_address_class_name_to_type_flags_ftype address_class_name_to_type_flags)
Definition: gdbarch.c:3582
frame_unwind_got_register
struct value * frame_unwind_got_register(struct frame_info *frame, int regnum, int new_regnum)
Definition: frame-unwind.c:223
regcache_cooked_write_unsigned
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition: regcache.c:806
builtin_type::builtin_data_ptr
struct type * builtin_data_ptr
Definition: gdbtypes.h:1554
bound_minimal_symbol::minsym
struct minimal_symbol * minsym
Definition: minsyms.h:34
regcache::arch
gdbarch * arch() const
Definition: regcache.c:221
SYMBOL_LANGUAGE
#define SYMBOL_LANGUAGE(symbol)
Definition: symtab.h:469
ft32_analyze_prologue
static CORE_ADDR ft32_analyze_prologue(CORE_ADDR start_addr, CORE_ADDR end_addr, struct ft32_frame_cache *cache, struct gdbarch *gdbarch)
Definition: ft32-tdep.c:168
VAR_DOMAIN
Definition: symtab.h:739
value.h
frame_unwind
Definition: frame-unwind.h:144
ft32_store_return_value
static void ft32_store_return_value(struct type *type, struct regcache *regcache, const gdb_byte *valbuf)
Definition: ft32-tdep.c:123
gdbtypes.h
ULONGEST
unsigned long long ULONGEST
Definition: common-types.h:53
default_frame_unwind_stop_reason
enum unwind_stop_reason default_frame_unwind_stop_reason(struct frame_info *this_frame, void **this_cache)
Definition: frame-unwind.c:184
regcache
Definition: regcache.h:232
gdbarch_info
Definition: gdbarch.h:1626
ft32_register_name
static const char * ft32_register_name(struct gdbarch *gdbarch, int reg_nr)
Definition: ft32-tdep.c:97
symbol
Definition: symtab.h:1049
set_gdbarch_return_value
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype return_value)
Definition: gdbarch.c:2738
ft32_address_class_type_flags
static int ft32_address_class_type_flags(int byte_size, int dwarf2_addr_class)
Definition: ft32-tdep.c:345
TYPE_LENGTH
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1235
ft32_address_class_name_to_type_flags
static int ft32_address_class_name_to_type_flags(struct gdbarch *gdbarch, const char *name, int *type_flags_ptr)
Definition: ft32-tdep.c:373
set_gdbarch_sw_breakpoint_from_kind
void set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype sw_breakpoint_from_kind)
Definition: gdbarch.c:2888
register_gdbarch_init
void register_gdbarch_init(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init)
Definition: gdbarch.c:5299
ft32_register_type
static struct type * ft32_register_type(struct gdbarch *gdbarch, int reg_nr)
Definition: ft32-tdep.c:109
ft32_frame_unwind
static const struct frame_unwind ft32_frame_unwind
Definition: ft32-tdep.c:561
set_gdbarch_skip_prologue
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype skip_prologue)
Definition: gdbarch.c:2772
lookup_minimal_symbol
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:311
RETURN_VALUE_REGISTER_CONVENTION
Definition: defs.h:251
gdbarch::byte_order
enum bfd_endian byte_order
Definition: gdbarch.c:137
set_gdbarch_pc_regnum
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
Definition: gdbarch.c:2173
gdbcmd.h
set_gdbarch_register_name
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype register_name)
Definition: gdbarch.c:2292
get_frame_func
CORE_ADDR get_frame_func(struct frame_info *this_frame)
Definition: frame.c:1001
gdbarch_alloc
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, struct gdbarch_tdep *tdep)
Definition: gdbarch.c:361
set_gdbarch_inner_than
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype inner_than)
Definition: gdbarch.c:2837
frame_id
Definition: frame.h:111
get_frame_arch
struct gdbarch * get_frame_arch(struct frame_info *this_frame)
Definition: frame.c:2691
LONGEST
long long LONGEST
Definition: common-types.h:52
ft32_read_pc
static CORE_ADDR ft32_read_pc(struct regcache *regcache)
Definition: ft32-tdep.c:390
symfile.h
store_unsigned_integer
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition: defs.h:604
gdbarch_list
Definition: gdbarch.h:1620