GDB (xrefs)
Loading...
Searching...
No Matches
iq2000-tdep.c
Go to the documentation of this file.
1/* Target-dependent code for the IQ2000 architecture, for GDB, the GNU
2 Debugger.
3
4 Copyright (C) 2000-2023 Free Software Foundation, Inc.
5
6 Contributed by Red Hat.
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-base.h"
26#include "frame-unwind.h"
27#include "dwarf2/frame.h"
28#include "gdbtypes.h"
29#include "value.h"
30#include "dis-asm.h"
31#include "arch-utils.h"
32#include "regcache.h"
33#include "osabi.h"
34#include "gdbcore.h"
35
55
56/* Use an invalid address value as 'not available' marker. */
57enum { REG_UNAVAIL = (CORE_ADDR) -1 };
58
60{
61 /* Base address. */
62 CORE_ADDR base;
63 CORE_ADDR pc;
64 LONGEST framesize;
66 CORE_ADDR saved_sp;
68};
69
70/* Harvard methods: */
71
72static CORE_ADDR
73insn_ptr_from_addr (CORE_ADDR addr) /* CORE_ADDR to target pointer. */
74{
75 return addr & 0x7fffffffL;
76}
77
78static CORE_ADDR
79insn_addr_from_ptr (CORE_ADDR ptr) /* target_pointer to CORE_ADDR. */
80{
81 return (ptr & 0x7fffffffL) | 0x80000000L;
82}
83
84/* Function: pointer_to_address
85 Convert a target pointer to an address in host (CORE_ADDR) format. */
86
87static CORE_ADDR
89 struct type * type, const gdb_byte * buf)
90{
91 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
92 enum type_code target = type->target_type ()->code ();
93 CORE_ADDR addr
94 = extract_unsigned_integer (buf, type->length (), byte_order);
95
96 if (target == TYPE_CODE_FUNC
97 || target == TYPE_CODE_METHOD
99 addr = insn_addr_from_ptr (addr);
100
101 return addr;
102}
103
104/* Function: address_to_pointer
105 Convert a host-format address (CORE_ADDR) into a target pointer. */
106
107static void
109 struct type *type, gdb_byte *buf, CORE_ADDR addr)
110{
111 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
112 enum type_code target = type->target_type ()->code ();
113
114 if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
115 addr = insn_ptr_from_addr (addr);
116 store_unsigned_integer (buf, type->length (), byte_order, addr);
117}
118
119/* Real register methods: */
120
121/* Function: register_name
122 Returns the name of the iq2000 register number N. */
123
124static const char *
126{
127 static const char * names[E_NUM_REGS] =
128 {
129 "r0", "r1", "r2", "r3", "r4",
130 "r5", "r6", "r7", "r8", "r9",
131 "r10", "r11", "r12", "r13", "r14",
132 "r15", "r16", "r17", "r18", "r19",
133 "r20", "r21", "r22", "r23", "r24",
134 "r25", "r26", "r27", "r28", "r29",
135 "r30", "r31",
136 "pc"
137 };
138 gdb_static_assert (ARRAY_SIZE (names) == E_NUM_REGS);
139 return names[regnum];
140}
141
142/* Prologue analysis methods: */
143
144/* ADDIU insn (001001 rs(5) rt(5) imm(16)). */
145#define INSN_IS_ADDIU(X) (((X) & 0xfc000000) == 0x24000000)
146#define ADDIU_REG_SRC(X) (((X) & 0x03e00000) >> 21)
147#define ADDIU_REG_TGT(X) (((X) & 0x001f0000) >> 16)
148#define ADDIU_IMMEDIATE(X) ((signed short) ((X) & 0x0000ffff))
149
150/* "MOVE" (OR) insn (000000 rs(5) rt(5) rd(5) 00000 100101). */
151#define INSN_IS_MOVE(X) (((X) & 0xffe007ff) == 0x00000025)
152#define MOVE_REG_SRC(X) (((X) & 0x001f0000) >> 16)
153#define MOVE_REG_TGT(X) (((X) & 0x0000f800) >> 11)
154
155/* STORE WORD insn (101011 rs(5) rt(5) offset(16)). */
156#define INSN_IS_STORE_WORD(X) (((X) & 0xfc000000) == 0xac000000)
157#define SW_REG_INDEX(X) (((X) & 0x03e00000) >> 21)
158#define SW_REG_SRC(X) (((X) & 0x001f0000) >> 16)
159#define SW_OFFSET(X) ((signed short) ((X) & 0x0000ffff))
160
161/* Function: find_last_line_symbol
162
163 Given an address range, first find a line symbol corresponding to
164 the starting address. Then find the last line symbol within the
165 range that has a line number less than or equal to the first line.
166
167 For optimized code with code motion, this finds the last address
168 for the lowest-numbered line within the address range. */
169
170static struct symtab_and_line
171find_last_line_symbol (CORE_ADDR start, CORE_ADDR end, int notcurrent)
172{
173 struct symtab_and_line sal = find_pc_line (start, notcurrent);
174 struct symtab_and_line best_sal = sal;
175
176 if (sal.pc == 0 || sal.line == 0 || sal.end == 0)
177 return sal;
178
179 do
180 {
181 if (sal.line && sal.line <= best_sal.line)
182 best_sal = sal;
183 sal = find_pc_line (sal.end, notcurrent);
184 }
185 while (sal.pc && sal.pc < end);
186
187 return best_sal;
188}
189
190/* Function: scan_prologue
191 Decode the instructions within the given address range.
192 Decide when we must have reached the end of the function prologue.
193 If a frame_info pointer is provided, fill in its prologue information.
194
195 Returns the address of the first instruction after the prologue. */
196
197static CORE_ADDR
199 CORE_ADDR scan_start,
200 CORE_ADDR scan_end,
202 struct iq2000_frame_cache *cache)
203{
204 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
205 struct symtab_and_line sal;
206 CORE_ADDR pc;
207 CORE_ADDR loop_end;
208 int srcreg;
209 int tgtreg;
210 signed short offset;
211
212 if (scan_end == (CORE_ADDR) 0)
213 {
214 loop_end = scan_start + 100;
215 sal.end = sal.pc = 0;
216 }
217 else
218 {
219 loop_end = scan_end;
220 if (fi)
221 sal = find_last_line_symbol (scan_start, scan_end, 0);
222 else
223 sal.end = 0; /* Avoid GCC false warning. */
224 }
225
226 /* Saved registers:
227 We first have to save the saved register's offset, and
228 only later do we compute its actual address. Since the
229 offset can be zero, we must first initialize all the
230 saved regs to minus one (so we can later distinguish
231 between one that's not saved, and one that's saved at zero). */
232 for (srcreg = 0; srcreg < E_NUM_REGS; srcreg ++)
233 cache->saved_regs[srcreg] = -1;
234 cache->using_fp = 0;
235 cache->framesize = 0;
236
237 for (pc = scan_start; pc < loop_end; pc += 4)
238 {
239 LONGEST insn = read_memory_unsigned_integer (pc, 4, byte_order);
240 /* Skip any instructions writing to (sp) or decrementing the
241 SP. */
242 if ((insn & 0xffe00000) == 0xac200000)
243 {
244 /* sw using SP/%1 as base. */
245 /* LEGACY -- from assembly-only port. */
246 tgtreg = ((insn >> 16) & 0x1f);
247 if (tgtreg >= 0 && tgtreg < E_NUM_REGS)
248 cache->saved_regs[tgtreg] = -((signed short) (insn & 0xffff));
249
250 continue;
251 }
252
253 if ((insn & 0xffff8000) == 0x20218000)
254 {
255 /* addi %1, %1, -N == addi %sp, %sp, -N */
256 /* LEGACY -- from assembly-only port. */
257 cache->framesize = -((signed short) (insn & 0xffff));
258 continue;
259 }
260
261 if (INSN_IS_ADDIU (insn))
262 {
263 srcreg = ADDIU_REG_SRC (insn);
264 tgtreg = ADDIU_REG_TGT (insn);
265 offset = ADDIU_IMMEDIATE (insn);
266 if (srcreg == E_SP_REGNUM && tgtreg == E_SP_REGNUM)
267 cache->framesize = -offset;
268 continue;
269 }
270
271 if (INSN_IS_STORE_WORD (insn))
272 {
273 srcreg = SW_REG_SRC (insn);
274 tgtreg = SW_REG_INDEX (insn);
275 offset = SW_OFFSET (insn);
276
277 if (tgtreg == E_SP_REGNUM || tgtreg == E_FP_REGNUM)
278 {
279 /* "push" to stack (via SP or FP reg). */
280 if (cache->saved_regs[srcreg] == -1) /* Don't save twice. */
281 cache->saved_regs[srcreg] = offset;
282 continue;
283 }
284 }
285
286 if (INSN_IS_MOVE (insn))
287 {
288 srcreg = MOVE_REG_SRC (insn);
289 tgtreg = MOVE_REG_TGT (insn);
290
291 if (srcreg == E_SP_REGNUM && tgtreg == E_FP_REGNUM)
292 {
293 /* Copy sp to fp. */
294 cache->using_fp = 1;
295 continue;
296 }
297 }
298
299 /* Unknown instruction encountered in frame. Bail out?
300 1) If we have a subsequent line symbol, we can keep going.
301 2) If not, we need to bail out and quit scanning instructions. */
302
303 if (fi && sal.end && (pc < sal.end)) /* Keep scanning. */
304 continue;
305 else /* bail */
306 break;
307 }
308
309 return pc;
310}
311
312static void
314{
315 int i;
316
317 cache->base = 0;
318 cache->framesize = 0;
319 cache->using_fp = 0;
320 cache->saved_sp = 0;
321 for (i = 0; i < E_NUM_REGS; i++)
322 cache->saved_regs[i] = -1;
323}
324
325/* Function: iq2000_skip_prologue
326 If the input address is in a function prologue,
327 returns the address of the end of the prologue;
328 else returns the input address.
329
330 Note: the input address is likely to be the function start,
331 since this function is mainly used for advancing a breakpoint
332 to the first line, or stepping to the first line when we have
333 stepped into a function call. */
334
335static CORE_ADDR
337{
338 CORE_ADDR func_addr = 0 , func_end = 0;
339
340 if (find_pc_partial_function (pc, NULL, & func_addr, & func_end))
341 {
342 struct symtab_and_line sal;
343 struct iq2000_frame_cache cache;
344
345 /* Found a function. */
346 sal = find_pc_line (func_addr, 0);
347 if (sal.end && sal.end < func_end)
348 /* Found a line number, use it as end of prologue. */
349 return sal.end;
350
351 /* No useable line symbol. Use prologue parsing method. */
353 return iq2000_scan_prologue (gdbarch, func_addr, func_end, NULL, &cache);
354 }
355
356 /* No function symbol -- just return the PC. */
357 return (CORE_ADDR) pc;
358}
359
360static struct iq2000_frame_cache *
361iq2000_frame_cache (frame_info_ptr this_frame, void **this_cache)
362{
363 struct gdbarch *gdbarch = get_frame_arch (this_frame);
364 struct iq2000_frame_cache *cache;
365 CORE_ADDR current_pc;
366 int i;
367
368 if (*this_cache)
369 return (struct iq2000_frame_cache *) *this_cache;
370
373 *this_cache = cache;
374
375 cache->base = get_frame_register_unsigned (this_frame, E_FP_REGNUM);
376
377 current_pc = get_frame_pc (this_frame);
378 find_pc_partial_function (current_pc, NULL, &cache->pc, NULL);
379 if (cache->pc != 0)
380 iq2000_scan_prologue (gdbarch, cache->pc, current_pc, this_frame, cache);
381 if (!cache->using_fp)
382 cache->base = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
383
384 cache->saved_sp = cache->base + cache->framesize;
385
386 for (i = 0; i < E_NUM_REGS; i++)
387 if (cache->saved_regs[i] != -1)
388 cache->saved_regs[i] += cache->base;
389
390 return cache;
391}
392
393static struct value *
394iq2000_frame_prev_register (frame_info_ptr this_frame, void **this_cache,
395 int regnum)
396{
397 struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame,
398 this_cache);
399
400 if (regnum == E_SP_REGNUM && cache->saved_sp)
401 return frame_unwind_got_constant (this_frame, regnum, cache->saved_sp);
402
403 if (regnum == E_PC_REGNUM)
405
406 if (regnum < E_NUM_REGS && cache->saved_regs[regnum] != -1)
407 return frame_unwind_got_memory (this_frame, regnum,
408 cache->saved_regs[regnum]);
409
410 return frame_unwind_got_register (this_frame, regnum, regnum);
411}
412
413static void
414iq2000_frame_this_id (frame_info_ptr this_frame, void **this_cache,
415 struct frame_id *this_id)
416{
417 struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame,
418 this_cache);
419
420 /* This marks the outermost frame. */
421 if (cache->base == 0)
422 return;
423
424 *this_id = frame_id_build (cache->saved_sp, cache->pc);
425}
426
436
437static CORE_ADDR
438iq2000_frame_base_address (frame_info_ptr this_frame, void **this_cache)
439{
440 struct iq2000_frame_cache *cache = iq2000_frame_cache (this_frame,
441 this_cache);
442
443 return cache->base;
444}
445
452
453static int
455{
456 if ((*pcptr & 3) != 0)
457 error (_("breakpoint_from_pc: invalid breakpoint address 0x%lx"),
458 (long) *pcptr);
459
460 return 4;
461}
462
463static const gdb_byte *
465{
466 static const unsigned char big_breakpoint[] = { 0x00, 0x00, 0x00, 0x0d };
467 static const unsigned char little_breakpoint[] = { 0x0d, 0x00, 0x00, 0x00 };
468 *size = kind;
469
471 == BFD_ENDIAN_BIG) ? big_breakpoint : little_breakpoint;
472}
473
474/* Target function return value methods: */
475
476/* Function: store_return_value
477 Copy the function return value from VALBUF into the
478 proper location for a function return. */
479
480static void
482 const void *valbuf)
483{
484 int len = type->length ();
485 int regno = E_FN_RETURN_REGNUM;
486
487 while (len > 0)
488 {
489 gdb_byte buf[4];
490 int size = len % 4 ?: 4;
491
492 memset (buf, 0, 4);
493 memcpy (buf + 4 - size, valbuf, size);
494 regcache->raw_write (regno++, buf);
495 len -= size;
496 valbuf = ((char *) valbuf) + size;
497 }
498}
499
500/* Function: use_struct_convention
501 Returns non-zero if the given struct type will be returned using
502 a special convention, rather than the normal function return method. */
503
504static int
506{
507 return ((type->code () == TYPE_CODE_STRUCT)
508 || (type->code () == TYPE_CODE_UNION))
509 && type->length () > 8;
510}
511
512/* Function: extract_return_value
513 Copy the function's return value into VALBUF.
514 This function is called only in the context of "target function calls",
515 ie. when the debugger forces a function to be called in the child, and
516 when the debugger forces a function to return prematurely via the
517 "return" command. */
518
519static void
521 gdb_byte *valbuf)
522{
523 struct gdbarch *gdbarch = regcache->arch ();
524 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
525
526 /* If the function's return value is 8 bytes or less, it is
527 returned in a register, and if larger than 8 bytes, it is
528 returned in a stack location which is pointed to by the same
529 register. */
530 int len = type->length ();
531
532 if (len <= (2 * 4))
533 {
534 int regno = E_FN_RETURN_REGNUM;
535
536 /* Return values of <= 8 bytes are returned in
537 FN_RETURN_REGNUM. */
538 while (len > 0)
539 {
540 ULONGEST tmp;
541 int size = len % 4 ?: 4;
542
543 /* By using store_unsigned_integer we avoid having to
544 do anything special for small big-endian values. */
546 store_unsigned_integer (valbuf, size, byte_order, tmp);
547 len -= size;
548 valbuf += size;
549 }
550 }
551 else
552 {
553 /* Return values > 8 bytes are returned in memory,
554 pointed to by FN_RETURN_REGNUM. */
555 ULONGEST return_buffer;
557 &return_buffer);
558 read_memory (return_buffer, valbuf, type->length ());
559 }
560}
561
562static enum return_value_convention
563iq2000_return_value (struct gdbarch *gdbarch, struct value *function,
564 struct type *type, struct regcache *regcache,
565 gdb_byte *readbuf, const gdb_byte *writebuf)
566{
569 if (writebuf)
571 else if (readbuf)
574}
575
576/* Function: register_virtual_type
577 Returns the default type for register N. */
578
579static struct type *
584
585static CORE_ADDR
586iq2000_frame_align (struct gdbarch *ignore, CORE_ADDR sp)
587{
588 /* This is the same frame alignment used by gcc. */
589 return ((sp + 7) & ~7);
590}
591
592/* Convenience function to check 8-byte types for being a scalar type
593 or a struct with only one long long or double member. */
594static int
596{
597 struct type *ftype;
598
599 /* Skip typedefs. */
600 while (type->code () == TYPE_CODE_TYPEDEF)
601 type = type->target_type ();
602 /* Non-struct and non-union types are always passed by value. */
603 if (type->code () != TYPE_CODE_STRUCT
604 && type->code () != TYPE_CODE_UNION)
605 return 0;
606 /* Structs with more than 1 field are always passed by address. */
607 if (type->num_fields () != 1)
608 return 1;
609 /* Get field type. */
610 ftype = type->field (0).type ();
611 /* The field type must have size 8, otherwise pass by address. */
612 if (ftype->length () != 8)
613 return 1;
614 /* Skip typedefs of field type. */
615 while (ftype->code () == TYPE_CODE_TYPEDEF)
616 ftype = ftype->target_type ();
617 /* If field is int or float, pass by value. */
618 if (ftype->code () == TYPE_CODE_FLT
619 || ftype->code () == TYPE_CODE_INT)
620 return 0;
621 /* Everything else, pass by address. */
622 return 1;
623}
624
625static CORE_ADDR
626iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
627 struct regcache *regcache, CORE_ADDR bp_addr,
628 int nargs, struct value **args, CORE_ADDR sp,
629 function_call_return_method return_method,
630 CORE_ADDR struct_addr)
631{
632 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
633 const bfd_byte *val;
634 bfd_byte buf[4];
635 struct type *type;
636 int i, argreg, typelen, slacklen;
637 int stackspace = 0;
638 /* Used to copy struct arguments into the stack. */
639 CORE_ADDR struct_ptr;
640
641 /* First determine how much stack space we will need. */
642 for (i = 0, argreg = E_1ST_ARGREG + (return_method == return_method_struct);
643 i < nargs;
644 i++)
645 {
646 type = args[i]->type ();
647 typelen = type->length ();
648 if (typelen <= 4)
649 {
650 /* Scalars of up to 4 bytes,
651 structs of up to 4 bytes, and
652 pointers. */
653 if (argreg <= E_LAST_ARGREG)
654 argreg++;
655 else
656 stackspace += 4;
657 }
658 else if (typelen == 8 && !iq2000_pass_8bytetype_by_address (type))
659 {
660 /* long long,
661 double, and possibly
662 structs with a single field of long long or double. */
663 if (argreg <= E_LAST_ARGREG - 1)
664 {
665 /* 8-byte arg goes into a register pair
666 (must start with an even-numbered reg). */
667 if (((argreg - E_1ST_ARGREG) % 2) != 0)
668 argreg ++;
669 argreg += 2;
670 }
671 else
672 {
673 argreg = E_LAST_ARGREG + 1; /* no more argregs. */
674 /* 8-byte arg goes on stack, must be 8-byte aligned. */
675 stackspace = ((stackspace + 7) & ~7);
676 stackspace += 8;
677 }
678 }
679 else
680 {
681 /* Structs are passed as pointer to a copy of the struct.
682 So we need room on the stack for a copy of the struct
683 plus for the argument pointer. */
684 if (argreg <= E_LAST_ARGREG)
685 argreg++;
686 else
687 stackspace += 4;
688 /* Care for 8-byte alignment of structs saved on stack. */
689 stackspace += ((typelen + 7) & ~7);
690 }
691 }
692
693 /* Now copy params, in ascending order, into their assigned location
694 (either in a register or on the stack). */
695
696 sp -= (sp % 8); /* align */
697 struct_ptr = sp;
698 sp -= stackspace;
699 sp -= (sp % 8); /* align again */
700 stackspace = 0;
701
702 argreg = E_1ST_ARGREG;
703 if (return_method == return_method_struct)
704 {
705 /* A function that returns a struct will consume one argreg to do so.
706 */
707 regcache_cooked_write_unsigned (regcache, argreg++, struct_addr);
708 }
709
710 for (i = 0; i < nargs; i++)
711 {
712 type = args[i]->type ();
713 typelen = type->length ();
714 val = args[i]->contents ().data ();
715 if (typelen <= 4)
716 {
717 /* Char, short, int, float, pointer, and structs <= four bytes. */
718 slacklen = (4 - (typelen % 4)) % 4;
719 memset (buf, 0, sizeof (buf));
720 memcpy (buf + slacklen, val, typelen);
721 if (argreg <= E_LAST_ARGREG)
722 {
723 /* Passed in a register. */
724 regcache->raw_write (argreg++, buf);
725 }
726 else
727 {
728 /* Passed on the stack. */
729 write_memory (sp + stackspace, buf, 4);
730 stackspace += 4;
731 }
732 }
733 else if (typelen == 8 && !iq2000_pass_8bytetype_by_address (type))
734 {
735 /* (long long), (double), or struct consisting of
736 a single (long long) or (double). */
737 if (argreg <= E_LAST_ARGREG - 1)
738 {
739 /* 8-byte arg goes into a register pair
740 (must start with an even-numbered reg). */
741 if (((argreg - E_1ST_ARGREG) % 2) != 0)
742 argreg++;
743 regcache->raw_write (argreg++, val);
744 regcache->raw_write (argreg++, val + 4);
745 }
746 else
747 {
748 /* 8-byte arg goes on stack, must be 8-byte aligned. */
749 argreg = E_LAST_ARGREG + 1; /* no more argregs. */
750 stackspace = ((stackspace + 7) & ~7);
751 write_memory (sp + stackspace, val, typelen);
752 stackspace += 8;
753 }
754 }
755 else
756 {
757 /* Store struct beginning at the upper end of the previously
758 computed stack space. Then store the address of the struct
759 using the usual rules for a 4 byte value. */
760 struct_ptr -= ((typelen + 7) & ~7);
761 write_memory (struct_ptr, val, typelen);
762 if (argreg <= E_LAST_ARGREG)
763 regcache_cooked_write_unsigned (regcache, argreg++, struct_ptr);
764 else
765 {
766 store_unsigned_integer (buf, 4, byte_order, struct_ptr);
767 write_memory (sp + stackspace, buf, 4);
768 stackspace += 4;
769 }
770 }
771 }
772
773 /* Store return address. */
775
776 /* Update stack pointer. */
778
779 /* And that should do it. Return the new stack pointer. */
780 return sp;
781}
782
783/* Function: gdbarch_init
784 Initializer function for the iq2000 gdbarch vector.
785 Called by gdbarch. Sets up the gdbarch vector(s) for this target. */
786
787static struct gdbarch *
789{
790 struct gdbarch *gdbarch;
791
792 /* Look up list for candidates - only one. */
794 if (arches != NULL)
795 return arches->gdbarch;
796
797 gdbarch = gdbarch_alloc (&info, NULL);
798
806 set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
807 set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
808 set_gdbarch_int_bit (gdbarch, 4 * TARGET_CHAR_BIT);
809 set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
810 set_gdbarch_long_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
811 set_gdbarch_float_bit (gdbarch, 4 * TARGET_CHAR_BIT);
812 set_gdbarch_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
813 set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT);
829
831
834
835 return gdbarch;
836}
837
838/* Function: _initialize_iq2000_tdep
839 Initializer function for the iq2000 module.
840 Called by gdb at start-up. */
841
843void
int regnum
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
void gdbarch_register(enum bfd_architecture bfd_architecture, gdbarch_init_ftype *init, gdbarch_dump_tdep_ftype *dump_tdep, gdbarch_supports_arch_info_ftype *supports_arch_info)
static std::vector< const char * > arches
Definition arch-utils.c:685
int core_addr_lessthan(CORE_ADDR lhs, CORE_ADDR rhs)
Definition arch-utils.c:177
struct gdbarch_list * gdbarch_list_lookup_by_info(struct gdbarch_list *arches, const struct gdbarch_info *info)
gdb_regnum
Definition arm.h:39
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
Definition blockframe.c:373
gdbarch * arch() const
Definition regcache.c:231
void raw_write(int regnum, const gdb_byte *buf)
Definition regcache.c:833
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
Definition corefile.c:347
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
Definition corefile.c:306
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition corefile.c:238
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
Definition defs.h:515
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
Definition defs.h:480
return_value_convention
Definition defs.h:257
@ RETURN_VALUE_REGISTER_CONVENTION
Definition defs.h:260
@ RETURN_VALUE_STRUCT_CONVENTION
Definition defs.h:267
void dwarf2_append_unwinders(struct gdbarch *gdbarch)
Definition frame.c:1369
void frame_base_set_default(struct gdbarch *gdbarch, const struct frame_base *default_base)
Definition frame-base.c:93
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
struct value * frame_unwind_got_memory(frame_info_ptr frame, int regnum, CORE_ADDR addr)
struct value * frame_unwind_got_register(frame_info_ptr frame, int regnum, int new_regnum)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
struct value * frame_unwind_got_constant(frame_info_ptr frame, int regnum, ULONGEST val)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
ULONGEST get_frame_register_unsigned(frame_info_ptr frame, int regnum)
Definition frame.c:1399
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition frame.c:2712
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition frame.c:736
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
@ NORMAL_FRAME
Definition frame.h:187
#define FRAME_OBSTACK_ZALLOC(TYPE)
Definition frame.h:825
void set_gdbarch_long_long_bit(struct gdbarch *gdbarch, int long_long_bit)
Definition gdbarch.c:1493
void set_gdbarch_address_to_pointer(struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition gdbarch.c:1396
void set_gdbarch_breakpoint_kind_from_pc(struct gdbarch *gdbarch, gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc)
void set_gdbarch_frame_align(struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_register_name(struct gdbarch *gdbarch, gdbarch_register_name_ftype *register_name)
void set_gdbarch_int_bit(struct gdbarch *gdbarch, int int_bit)
Definition gdbarch.c:1459
void set_gdbarch_return_value(struct gdbarch *gdbarch, gdbarch_return_value_ftype *return_value)
void set_gdbarch_double_bit(struct gdbarch *gdbarch, int double_bit)
Definition gdbarch.c:1612
void set_gdbarch_inner_than(struct gdbarch *gdbarch, gdbarch_inner_than_ftype *inner_than)
void set_gdbarch_sp_regnum(struct gdbarch *gdbarch, int sp_regnum)
Definition gdbarch.c:2047
void set_gdbarch_long_double_format(struct gdbarch *gdbarch, const struct floatformat **long_double_format)
Definition gdbarch.c:1663
void set_gdbarch_pc_regnum(struct gdbarch *gdbarch, int pc_regnum)
Definition gdbarch.c:2064
void set_gdbarch_register_type(struct gdbarch *gdbarch, gdbarch_register_type_ftype *register_type)
void set_gdbarch_float_bit(struct gdbarch *gdbarch, int float_bit)
Definition gdbarch.c:1578
void set_gdbarch_short_bit(struct gdbarch *gdbarch, int short_bit)
Definition gdbarch.c:1442
void set_gdbarch_num_pseudo_regs(struct gdbarch *gdbarch, int num_pseudo_regs)
Definition gdbarch.c:1958
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
Definition gdbarch.c:1476
void set_gdbarch_ptr_bit(struct gdbarch *gdbarch, int ptr_bit)
Definition gdbarch.c:1732
void set_gdbarch_num_regs(struct gdbarch *gdbarch, int num_regs)
Definition gdbarch.c:1941
void set_gdbarch_long_double_bit(struct gdbarch *gdbarch, int long_double_bit)
Definition gdbarch.c:1646
void set_gdbarch_sw_breakpoint_from_kind(struct gdbarch *gdbarch, gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind)
void set_gdbarch_double_format(struct gdbarch *gdbarch, const struct floatformat **double_format)
Definition gdbarch.c:1629
void set_gdbarch_pointer_to_address(struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address)
void set_gdbarch_float_format(struct gdbarch *gdbarch, const struct floatformat **float_format)
Definition gdbarch.c:1595
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call)
void set_gdbarch_frame_args_skip(struct gdbarch *gdbarch, CORE_ADDR frame_args_skip)
Definition gdbarch.c:3012
struct gdbarch * gdbarch_alloc(const struct gdbarch_info *info, gdbarch_tdep_up tdep)
Definition gdbarch.c:266
function_call_return_method
Definition gdbarch.h:114
@ return_method_struct
Definition gdbarch.h:126
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:85
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
Definition gdbtypes.c:6168
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
Definition gdbtypes.c:89
type_code
Definition gdbtypes.h:82
#define TYPE_CODE_SPACE(t)
Definition gdbtypes.h:173
size_t size
Definition go32-nat.c:239
static CORE_ADDR iq2000_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr)
static struct symtab_and_line find_last_line_symbol(CORE_ADDR start, CORE_ADDR end, int notcurrent)
static struct gdbarch * iq2000_gdbarch_init(struct gdbarch_info info, struct gdbarch_list *arches)
static struct iq2000_frame_cache * iq2000_frame_cache(frame_info_ptr this_frame, void **this_cache)
static void iq2000_address_to_pointer(struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr)
static struct value * iq2000_frame_prev_register(frame_info_ptr this_frame, void **this_cache, int regnum)
@ REG_UNAVAIL
Definition iq2000-tdep.c:57
static struct type * iq2000_register_type(struct gdbarch *gdbarch, int regnum)
static void iq2000_frame_this_id(frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id)
static CORE_ADDR insn_addr_from_ptr(CORE_ADDR ptr)
Definition iq2000-tdep.c:79
#define SW_OFFSET(X)
void _initialize_iq2000_tdep()
static const char * iq2000_register_name(struct gdbarch *gdbarch, int regnum)
static CORE_ADDR iq2000_pointer_to_address(struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf)
Definition iq2000-tdep.c:88
#define SW_REG_INDEX(X)
#define INSN_IS_ADDIU(X)
static enum return_value_convention iq2000_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf)
static void iq2000_extract_return_value(struct type *type, struct regcache *regcache, gdb_byte *valbuf)
static CORE_ADDR iq2000_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
#define MOVE_REG_SRC(X)
static void iq2000_init_frame_cache(struct iq2000_frame_cache *cache)
static CORE_ADDR insn_ptr_from_addr(CORE_ADDR addr)
Definition iq2000-tdep.c:73
#define ADDIU_IMMEDIATE(X)
#define INSN_IS_MOVE(X)
#define SW_REG_SRC(X)
static CORE_ADDR iq2000_frame_align(struct gdbarch *ignore, CORE_ADDR sp)
static const struct frame_unwind iq2000_frame_unwind
#define INSN_IS_STORE_WORD(X)
#define ADDIU_REG_SRC(X)
static int iq2000_breakpoint_kind_from_pc(struct gdbarch *gdbarch, CORE_ADDR *pcptr)
static void iq2000_store_return_value(struct type *type, struct regcache *regcache, const void *valbuf)
static const gdb_byte * iq2000_sw_breakpoint_from_kind(struct gdbarch *gdbarch, int kind, int *size)
#define MOVE_REG_TGT(X)
@ E_R27_REGNUM
Definition iq2000-tdep.c:44
@ E_R7_REGNUM
Definition iq2000-tdep.c:39
@ E_R22_REGNUM
Definition iq2000-tdep.c:43
@ E_FN_RETURN_REGNUM
Definition iq2000-tdep.c:50
@ E_R9_REGNUM
Definition iq2000-tdep.c:40
@ E_1ST_ARGREG
Definition iq2000-tdep.c:51
@ E_R25_REGNUM
Definition iq2000-tdep.c:44
@ E_R28_REGNUM
Definition iq2000-tdep.c:45
@ E_R5_REGNUM
Definition iq2000-tdep.c:39
@ E_R10_REGNUM
Definition iq2000-tdep.c:40
@ E_LR_REGNUM
Definition iq2000-tdep.c:47
@ E_R31_REGNUM
Definition iq2000-tdep.c:45
@ E_R18_REGNUM
Definition iq2000-tdep.c:42
@ E_R19_REGNUM
Definition iq2000-tdep.c:42
@ E_R13_REGNUM
Definition iq2000-tdep.c:41
@ E_R11_REGNUM
Definition iq2000-tdep.c:40
@ E_R30_REGNUM
Definition iq2000-tdep.c:45
@ E_NUM_REGS
Definition iq2000-tdep.c:53
@ E_R2_REGNUM
Definition iq2000-tdep.c:38
@ E_R29_REGNUM
Definition iq2000-tdep.c:45
@ E_R15_REGNUM
Definition iq2000-tdep.c:41
@ E_LAST_ARGREG
Definition iq2000-tdep.c:52
@ E_R20_REGNUM
Definition iq2000-tdep.c:43
@ E_R6_REGNUM
Definition iq2000-tdep.c:39
@ E_R8_REGNUM
Definition iq2000-tdep.c:40
@ E_SP_REGNUM
Definition iq2000-tdep.c:48
@ E_R0_REGNUM
Definition iq2000-tdep.c:38
@ E_R24_REGNUM
Definition iq2000-tdep.c:44
@ E_R12_REGNUM
Definition iq2000-tdep.c:41
@ E_R1_REGNUM
Definition iq2000-tdep.c:38
@ E_R23_REGNUM
Definition iq2000-tdep.c:43
@ E_R16_REGNUM
Definition iq2000-tdep.c:42
@ E_R4_REGNUM
Definition iq2000-tdep.c:39
@ E_R26_REGNUM
Definition iq2000-tdep.c:44
@ E_PC_REGNUM
Definition iq2000-tdep.c:46
@ E_R14_REGNUM
Definition iq2000-tdep.c:41
@ E_FP_REGNUM
Definition iq2000-tdep.c:49
@ E_R21_REGNUM
Definition iq2000-tdep.c:43
@ E_R17_REGNUM
Definition iq2000-tdep.c:42
@ E_R3_REGNUM
Definition iq2000-tdep.c:38
#define ADDIU_REG_TGT(X)
static const struct frame_base iq2000_frame_base
static CORE_ADDR iq2000_frame_base_address(frame_info_ptr this_frame, void **this_cache)
static int iq2000_use_struct_convention(struct type *type)
static int iq2000_pass_8bytetype_by_address(struct type *type)
static CORE_ADDR iq2000_scan_prologue(struct gdbarch *gdbarch, CORE_ADDR scan_start, CORE_ADDR scan_end, frame_info_ptr fi, struct iq2000_frame_cache *cache)
info(Component c)
Definition gdbarch.py:41
void gdbarch_init_osabi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition osabi.c:382
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
Definition regcache.c:796
void regcache_cooked_write_unsigned(struct regcache *regcache, int regnum, ULONGEST val)
Definition regcache.c:825
constexpr gdb_byte little_breakpoint[]
constexpr gdb_byte big_breakpoint[]
enum var_types type
Definition scm-param.c:142
struct type * builtin_int32
Definition gdbtypes.h:2119
struct type * type() const
Definition gdbtypes.h:547
CORE_ADDR saved_regs[E_NUM_REGS]
Definition iq2000-tdep.c:67
CORE_ADDR pc
Definition symtab.h:2337
CORE_ADDR end
Definition symtab.h:2338
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
struct field & field(int idx) const
Definition gdbtypes.h:1012
unsigned int num_fields() const
Definition gdbtypes.h:994
Definition value.h:130
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition symtab.c:3295
struct symtab_and_line find_pc_line(CORE_ADDR, int)
Definition symtab.c:3295