1 /* Target-dependent code for the CSKY architecture, for GDB.
3 Copyright (C) 2010-2022 Free Software Foundation, Inc.
5 Contributed by C-SKY Microsystems and Mentor Graphics.
7 This file is part of GDB.
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.
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.
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/>. */
23 #include "gdbsupport/gdb_assert.h"
35 #include "arch-utils.h"
39 #include "reggroups.h"
43 #include "sim-regno.h"
45 #include "frame-unwind.h"
46 #include "frame-base.h"
47 #include "trad-frame.h"
49 #include "floatformat.h"
51 #include "target-descriptions.h"
52 #include "dwarf2/frame.h"
53 #include "user-regs.h"
55 #include "csky-tdep.h"
57 #include "opcode/csky.h"
61 /* Control debugging information emitted in this file. */
63 static bool csky_debug
= false;
65 static const reggroup
*cr_reggroup
;
66 static const reggroup
*fr_reggroup
;
67 static const reggroup
*vr_reggroup
;
68 static const reggroup
*mmu_reggroup
;
69 static const reggroup
*prof_reggroup
;
71 static const char *csky_supported_tdesc_feature_names
[] = {
72 (const char *)"org.gnu.csky.abiv2.gpr",
73 (const char *)"org.gnu.csky.abiv2.fpu",
74 (const char *)"org.gnu.csky.abiv2.cr",
75 (const char *)"org.gnu.csky.abiv2.fvcr",
76 (const char *)"org.gnu.csky.abiv2.mmu",
77 (const char *)"org.gnu.csky.abiv2.tee",
78 (const char *)"org.gnu.csky.abiv2.fpu2",
79 (const char *)"org.gnu.csky.abiv2.bank0",
80 (const char *)"org.gnu.csky.abiv2.bank1",
81 (const char *)"org.gnu.csky.abiv2.bank2",
82 (const char *)"org.gnu.csky.abiv2.bank3",
83 (const char *)"org.gnu.csky.abiv2.bank4",
84 (const char *)"org.gnu.csky.abiv2.bank5",
85 (const char *)"org.gnu.csky.abiv2.bank6",
86 (const char *)"org.gnu.csky.abiv2.bank7",
87 (const char *)"org.gnu.csky.abiv2.bank8",
88 (const char *)"org.gnu.csky.abiv2.bank9",
89 (const char *)"org.gnu.csky.abiv2.bank10",
90 (const char *)"org.gnu.csky.abiv2.bank11",
91 (const char *)"org.gnu.csky.abiv2.bank12",
92 (const char *)"org.gnu.csky.abiv2.bank13",
93 (const char *)"org.gnu.csky.abiv2.bank14",
94 (const char *)"org.gnu.csky.abiv2.bank15",
95 (const char *)"org.gnu.csky.abiv2.bank16",
96 (const char *)"org.gnu.csky.abiv2.bank17",
97 (const char *)"org.gnu.csky.abiv2.bank18",
98 (const char *)"org.gnu.csky.abiv2.bank19",
99 (const char *)"org.gnu.csky.abiv2.bank20",
100 (const char *)"org.gnu.csky.abiv2.bank21",
101 (const char *)"org.gnu.csky.abiv2.bank22",
102 (const char *)"org.gnu.csky.abiv2.bank23",
103 (const char *)"org.gnu.csky.abiv2.bank24",
104 (const char *)"org.gnu.csky.abiv2.bank25",
105 (const char *)"org.gnu.csky.abiv2.bank26",
106 (const char *)"org.gnu.csky.abiv2.bank27",
107 (const char *)"org.gnu.csky.abiv2.bank28",
108 (const char *)"org.gnu.csky.abiv2.bank29",
109 (const char *)"org.gnu.csky.abiv2.bank30",
110 (const char *)"org.gnu.csky.abiv2.bank31"
113 struct csky_supported_tdesc_register
119 static const struct csky_supported_tdesc_register csky_supported_gpr_regs
[] = {
153 {"hi", CSKY_HI_REGNUM
},
154 {"lo", CSKY_LO_REGNUM
},
155 {"pc", CSKY_PC_REGNUM
}
158 static const struct csky_supported_tdesc_register csky_supported_fpu_regs
[] = {
160 {"fr0", CSKY_FR0_REGNUM
+ 0},
161 {"fr1", CSKY_FR0_REGNUM
+ 1},
162 {"fr2", CSKY_FR0_REGNUM
+ 2},
163 {"fr3", CSKY_FR0_REGNUM
+ 3},
164 {"fr4", CSKY_FR0_REGNUM
+ 4},
165 {"fr5", CSKY_FR0_REGNUM
+ 5},
166 {"fr6", CSKY_FR0_REGNUM
+ 6},
167 {"fr7", CSKY_FR0_REGNUM
+ 7},
168 {"fr8", CSKY_FR0_REGNUM
+ 8},
169 {"fr9", CSKY_FR0_REGNUM
+ 9},
170 {"fr10", CSKY_FR0_REGNUM
+ 10},
171 {"fr11", CSKY_FR0_REGNUM
+ 11},
172 {"fr12", CSKY_FR0_REGNUM
+ 12},
173 {"fr13", CSKY_FR0_REGNUM
+ 13},
174 {"fr14", CSKY_FR0_REGNUM
+ 14},
175 {"fr15", CSKY_FR0_REGNUM
+ 15},
177 {"fr16", CSKY_FR16_REGNUM
+ 0},
178 {"fr17", CSKY_FR16_REGNUM
+ 1},
179 {"fr18", CSKY_FR16_REGNUM
+ 2},
180 {"fr19", CSKY_FR16_REGNUM
+ 3},
181 {"fr20", CSKY_FR16_REGNUM
+ 4},
182 {"fr21", CSKY_FR16_REGNUM
+ 5},
183 {"fr22", CSKY_FR16_REGNUM
+ 6},
184 {"fr23", CSKY_FR16_REGNUM
+ 7},
185 {"fr24", CSKY_FR16_REGNUM
+ 8},
186 {"fr25", CSKY_FR16_REGNUM
+ 9},
187 {"fr26", CSKY_FR16_REGNUM
+ 10},
188 {"fr27", CSKY_FR16_REGNUM
+ 11},
189 {"fr28", CSKY_FR16_REGNUM
+ 12},
190 {"fr29", CSKY_FR16_REGNUM
+ 13},
191 {"fr30", CSKY_FR16_REGNUM
+ 14},
192 {"fr31", CSKY_FR16_REGNUM
+ 15},
194 {"vr0", CSKY_VR0_REGNUM
+ 0},
195 {"vr1", CSKY_VR0_REGNUM
+ 1},
196 {"vr2", CSKY_VR0_REGNUM
+ 2},
197 {"vr3", CSKY_VR0_REGNUM
+ 3},
198 {"vr4", CSKY_VR0_REGNUM
+ 4},
199 {"vr5", CSKY_VR0_REGNUM
+ 5},
200 {"vr6", CSKY_VR0_REGNUM
+ 6},
201 {"vr7", CSKY_VR0_REGNUM
+ 7},
202 {"vr8", CSKY_VR0_REGNUM
+ 8},
203 {"vr9", CSKY_VR0_REGNUM
+ 9},
204 {"vr10", CSKY_VR0_REGNUM
+ 10},
205 {"vr11", CSKY_VR0_REGNUM
+ 11},
206 {"vr12", CSKY_VR0_REGNUM
+ 12},
207 {"vr13", CSKY_VR0_REGNUM
+ 13},
208 {"vr14", CSKY_VR0_REGNUM
+ 14},
209 {"vr15", CSKY_VR0_REGNUM
+ 15},
210 /* fpu control registers. */
211 {"fcr", CSKY_FCR_REGNUM
+ 0},
212 {"fid", CSKY_FCR_REGNUM
+ 1},
213 {"fesr", CSKY_FCR_REGNUM
+ 2},
216 static const struct csky_supported_tdesc_register csky_supported_ar_regs
[] = {
217 {"ar0", CSKY_AR0_REGNUM
+ 0},
218 {"ar1", CSKY_AR0_REGNUM
+ 1},
219 {"ar2", CSKY_AR0_REGNUM
+ 2},
220 {"ar3", CSKY_AR0_REGNUM
+ 3},
221 {"ar4", CSKY_AR0_REGNUM
+ 4},
222 {"ar5", CSKY_AR0_REGNUM
+ 5},
223 {"ar6", CSKY_AR0_REGNUM
+ 6},
224 {"ar7", CSKY_AR0_REGNUM
+ 7},
225 {"ar8", CSKY_AR0_REGNUM
+ 8},
226 {"ar9", CSKY_AR0_REGNUM
+ 9},
227 {"ar10", CSKY_AR0_REGNUM
+ 10},
228 {"ar11", CSKY_AR0_REGNUM
+ 11},
229 {"ar12", CSKY_AR0_REGNUM
+ 12},
230 {"ar13", CSKY_AR0_REGNUM
+ 13},
231 {"ar14", CSKY_AR0_REGNUM
+ 14},
232 {"ar15", CSKY_AR0_REGNUM
+ 15},
235 static const struct csky_supported_tdesc_register csky_supported_bank0_regs
[] = {
236 {"cr0", CSKY_CR0_REGNUM
+ 0},
237 {"cr1", CSKY_CR0_REGNUM
+ 1},
238 {"cr2", CSKY_CR0_REGNUM
+ 2},
239 {"cr3", CSKY_CR0_REGNUM
+ 3},
240 {"cr4", CSKY_CR0_REGNUM
+ 4},
241 {"cr5", CSKY_CR0_REGNUM
+ 5},
242 {"cr6", CSKY_CR0_REGNUM
+ 6},
243 {"cr7", CSKY_CR0_REGNUM
+ 7},
244 {"cr8", CSKY_CR0_REGNUM
+ 8},
245 {"cr9", CSKY_CR0_REGNUM
+ 9},
246 {"cr10", CSKY_CR0_REGNUM
+ 10},
247 {"cr11", CSKY_CR0_REGNUM
+ 11},
248 {"cr12", CSKY_CR0_REGNUM
+ 12},
249 {"cr13", CSKY_CR0_REGNUM
+ 13},
250 {"cr14", CSKY_CR0_REGNUM
+ 14},
251 {"cr15", CSKY_CR0_REGNUM
+ 15},
252 {"cr16", CSKY_CR0_REGNUM
+ 16},
253 {"cr17", CSKY_CR0_REGNUM
+ 17},
254 {"cr18", CSKY_CR0_REGNUM
+ 18},
255 {"cr19", CSKY_CR0_REGNUM
+ 19},
256 {"cr20", CSKY_CR0_REGNUM
+ 20},
257 {"cr21", CSKY_CR0_REGNUM
+ 21},
258 {"cr22", CSKY_CR0_REGNUM
+ 22},
259 {"cr23", CSKY_CR0_REGNUM
+ 23},
260 {"cr24", CSKY_CR0_REGNUM
+ 24},
261 {"cr25", CSKY_CR0_REGNUM
+ 25},
262 {"cr26", CSKY_CR0_REGNUM
+ 26},
263 {"cr27", CSKY_CR0_REGNUM
+ 27},
264 {"cr28", CSKY_CR0_REGNUM
+ 28},
265 {"cr29", CSKY_CR0_REGNUM
+ 29},
266 {"cr30", CSKY_CR0_REGNUM
+ 30},
267 {"cr31", CSKY_CR0_REGNUM
+ 31}
270 static const struct csky_supported_tdesc_register csky_supported_mmu_regs
[] = {
282 static const struct csky_supported_tdesc_register csky_supported_bank15_regs
[] = {
308 static const struct csky_supported_tdesc_register csky_supported_alias_regs
[] = {
309 /* Alias register names for Bank0. */
310 {"psr", CSKY_CR0_REGNUM
+ 0},
311 {"vbr", CSKY_CR0_REGNUM
+ 1},
312 {"epsr", CSKY_CR0_REGNUM
+ 2},
313 {"fpsr", CSKY_CR0_REGNUM
+ 3},
314 {"epc", CSKY_CR0_REGNUM
+ 4},
315 {"fpc", CSKY_CR0_REGNUM
+ 5},
316 {"ss0", CSKY_CR0_REGNUM
+ 6},
317 {"ss1", CSKY_CR0_REGNUM
+ 7},
318 {"ss2", CSKY_CR0_REGNUM
+ 8},
319 {"ss3", CSKY_CR0_REGNUM
+ 9},
320 {"ss4", CSKY_CR0_REGNUM
+ 10},
321 {"gcr", CSKY_CR0_REGNUM
+ 11},
322 {"gsr", CSKY_CR0_REGNUM
+ 12},
323 {"cpuid", CSKY_CR0_REGNUM
+ 13},
324 {"ccr", CSKY_CR0_REGNUM
+ 18},
325 {"capr", CSKY_CR0_REGNUM
+ 19},
326 {"pacr", CSKY_CR0_REGNUM
+ 20},
327 {"prsr", CSKY_CR0_REGNUM
+ 21},
328 {"chr", CSKY_CR0_REGNUM
+ 31},
329 /* Alias register names for MMU. */
339 /* Alias register names for Bank1. */
354 /* Alias register names for Bank3. */
367 /* Functions declaration. */
370 csky_pseudo_register_name (struct gdbarch
*gdbarch
, int regno
);
372 /* Get csky supported registers's count for tdesc xml. */
375 csky_get_supported_tdesc_registers_count()
378 count
+= ARRAY_SIZE (csky_supported_gpr_regs
);
379 count
+= ARRAY_SIZE (csky_supported_fpu_regs
);
380 count
+= ARRAY_SIZE (csky_supported_ar_regs
);
381 count
+= ARRAY_SIZE (csky_supported_bank0_regs
);
382 count
+= ARRAY_SIZE (csky_supported_mmu_regs
);
383 count
+= ARRAY_SIZE (csky_supported_bank15_regs
);
384 count
+= ARRAY_SIZE (csky_supported_alias_regs
);
385 /* Bank1~Bank14, Bank16~Bank31. */
386 count
+= 32 * (14 + 16);
390 /* Return a supported register according to index. */
392 static const struct csky_supported_tdesc_register
*
393 csky_get_supported_register_by_index (int index
)
395 static struct csky_supported_tdesc_register tdesc_reg
;
398 int count_gpr
= ARRAY_SIZE (csky_supported_gpr_regs
);
399 int count_fpu
= ARRAY_SIZE (csky_supported_fpu_regs
);
400 int count_ar
= ARRAY_SIZE (csky_supported_ar_regs
);
401 int count_bank0
= ARRAY_SIZE (csky_supported_bank0_regs
);
402 int count_mmu
= ARRAY_SIZE (csky_supported_mmu_regs
);
403 int count_bank15
= ARRAY_SIZE (csky_supported_bank15_regs
);
404 int count_alias
= ARRAY_SIZE (csky_supported_alias_regs
);
408 return &csky_supported_gpr_regs
[index
];
409 if (index
< (count
+ count_fpu
))
410 return &csky_supported_fpu_regs
[index
- count
];
412 if (index
< (count
+ count_ar
))
413 return &csky_supported_ar_regs
[index
- count
];
415 if (index
< (count
+ count_bank0
))
416 return &csky_supported_bank0_regs
[index
- count
];
417 count
+= count_bank0
;
418 if (index
< (count
+ count_mmu
))
419 return &csky_supported_mmu_regs
[index
- count
];
421 if (index
< (count
+ count_bank15
))
422 return &csky_supported_bank15_regs
[index
- count
];
423 count
+= count_bank15
;
424 if (index
< (count
+ count_alias
))
425 return &csky_supported_alias_regs
[index
- count
];
426 count
+= count_alias
;
434 sprintf (tdesc_reg
.name
, "cp1cr%d", remain
);
435 tdesc_reg
.num
= 189 + remain
;
440 sprintf (tdesc_reg
.name
, "cp2cr%d", remain
);
441 tdesc_reg
.num
= 276 + remain
;
446 sprintf (tdesc_reg
.name
, "cp3cr%d", remain
);
447 tdesc_reg
.num
= 221 + remain
;
456 case 9: /* Bank10. */
457 case 10: /* Bank11. */
458 case 11: /* Bank12. */
459 case 12: /* Bank13. */
460 case 13: /* Bank14. */
462 /* Regitsers in Bank4~14 have continuous regno with start 308. */
463 sprintf (tdesc_reg
.name
, "cp%dcr%d", (multi
+ 1), remain
);
464 tdesc_reg
.num
= 308 + ((multi
- 3) * 32) + remain
;
467 case 14: /* Bank16. */
468 case 15: /* Bank17. */
469 case 16: /* Bank18. */
470 case 17: /* Bank19. */
471 case 18: /* Bank20. */
472 case 19: /* Bank21. */
473 case 20: /* Bank22. */
474 case 21: /* Bank23. */
475 case 22: /* Bank24. */
476 case 23: /* Bank25. */
477 case 24: /* Bank26. */
478 case 25: /* Bank27. */
479 case 26: /* Bank28. */
480 case 27: /* Bank29. */
481 case 28: /* Bank30. */
482 case 29: /* Bank31. */
484 /* Regitsers in Bank16~31 have continuous regno with start 660. */
485 sprintf (tdesc_reg
.name
, "cp%dcr%d", (multi
+ 2), remain
);
486 tdesc_reg
.num
= 660 + ((multi
- 14) * 32) + remain
;
495 /* Convenience function to print debug messages in prologue analysis. */
498 print_savedreg_msg (int regno
, int offsets
[], bool print_continuing
)
500 gdb_printf (gdb_stdlog
, "csky: r%d saved at offset 0x%x\n",
501 regno
, offsets
[regno
]);
502 if (print_continuing
)
503 gdb_printf (gdb_stdlog
, "csky: continuing\n");
506 /* Check whether the instruction at ADDR is 16-bit or not. */
509 csky_pc_is_csky16 (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
511 gdb_byte target_mem
[2];
515 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
517 status
= target_read_memory (addr
, target_mem
, 2);
518 /* Assume a 16-bit instruction if we can't read memory. */
522 /* Get instruction from memory. */
523 insn
= extract_unsigned_integer (target_mem
, 2, byte_order
);
524 if ((insn
& CSKY_32_INSN_MASK
) == CSKY_32_INSN_MASK
)
526 else if (insn
== CSKY_BKPT_INSN
)
528 /* Check for 32-bit bkpt instruction which is all 0. */
529 status
= target_read_memory (addr
+ 2, target_mem
, 2);
533 insn
= extract_unsigned_integer (target_mem
, 2, byte_order
);
534 if (insn
== CSKY_BKPT_INSN
)
540 /* Get one instruction at ADDR and store it in INSN. Return 2 for
541 a 16-bit instruction or 4 for a 32-bit instruction. */
544 csky_get_insn (struct gdbarch
*gdbarch
, CORE_ADDR addr
, unsigned int *insn
)
546 gdb_byte target_mem
[2];
547 unsigned int insn_type
;
550 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
552 status
= target_read_memory (addr
, target_mem
, 2);
554 memory_error (TARGET_XFER_E_IO
, addr
);
556 insn_type
= extract_unsigned_integer (target_mem
, 2, byte_order
);
557 if (CSKY_32_INSN_MASK
== (insn_type
& CSKY_32_INSN_MASK
))
559 status
= target_read_memory (addr
+ 2, target_mem
, 2);
561 memory_error (TARGET_XFER_E_IO
, addr
);
562 insn_type
= ((insn_type
<< 16)
563 | extract_unsigned_integer (target_mem
, 2, byte_order
));
570 /* Implement the read_pc gdbarch method. */
573 csky_read_pc (readable_regcache
*regcache
)
576 regcache
->cooked_read (CSKY_PC_REGNUM
, &pc
);
580 /* Implement the write_pc gdbarch method. */
583 csky_write_pc (regcache
*regcache
, CORE_ADDR val
)
585 regcache_cooked_write_unsigned (regcache
, CSKY_PC_REGNUM
, val
);
588 /* C-Sky ABI register names. */
590 static const char * const csky_register_names
[] =
592 /* General registers 0 - 31. */
593 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
594 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
595 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
596 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
598 /* DSP hilo registers 36 and 37. */
599 "", "", "", "", "hi", "lo", "", "",
601 /* FPU/VPU general registers 40 - 71. */
602 "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
603 "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
604 "vr0", "vr1", "vr2", "vr3", "vr4", "vr5", "vr6", "vr7",
605 "vr8", "vr9", "vr10", "vr11", "vr12", "vr13", "vr14", "vr15",
607 /* Program counter 72. */
610 /* Optional registers (ar) 73 - 88. */
611 "ar0", "ar1", "ar2", "ar3", "ar4", "ar5", "ar6", "ar7",
612 "ar8", "ar9", "ar10", "ar11", "ar12", "ar13", "ar14", "ar15",
614 /* Control registers (cr) 89 - 119. */
615 "psr", "vbr", "epsr", "fpsr", "epc", "fpc", "ss0", "ss1",
616 "ss2", "ss3", "ss4", "gcr", "gsr", "cr13", "cr14", "cr15",
617 "cr16", "cr17", "cr18", "cr19", "cr20", "cr21", "cr22", "cr23",
618 "cr24", "cr25", "cr26", "cr27", "cr28", "cr29", "cr30", "cr31",
620 /* FPU/VPU control registers 121 ~ 123. */
622 "fid", "fcr", "fesr", "", "", "", "usp",
624 /* MMU control registers: 128 - 136. */
625 "mcr0", "mcr2", "mcr3", "mcr4", "mcr6", "mcr8", "mcr29", "mcr30",
628 /* Profiling control registers 140 - 143. */
629 /* Profiling software general registers 144 - 157. */
630 "profcr0", "profcr1", "profcr2", "profcr3", "profsgr0", "profsgr1",
631 "profsgr2", "profsgr3", "profsgr4", "profsgr5", "profsgr6", "profsgr7",
632 "profsgr8", "profsgr9", "profsgr10","profsgr11","profsgr12", "profsgr13",
635 /* Profiling architecture general registers 160 - 174. */
636 "profagr0", "profagr1", "profagr2", "profagr3", "profagr4", "profagr5",
637 "profagr6", "profagr7", "profagr8", "profagr9", "profagr10","profagr11",
638 "profagr12","profagr13","profagr14", "",
640 /* Profiling extension general registers 176 - 188. */
641 "profxgr0", "profxgr1", "profxgr2", "profxgr3", "profxgr4", "profxgr5",
642 "profxgr6", "profxgr7", "profxgr8", "profxgr9", "profxgr10","profxgr11",
645 /* Control registers in bank1. */
646 "", "", "", "", "", "", "", "",
647 "", "", "", "", "", "", "", "",
648 "cp1cr16", "cp1cr17", "cp1cr18", "cp1cr19", "cp1cr20", "", "", "",
649 "", "", "", "", "", "", "", "",
651 /* Control registers in bank3 (ICE). */
652 "sepsr", "sevbr", "seepsr", "", "seepc", "", "nsssp", "seusp",
653 "sedcr", "", "", "", "", "", "", "",
654 "", "", "", "", "", "", "", "",
655 "", "", "", "", "", "", "", ""
658 /* Implement the register_name gdbarch method. */
661 csky_register_name (struct gdbarch
*gdbarch
, int reg_nr
)
663 int num_regs
= gdbarch_num_regs (gdbarch
);
664 int num_pseudo_regs
= gdbarch_num_pseudo_regs (gdbarch
);
666 if ((reg_nr
>= num_regs
) && (reg_nr
< (num_regs
+ num_pseudo_regs
)))
667 return csky_pseudo_register_name (gdbarch
, reg_nr
);
669 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
670 return tdesc_register_name (gdbarch
, reg_nr
);
675 if (reg_nr
>= gdbarch_num_regs (gdbarch
))
678 return csky_register_names
[reg_nr
];
681 /* Construct vector type for vrx registers. */
684 csky_vector_type (struct gdbarch
*gdbarch
)
686 const struct builtin_type
*bt
= builtin_type (gdbarch
);
690 t
= arch_composite_type (gdbarch
, "__gdb_builtin_type_vec128i",
693 append_composite_type_field (t
, "u32",
694 init_vector_type (bt
->builtin_int32
, 4));
695 append_composite_type_field (t
, "u16",
696 init_vector_type (bt
->builtin_int16
, 8));
697 append_composite_type_field (t
, "u8",
698 init_vector_type (bt
->builtin_int8
, 16));
700 t
->set_is_vector (true);
701 t
->set_name ("builtin_type_vec128i");
706 /* Return the GDB type object for the "standard" data type
707 of data in register N. */
710 csky_register_type (struct gdbarch
*gdbarch
, int reg_nr
)
712 /* If type has been described in tdesc-xml, use it. */
713 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
715 struct type
*tdesc_t
= tdesc_register_type (gdbarch
, reg_nr
);
720 /* PC, EPC, FPC is a text pointer. */
721 if ((reg_nr
== CSKY_PC_REGNUM
) || (reg_nr
== CSKY_EPC_REGNUM
)
722 || (reg_nr
== CSKY_FPC_REGNUM
))
723 return builtin_type (gdbarch
)->builtin_func_ptr
;
725 /* VBR is a data pointer. */
726 if (reg_nr
== CSKY_VBR_REGNUM
)
727 return builtin_type (gdbarch
)->builtin_data_ptr
;
729 /* Float register has 64 bits, and only in ck810. */
730 if ((reg_nr
>=CSKY_FR0_REGNUM
) && (reg_nr
<= CSKY_FR0_REGNUM
+ 15))
731 return arch_float_type (gdbarch
, 64, "builtin_type_csky_ext",
732 floatformats_ieee_double
);
734 /* Vector register has 128 bits, and only in ck810. */
735 if ((reg_nr
>= CSKY_VR0_REGNUM
) && (reg_nr
<= CSKY_VR0_REGNUM
+ 15))
736 return csky_vector_type (gdbarch
);
738 /* Profiling general register has 48 bits, we use 64bit. */
739 if ((reg_nr
>= CSKY_PROFGR_REGNUM
) && (reg_nr
<= CSKY_PROFGR_REGNUM
+ 44))
740 return builtin_type (gdbarch
)->builtin_uint64
;
742 if (reg_nr
== CSKY_SP_REGNUM
)
743 return builtin_type (gdbarch
)->builtin_data_ptr
;
745 /* Others are 32 bits. */
746 return builtin_type (gdbarch
)->builtin_int32
;
749 /* Data structure to marshall items in a dummy stack frame when
750 calling a function in the inferior. */
752 struct csky_stack_item
754 csky_stack_item (int len_
, const gdb_byte
*data_
)
755 : len (len_
), data (data_
)
759 const gdb_byte
*data
;
762 /* Implement the push_dummy_call gdbarch method. */
765 csky_push_dummy_call (struct gdbarch
*gdbarch
, struct value
*function
,
766 struct regcache
*regcache
, CORE_ADDR bp_addr
,
767 int nargs
, struct value
**args
, CORE_ADDR sp
,
768 function_call_return_method return_method
,
769 CORE_ADDR struct_addr
)
772 int argreg
= CSKY_ABI_A0_REGNUM
;
773 int last_arg_regnum
= CSKY_ABI_LAST_ARG_REGNUM
;
774 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
775 std::vector
<csky_stack_item
> stack_items
;
777 /* Set the return address. For CSKY, the return breakpoint is
778 always at BP_ADDR. */
779 regcache_cooked_write_unsigned (regcache
, CSKY_LR_REGNUM
, bp_addr
);
781 /* The struct_return pointer occupies the first parameter
783 if (return_method
== return_method_struct
)
787 gdb_printf (gdb_stdlog
,
788 "csky: struct return in %s = %s\n",
789 gdbarch_register_name (gdbarch
, argreg
),
790 paddress (gdbarch
, struct_addr
));
792 regcache_cooked_write_unsigned (regcache
, argreg
, struct_addr
);
796 /* Put parameters into argument registers in REGCACHE.
797 In ABI argument registers are r0 through r3. */
798 for (argnum
= 0; argnum
< nargs
; argnum
++)
801 struct type
*arg_type
;
804 arg_type
= check_typedef (value_type (args
[argnum
]));
805 len
= TYPE_LENGTH (arg_type
);
806 val
= value_contents (args
[argnum
]).data ();
808 /* Copy the argument to argument registers or the dummy stack.
809 Large arguments are split between registers and stack.
811 If len < 4, there is no need to worry about endianness since
812 the arguments will always be stored in the low address. */
816 = extract_unsigned_integer (val
, len
, byte_order
);
817 regcache_cooked_write_unsigned (regcache
, argreg
, regval
);
824 int partial_len
= len
< 4 ? len
: 4;
825 if (argreg
<= last_arg_regnum
)
827 /* The argument is passed in an argument register. */
829 = extract_unsigned_integer (val
, partial_len
,
831 if (byte_order
== BFD_ENDIAN_BIG
)
832 regval
<<= (4 - partial_len
) * 8;
834 /* Put regval into register in REGCACHE. */
835 regcache_cooked_write_unsigned (regcache
, argreg
,
841 /* The argument should be pushed onto the dummy stack. */
842 stack_items
.emplace_back (4, val
);
850 /* Transfer the dummy stack frame to the target. */
851 std::vector
<csky_stack_item
>::reverse_iterator iter
;
852 for (iter
= stack_items
.rbegin (); iter
!= stack_items
.rend (); ++iter
)
855 write_memory (sp
, iter
->data
, iter
->len
);
858 /* Finally, update the SP register. */
859 regcache_cooked_write_unsigned (regcache
, CSKY_SP_REGNUM
, sp
);
863 /* Implement the return_value gdbarch method. */
865 static enum return_value_convention
866 csky_return_value (struct gdbarch
*gdbarch
, struct value
*function
,
867 struct type
*valtype
, struct regcache
*regcache
,
868 gdb_byte
*readbuf
, const gdb_byte
*writebuf
)
871 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
872 int len
= TYPE_LENGTH (valtype
);
873 unsigned int ret_regnum
= CSKY_RET_REGNUM
;
875 /* Csky abi specifies that return values larger than 8 bytes
876 are put on the stack. */
878 return RETURN_VALUE_STRUCT_CONVENTION
;
884 /* By using store_unsigned_integer we avoid having to do
885 anything special for small big-endian values. */
886 regcache
->cooked_read (ret_regnum
, &tmp
);
887 store_unsigned_integer (readbuf
, (len
> 4 ? 4 : len
),
891 regcache
->cooked_read (ret_regnum
+ 1, &tmp
);
892 store_unsigned_integer (readbuf
+ 4, 4, byte_order
, tmp
);
895 if (writebuf
!= NULL
)
897 regval
= extract_unsigned_integer (writebuf
, len
> 4 ? 4 : len
,
899 regcache_cooked_write_unsigned (regcache
, ret_regnum
, regval
);
902 regval
= extract_unsigned_integer ((gdb_byte
*) writebuf
+ 4,
904 regcache_cooked_write_unsigned (regcache
, ret_regnum
+ 1,
909 return RETURN_VALUE_REGISTER_CONVENTION
;
913 /* Implement the frame_align gdbarch method.
915 Adjust the address downward (direction of stack growth) so that it
916 is correctly aligned for a new stack frame. */
919 csky_frame_align (struct gdbarch
*gdbarch
, CORE_ADDR addr
)
921 return align_down (addr
, 4);
924 /* Unwind cache used for gdbarch fallback unwinder. */
926 struct csky_unwind_cache
928 /* The stack pointer at the time this frame was created; i.e. the
929 caller's stack pointer when this function was called. It is used
930 to identify this frame. */
933 /* The frame base for this frame is just prev_sp - frame size.
934 FRAMESIZE is the distance from the frame pointer to the
935 initial stack pointer. */
938 /* The register used to hold the frame pointer for this frame. */
941 /* Saved register offsets. */
942 trad_frame_saved_reg
*saved_regs
;
945 /* Do prologue analysis, returning the PC of the first instruction
946 after the function prologue. */
949 csky_analyze_prologue (struct gdbarch
*gdbarch
,
953 struct frame_info
*this_frame
,
954 struct csky_unwind_cache
*this_cache
,
958 unsigned int insn
, rn
;
961 int register_offsets
[CSKY_NUM_GREGS_SAVED_GREGS
];
963 /* For adjusting fp. */
967 /* REGISTER_OFFSETS will contain offsets from the top of the frame
968 (NOT the frame pointer) for the various saved registers, or -1
969 if the register is not saved. */
970 for (rn
= 0; rn
< CSKY_NUM_GREGS_SAVED_GREGS
; rn
++)
971 register_offsets
[rn
] = -1;
973 /* Analyze the prologue. Things we determine from analyzing the
974 prologue include the size of the frame and which registers are
975 saved (and where). */
978 gdb_printf (gdb_stdlog
,
979 "csky: Scanning prologue: start_pc = 0x%x,"
980 "limit_pc = 0x%x\n", (unsigned int) start_pc
,
981 (unsigned int) limit_pc
);
984 /* Default to 16 bit instruction. */
987 for (addr
= start_pc
; addr
< limit_pc
; addr
+= insn_len
)
990 insn_len
= csky_get_insn (gdbarch
, addr
, &insn
);
992 /* Check if 32 bit. */
995 /* subi32 sp,sp oimm12. */
996 if (CSKY_32_IS_SUBI0 (insn
))
999 int offset
= CSKY_32_SUBI_IMM (insn
);
1002 gdb_printf (gdb_stdlog
,
1003 "csky: got subi sp,%d; continuing\n",
1006 stacksize
+= offset
;
1009 /* stm32 ry-rz,(sp). */
1010 else if (CSKY_32_IS_STMx0 (insn
))
1012 /* Spill register(s). */
1017 /* BIG WARNING! The CKCore ABI does not restrict functions
1018 to taking only one stack allocation. Therefore, when
1019 we save a register, we record the offset of where it was
1020 saved relative to the current stacksize. This will
1021 then give an offset from the SP upon entry to our
1022 function. Remember, stacksize is NOT constant until
1023 we're done scanning the prologue. */
1024 start_register
= CSKY_32_STM_VAL_REGNUM (insn
);
1025 reg_count
= CSKY_32_STM_SIZE (insn
);
1028 gdb_printf (gdb_stdlog
,
1029 "csky: got stm r%d-r%d,(sp)\n",
1031 start_register
+ reg_count
);
1034 for (rn
= start_register
, offset
= 0;
1035 rn
<= start_register
+ reg_count
;
1038 register_offsets
[rn
] = stacksize
- offset
;
1041 gdb_printf (gdb_stdlog
,
1042 "csky: r%d saved at 0x%x"
1044 rn
, register_offsets
[rn
],
1049 gdb_printf (gdb_stdlog
, "csky: continuing\n");
1052 /* stw ry,(sp,disp). */
1053 else if (CSKY_32_IS_STWx0 (insn
))
1055 /* Spill register: see note for IS_STM above. */
1058 rn
= CSKY_32_ST_VAL_REGNUM (insn
);
1059 disp
= CSKY_32_ST_OFFSET (insn
);
1060 register_offsets
[rn
] = stacksize
- disp
;
1062 print_savedreg_msg (rn
, register_offsets
, true);
1065 else if (CSKY_32_IS_MOV_FP_SP (insn
))
1067 /* SP is saved to FP reg, means code afer prologue may
1070 adjust_fp
= stacksize
;
1073 else if (CSKY_32_IS_MFCR_EPSR (insn
))
1077 int mfcr_regnum
= insn
& 0x1f;
1078 insn_len
= csky_get_insn (gdbarch
, addr
, &insn2
);
1081 int stw_regnum
= (insn2
>> 5) & 0x7;
1082 if (CSKY_16_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1086 /* CSKY_EPSR_REGNUM. */
1087 rn
= CSKY_NUM_GREGS
;
1088 offset
= CSKY_16_STWx0_OFFSET (insn2
);
1089 register_offsets
[rn
] = stacksize
- offset
;
1091 print_savedreg_msg (rn
, register_offsets
, true);
1098 /* INSN_LEN == 4. */
1099 int stw_regnum
= (insn2
>> 21) & 0x1f;
1100 if (CSKY_32_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1104 /* CSKY_EPSR_REGNUM. */
1105 rn
= CSKY_NUM_GREGS
;
1106 offset
= CSKY_32_ST_OFFSET (insn2
);
1107 register_offsets
[rn
] = framesize
- offset
;
1109 print_savedreg_msg (rn
, register_offsets
, true);
1115 else if (CSKY_32_IS_MFCR_FPSR (insn
))
1119 int mfcr_regnum
= insn
& 0x1f;
1120 insn_len
= csky_get_insn (gdbarch
, addr
, &insn2
);
1123 int stw_regnum
= (insn2
>> 5) & 0x7;
1124 if (CSKY_16_IS_STWx0 (insn2
) && (mfcr_regnum
1129 /* CSKY_FPSR_REGNUM. */
1130 rn
= CSKY_NUM_GREGS
+ 1;
1131 offset
= CSKY_16_STWx0_OFFSET (insn2
);
1132 register_offsets
[rn
] = stacksize
- offset
;
1134 print_savedreg_msg (rn
, register_offsets
, true);
1141 /* INSN_LEN == 4. */
1142 int stw_regnum
= (insn2
>> 21) & 0x1f;
1143 if (CSKY_32_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1147 /* CSKY_FPSR_REGNUM. */
1148 rn
= CSKY_NUM_GREGS
+ 1;
1149 offset
= CSKY_32_ST_OFFSET (insn2
);
1150 register_offsets
[rn
] = framesize
- offset
;
1152 print_savedreg_msg (rn
, register_offsets
, true);
1158 else if (CSKY_32_IS_MFCR_EPC (insn
))
1162 int mfcr_regnum
= insn
& 0x1f;
1163 insn_len
= csky_get_insn (gdbarch
, addr
, &insn2
);
1166 int stw_regnum
= (insn2
>> 5) & 0x7;
1167 if (CSKY_16_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1171 /* CSKY_EPC_REGNUM. */
1172 rn
= CSKY_NUM_GREGS
+ 2;
1173 offset
= CSKY_16_STWx0_OFFSET (insn2
);
1174 register_offsets
[rn
] = stacksize
- offset
;
1176 print_savedreg_msg (rn
, register_offsets
, true);
1183 /* INSN_LEN == 4. */
1184 int stw_regnum
= (insn2
>> 21) & 0x1f;
1185 if (CSKY_32_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1189 /* CSKY_EPC_REGNUM. */
1190 rn
= CSKY_NUM_GREGS
+ 2;
1191 offset
= CSKY_32_ST_OFFSET (insn2
);
1192 register_offsets
[rn
] = framesize
- offset
;
1194 print_savedreg_msg (rn
, register_offsets
, true);
1200 else if (CSKY_32_IS_MFCR_FPC (insn
))
1204 int mfcr_regnum
= insn
& 0x1f;
1205 insn_len
= csky_get_insn (gdbarch
, addr
, &insn2
);
1208 int stw_regnum
= (insn2
>> 5) & 0x7;
1209 if (CSKY_16_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1213 /* CSKY_FPC_REGNUM. */
1214 rn
= CSKY_NUM_GREGS
+ 3;
1215 offset
= CSKY_16_STWx0_OFFSET (insn2
);
1216 register_offsets
[rn
] = stacksize
- offset
;
1218 print_savedreg_msg (rn
, register_offsets
, true);
1225 /* INSN_LEN == 4. */
1226 int stw_regnum
= (insn2
>> 21) & 0x1f;
1227 if (CSKY_32_IS_STWx0 (insn2
) && (mfcr_regnum
== stw_regnum
))
1231 /* CSKY_FPC_REGNUM. */
1232 rn
= CSKY_NUM_GREGS
+ 3;
1233 offset
= CSKY_32_ST_OFFSET (insn2
);
1234 register_offsets
[rn
] = framesize
- offset
;
1236 print_savedreg_msg (rn
, register_offsets
, true);
1242 else if (CSKY_32_IS_PUSH (insn
))
1244 /* Push for 32_bit. */
1245 if (CSKY_32_IS_PUSH_R29 (insn
))
1248 register_offsets
[29] = stacksize
;
1250 print_savedreg_msg (29, register_offsets
, false);
1252 if (CSKY_32_PUSH_LIST2 (insn
))
1254 int num
= CSKY_32_PUSH_LIST2 (insn
);
1256 stacksize
+= num
* 4;
1259 gdb_printf (gdb_stdlog
,
1260 "csky: push regs_array: r16-r%d\n",
1263 for (rn
= 16; rn
<= 16 + num
- 1; rn
++)
1265 register_offsets
[rn
] = stacksize
- tmp
;
1268 gdb_printf (gdb_stdlog
,
1269 "csky: r%d saved at 0x%x"
1270 " (offset %d)\n", rn
,
1271 register_offsets
[rn
], tmp
);
1276 if (CSKY_32_IS_PUSH_R15 (insn
))
1279 register_offsets
[15] = stacksize
;
1281 print_savedreg_msg (15, register_offsets
, false);
1283 if (CSKY_32_PUSH_LIST1 (insn
))
1285 int num
= CSKY_32_PUSH_LIST1 (insn
);
1287 stacksize
+= num
* 4;
1290 gdb_printf (gdb_stdlog
,
1291 "csky: push regs_array: r4-r%d\n",
1294 for (rn
= 4; rn
<= 4 + num
- 1; rn
++)
1296 register_offsets
[rn
] = stacksize
- tmp
;
1299 gdb_printf (gdb_stdlog
,
1300 "csky: r%d saved at 0x%x"
1301 " (offset %d)\n", rn
,
1302 register_offsets
[rn
], tmp
);
1308 framesize
= stacksize
;
1310 gdb_printf (gdb_stdlog
, "csky: continuing\n");
1313 else if (CSKY_32_IS_LRW4 (insn
) || CSKY_32_IS_MOVI4 (insn
)
1314 || CSKY_32_IS_MOVIH4 (insn
) || CSKY_32_IS_BMASKI4 (insn
))
1322 gdb_printf (gdb_stdlog
,
1323 "csky: looking at large frame\n");
1325 if (CSKY_32_IS_LRW4 (insn
))
1327 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1328 int literal_addr
= (addr
+ ((insn
& 0xffff) << 2))
1330 adjust
= read_memory_unsigned_integer (literal_addr
, 4,
1333 else if (CSKY_32_IS_MOVI4 (insn
))
1334 adjust
= (insn
& 0xffff);
1335 else if (CSKY_32_IS_MOVIH4 (insn
))
1336 adjust
= (insn
& 0xffff) << 16;
1339 /* CSKY_32_IS_BMASKI4 (insn). */
1340 adjust
= (1 << (((insn
& 0x3e00000) >> 21) + 1)) - 1;
1345 gdb_printf (gdb_stdlog
,
1346 "csky: base stacksize=0x%x\n", adjust
);
1348 /* May have zero or more insns which modify r4. */
1349 gdb_printf (gdb_stdlog
,
1350 "csky: looking for r4 adjusters...\n");
1354 insn_len
= csky_get_insn (gdbarch
, addr
+ offset
, &insn2
);
1355 while (CSKY_IS_R4_ADJUSTER (insn2
))
1357 if (CSKY_32_IS_ADDI4 (insn2
))
1359 int imm
= (insn2
& 0xfff) + 1;
1363 gdb_printf (gdb_stdlog
,
1364 "csky: addi r4,%d\n", imm
);
1367 else if (CSKY_32_IS_SUBI4 (insn2
))
1369 int imm
= (insn2
& 0xfff) + 1;
1373 gdb_printf (gdb_stdlog
,
1374 "csky: subi r4,%d\n", imm
);
1377 else if (CSKY_32_IS_NOR4 (insn2
))
1382 gdb_printf (gdb_stdlog
,
1383 "csky: nor r4,r4,r4\n");
1386 else if (CSKY_32_IS_ROTLI4 (insn2
))
1388 int imm
= ((insn2
>> 21) & 0x1f);
1389 int temp
= adjust
>> (32 - imm
);
1394 gdb_printf (gdb_stdlog
,
1395 "csky: rotli r4,r4,%d\n", imm
);
1398 else if (CSKY_32_IS_LISI4 (insn2
))
1400 int imm
= ((insn2
>> 21) & 0x1f);
1404 gdb_printf (gdb_stdlog
,
1405 "csky: lsli r4,r4,%d\n", imm
);
1408 else if (CSKY_32_IS_BSETI4 (insn2
))
1410 int imm
= ((insn2
>> 21) & 0x1f);
1411 adjust
|= (1 << imm
);
1414 gdb_printf (gdb_stdlog
,
1415 "csky: bseti r4,r4 %d\n", imm
);
1418 else if (CSKY_32_IS_BCLRI4 (insn2
))
1420 int imm
= ((insn2
>> 21) & 0x1f);
1421 adjust
&= ~(1 << imm
);
1424 gdb_printf (gdb_stdlog
,
1425 "csky: bclri r4,r4 %d\n", imm
);
1428 else if (CSKY_32_IS_IXH4 (insn2
))
1433 gdb_printf (gdb_stdlog
,
1434 "csky: ixh r4,r4,r4\n");
1437 else if (CSKY_32_IS_IXW4 (insn2
))
1442 gdb_printf (gdb_stdlog
,
1443 "csky: ixw r4,r4,r4\n");
1446 else if (CSKY_16_IS_ADDI4 (insn2
))
1448 int imm
= (insn2
& 0xff) + 1;
1452 gdb_printf (gdb_stdlog
,
1453 "csky: addi r4,%d\n", imm
);
1456 else if (CSKY_16_IS_SUBI4 (insn2
))
1458 int imm
= (insn2
& 0xff) + 1;
1462 gdb_printf (gdb_stdlog
,
1463 "csky: subi r4,%d\n", imm
);
1466 else if (CSKY_16_IS_NOR4 (insn2
))
1471 gdb_printf (gdb_stdlog
,
1472 "csky: nor r4,r4\n");
1475 else if (CSKY_16_IS_BSETI4 (insn2
))
1477 int imm
= (insn2
& 0x1f);
1478 adjust
|= (1 << imm
);
1481 gdb_printf (gdb_stdlog
,
1482 "csky: bseti r4, %d\n", imm
);
1485 else if (CSKY_16_IS_BCLRI4 (insn2
))
1487 int imm
= (insn2
& 0x1f);
1488 adjust
&= ~(1 << imm
);
1491 gdb_printf (gdb_stdlog
,
1492 "csky: bclri r4, %d\n", imm
);
1495 else if (CSKY_16_IS_LSLI4 (insn2
))
1497 int imm
= (insn2
& 0x1f);
1501 gdb_printf (gdb_stdlog
,
1502 "csky: lsli r4,r4, %d\n", imm
);
1507 insn_len
= csky_get_insn (gdbarch
, addr
+ offset
, &insn2
);
1512 gdb_printf (gdb_stdlog
, "csky: done looking for"
1516 /* If the next insn adjusts the stack pointer, we keep
1517 everything; if not, we scrap it and we've found the
1518 end of the prologue. */
1519 if (CSKY_IS_SUBU4 (insn2
))
1522 stacksize
+= adjust
;
1525 gdb_printf (gdb_stdlog
,
1526 "csky: found stack adjustment of"
1527 " 0x%x bytes.\n", adjust
);
1528 gdb_printf (gdb_stdlog
,
1529 "csky: skipping to new address %s\n",
1530 core_addr_to_string_nz (addr
));
1531 gdb_printf (gdb_stdlog
,
1532 "csky: continuing\n");
1537 /* None of these instructions are prologue, so don't touch
1541 gdb_printf (gdb_stdlog
,
1542 "csky: no subu sp,sp,r4; NOT altering"
1550 /* insn_len != 4. */
1552 /* subi.sp sp,disp. */
1553 if (CSKY_16_IS_SUBI0 (insn
))
1555 int offset
= CSKY_16_SUBI_IMM (insn
);
1558 gdb_printf (gdb_stdlog
,
1559 "csky: got subi r0,%d; continuing\n",
1562 stacksize
+= offset
;
1565 /* stw.16 rz,(sp,disp). */
1566 else if (CSKY_16_IS_STWx0 (insn
))
1568 /* Spill register: see note for IS_STM above. */
1571 rn
= CSKY_16_ST_VAL_REGNUM (insn
);
1572 disp
= CSKY_16_ST_OFFSET (insn
);
1573 register_offsets
[rn
] = stacksize
- disp
;
1575 print_savedreg_msg (rn
, register_offsets
, true);
1578 else if (CSKY_16_IS_MOV_FP_SP (insn
))
1580 /* SP is saved to FP reg, means prologue may modify SP. */
1582 adjust_fp
= stacksize
;
1585 else if (CSKY_16_IS_PUSH (insn
))
1587 /* Push for 16_bit. */
1589 if (CSKY_16_IS_PUSH_R15 (insn
))
1592 register_offsets
[15] = stacksize
;
1594 print_savedreg_msg (15, register_offsets
, false);
1597 if (CSKY_16_PUSH_LIST1 (insn
))
1599 int num
= CSKY_16_PUSH_LIST1 (insn
);
1601 stacksize
+= num
* 4;
1605 gdb_printf (gdb_stdlog
,
1606 "csky: push regs_array: r4-r%d\n",
1609 for (rn
= 4; rn
<= 4 + num
- 1; rn
++)
1611 register_offsets
[rn
] = stacksize
- tmp
;
1614 gdb_printf (gdb_stdlog
,
1615 "csky: r%d saved at 0x%x"
1616 " (offset %d)\n", rn
,
1617 register_offsets
[rn
], offset
);
1623 framesize
= stacksize
;
1625 gdb_printf (gdb_stdlog
, "csky: continuing\n");
1628 else if (CSKY_16_IS_LRW4 (insn
) || CSKY_16_IS_MOVI4 (insn
))
1635 gdb_printf (gdb_stdlog
,
1636 "csky: looking at large frame\n");
1638 if (CSKY_16_IS_LRW4 (insn
))
1640 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1641 int offset
= ((insn
& 0x300) >> 3) | (insn
& 0x1f);
1642 int literal_addr
= (addr
+ ( offset
<< 2)) & 0xfffffffc;
1643 adjust
= read_memory_unsigned_integer (literal_addr
, 4,
1648 /* CSKY_16_IS_MOVI4 (insn). */
1649 adjust
= (insn
& 0xff);
1654 gdb_printf (gdb_stdlog
,
1655 "csky: base stacksize=0x%x\n", adjust
);
1658 /* May have zero or more instructions which modify r4. */
1661 gdb_printf (gdb_stdlog
,
1662 "csky: looking for r4 adjusters...\n");
1665 insn_len
= csky_get_insn (gdbarch
, addr
+ offset
, &insn2
);
1666 while (CSKY_IS_R4_ADJUSTER (insn2
))
1668 if (CSKY_32_IS_ADDI4 (insn2
))
1670 int imm
= (insn2
& 0xfff) + 1;
1674 gdb_printf (gdb_stdlog
,
1675 "csky: addi r4,%d\n", imm
);
1678 else if (CSKY_32_IS_SUBI4 (insn2
))
1680 int imm
= (insn2
& 0xfff) + 1;
1684 gdb_printf (gdb_stdlog
,
1685 "csky: subi r4,%d\n", imm
);
1688 else if (CSKY_32_IS_NOR4 (insn2
))
1693 gdb_printf (gdb_stdlog
,
1694 "csky: nor r4,r4,r4\n");
1697 else if (CSKY_32_IS_ROTLI4 (insn2
))
1699 int imm
= ((insn2
>> 21) & 0x1f);
1700 int temp
= adjust
>> (32 - imm
);
1705 gdb_printf (gdb_stdlog
,
1706 "csky: rotli r4,r4,%d\n", imm
);
1709 else if (CSKY_32_IS_LISI4 (insn2
))
1711 int imm
= ((insn2
>> 21) & 0x1f);
1715 gdb_printf (gdb_stdlog
,
1716 "csky: lsli r4,r4,%d\n", imm
);
1719 else if (CSKY_32_IS_BSETI4 (insn2
))
1721 int imm
= ((insn2
>> 21) & 0x1f);
1722 adjust
|= (1 << imm
);
1725 gdb_printf (gdb_stdlog
,
1726 "csky: bseti r4,r4 %d\n", imm
);
1729 else if (CSKY_32_IS_BCLRI4 (insn2
))
1731 int imm
= ((insn2
>> 21) & 0x1f);
1732 adjust
&= ~(1 << imm
);
1735 gdb_printf (gdb_stdlog
,
1736 "csky: bclri r4,r4 %d\n", imm
);
1739 else if (CSKY_32_IS_IXH4 (insn2
))
1744 gdb_printf (gdb_stdlog
,
1745 "csky: ixh r4,r4,r4\n");
1748 else if (CSKY_32_IS_IXW4 (insn2
))
1753 gdb_printf (gdb_stdlog
,
1754 "csky: ixw r4,r4,r4\n");
1757 else if (CSKY_16_IS_ADDI4 (insn2
))
1759 int imm
= (insn2
& 0xff) + 1;
1763 gdb_printf (gdb_stdlog
,
1764 "csky: addi r4,%d\n", imm
);
1767 else if (CSKY_16_IS_SUBI4 (insn2
))
1769 int imm
= (insn2
& 0xff) + 1;
1773 gdb_printf (gdb_stdlog
,
1774 "csky: subi r4,%d\n", imm
);
1777 else if (CSKY_16_IS_NOR4 (insn2
))
1782 gdb_printf (gdb_stdlog
,
1783 "csky: nor r4,r4\n");
1786 else if (CSKY_16_IS_BSETI4 (insn2
))
1788 int imm
= (insn2
& 0x1f);
1789 adjust
|= (1 << imm
);
1792 gdb_printf (gdb_stdlog
,
1793 "csky: bseti r4, %d\n", imm
);
1796 else if (CSKY_16_IS_BCLRI4 (insn2
))
1798 int imm
= (insn2
& 0x1f);
1799 adjust
&= ~(1 << imm
);
1802 gdb_printf (gdb_stdlog
,
1803 "csky: bclri r4, %d\n", imm
);
1806 else if (CSKY_16_IS_LSLI4 (insn2
))
1808 int imm
= (insn2
& 0x1f);
1812 gdb_printf (gdb_stdlog
,
1813 "csky: lsli r4,r4, %d\n", imm
);
1818 insn_len
= csky_get_insn (gdbarch
, addr
+ offset
, &insn2
);
1823 gdb_printf (gdb_stdlog
, "csky: "
1824 "done looking for r4 adjusters\n");
1827 /* If the next instruction adjusts the stack pointer, we keep
1828 everything; if not, we scrap it and we've found the end
1830 if (CSKY_IS_SUBU4 (insn2
))
1833 stacksize
+= adjust
;
1836 gdb_printf (gdb_stdlog
, "csky: "
1837 "found stack adjustment of 0x%x"
1838 " bytes.\n", adjust
);
1839 gdb_printf (gdb_stdlog
, "csky: "
1840 "skipping to new address %s\n",
1841 core_addr_to_string_nz (addr
));
1842 gdb_printf (gdb_stdlog
, "csky: continuing\n");
1847 /* None of these instructions are prologue, so don't touch
1851 gdb_printf (gdb_stdlog
, "csky: no subu sp,r4; "
1852 "NOT altering stacksize.\n");
1858 /* This is not a prologue instruction, so stop here. */
1861 gdb_printf (gdb_stdlog
, "csky: insn is not a prologue"
1862 " insn -- ending scan\n");
1869 CORE_ADDR unwound_fp
;
1870 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1871 this_cache
->framesize
= framesize
;
1875 this_cache
->framereg
= CSKY_FP_REGNUM
;
1876 unwound_fp
= get_frame_register_unsigned (this_frame
,
1877 this_cache
->framereg
);
1878 this_cache
->prev_sp
= unwound_fp
+ adjust_fp
;
1882 this_cache
->framereg
= CSKY_SP_REGNUM
;
1883 unwound_fp
= get_frame_register_unsigned (this_frame
,
1884 this_cache
->framereg
);
1885 this_cache
->prev_sp
= unwound_fp
+ stacksize
;
1888 /* Note where saved registers are stored. The offsets in
1889 REGISTER_OFFSETS are computed relative to the top of the frame. */
1890 for (rn
= 0; rn
< CSKY_NUM_GREGS
; rn
++)
1892 if (register_offsets
[rn
] >= 0)
1894 this_cache
->saved_regs
[rn
].set_addr (this_cache
->prev_sp
1895 - register_offsets
[rn
]);
1898 CORE_ADDR rn_value
= read_memory_unsigned_integer (
1899 this_cache
->saved_regs
[rn
].addr (), 4, byte_order
);
1900 gdb_printf (gdb_stdlog
, "Saved register %s "
1901 "stored at 0x%08lx, value=0x%08lx\n",
1902 csky_register_names
[rn
],
1904 this_cache
->saved_regs
[rn
].addr (),
1905 (unsigned long) rn_value
);
1909 if (lr_type
== LR_TYPE_EPC
)
1912 this_cache
->saved_regs
[CSKY_PC_REGNUM
]
1913 = this_cache
->saved_regs
[CSKY_EPC_REGNUM
];
1915 else if (lr_type
== LR_TYPE_FPC
)
1918 this_cache
->saved_regs
[CSKY_PC_REGNUM
]
1919 = this_cache
->saved_regs
[CSKY_FPC_REGNUM
];
1923 this_cache
->saved_regs
[CSKY_PC_REGNUM
]
1924 = this_cache
->saved_regs
[CSKY_LR_REGNUM
];
1931 /* Detect whether PC is at a point where the stack frame has been
1935 csky_stack_frame_destroyed_p (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1939 CORE_ADDR func_start
, func_end
;
1941 if (!find_pc_partial_function (pc
, NULL
, &func_start
, &func_end
))
1944 bool fp_saved
= false;
1946 for (addr
= func_start
; addr
< func_end
; addr
+= insn_len
)
1948 /* Get next insn. */
1949 insn_len
= csky_get_insn (gdbarch
, addr
, &insn
);
1953 /* Is sp is saved to fp. */
1954 if (CSKY_16_IS_MOV_FP_SP (insn
))
1956 /* If sp was saved to fp and now being restored from
1957 fp then it indicates the start of epilog. */
1958 else if (fp_saved
&& CSKY_16_IS_MOV_SP_FP (insn
))
1965 /* Implement the skip_prologue gdbarch hook. */
1968 csky_skip_prologue (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
1970 CORE_ADDR func_addr
, func_end
;
1971 const int default_search_limit
= 128;
1973 /* See if we can find the end of the prologue using the symbol table. */
1974 if (find_pc_partial_function (pc
, NULL
, &func_addr
, &func_end
))
1976 CORE_ADDR post_prologue_pc
1977 = skip_prologue_using_sal (gdbarch
, func_addr
);
1979 if (post_prologue_pc
!= 0)
1980 return std::max (pc
, post_prologue_pc
);
1983 func_end
= pc
+ default_search_limit
;
1985 /* Find the end of prologue. Default lr_type. */
1986 return csky_analyze_prologue (gdbarch
, pc
, func_end
, func_end
,
1987 NULL
, NULL
, LR_TYPE_R15
);
1990 /* Implement the breakpoint_kind_from_pc gdbarch method. */
1993 csky_breakpoint_kind_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
)
1995 if (csky_pc_is_csky16 (gdbarch
, *pcptr
))
1996 return CSKY_INSN_SIZE16
;
1998 return CSKY_INSN_SIZE32
;
2001 /* Implement the sw_breakpoint_from_kind gdbarch method. */
2003 static const gdb_byte
*
2004 csky_sw_breakpoint_from_kind (struct gdbarch
*gdbarch
, int kind
, int *size
)
2007 if (kind
== CSKY_INSN_SIZE16
)
2009 static gdb_byte csky_16_breakpoint
[] = { 0, 0 };
2010 return csky_16_breakpoint
;
2014 static gdb_byte csky_32_breakpoint
[] = { 0, 0, 0, 0 };
2015 return csky_32_breakpoint
;
2019 /* Implement the memory_insert_breakpoint gdbarch method. */
2022 csky_memory_insert_breakpoint (struct gdbarch
*gdbarch
,
2023 struct bp_target_info
*bp_tgt
)
2026 const unsigned char *bp
;
2027 gdb_byte bp_write_record1
[] = { 0, 0, 0, 0 };
2028 gdb_byte bp_write_record2
[] = { 0, 0, 0, 0 };
2029 gdb_byte bp_record
[] = { 0, 0, 0, 0 };
2031 /* Sanity-check bp_address. */
2032 if (bp_tgt
->reqstd_address
% 2)
2033 warning (_("Invalid breakpoint address 0x%x is an odd number."),
2034 (unsigned int) bp_tgt
->reqstd_address
);
2035 scoped_restore restore_memory
2036 = make_scoped_restore_show_memory_breakpoints (1);
2038 /* Determine appropriate breakpoint_kind for this address. */
2039 bp_tgt
->kind
= csky_breakpoint_kind_from_pc (gdbarch
,
2040 &bp_tgt
->reqstd_address
);
2042 /* Save the memory contents. */
2043 bp_tgt
->shadow_len
= bp_tgt
->kind
;
2045 /* Fill bp_tgt->placed_address. */
2046 bp_tgt
->placed_address
= bp_tgt
->reqstd_address
;
2048 if (bp_tgt
->kind
== CSKY_INSN_SIZE16
)
2050 if ((bp_tgt
->reqstd_address
% 4) == 0)
2052 /* Read two bytes. */
2053 val
= target_read_memory (bp_tgt
->reqstd_address
,
2054 bp_tgt
->shadow_contents
, 2);
2058 /* Read two bytes. */
2059 val
= target_read_memory (bp_tgt
->reqstd_address
+ 2,
2064 /* Write the breakpoint. */
2065 bp_write_record1
[2] = bp_record
[0];
2066 bp_write_record1
[3] = bp_record
[1];
2067 bp
= bp_write_record1
;
2068 val
= target_write_raw_memory (bp_tgt
->reqstd_address
, bp
,
2073 val
= target_read_memory (bp_tgt
->reqstd_address
,
2074 bp_tgt
->shadow_contents
, 2);
2078 val
= target_read_memory (bp_tgt
->reqstd_address
- 2,
2083 /* Write the breakpoint. */
2084 bp_write_record1
[0] = bp_record
[0];
2085 bp_write_record1
[1] = bp_record
[1];
2086 bp
= bp_write_record1
;
2087 val
= target_write_raw_memory (bp_tgt
->reqstd_address
- 2,
2088 bp
, CSKY_WR_BKPT_MODE
);
2093 if (bp_tgt
->placed_address
% 4 == 0)
2095 val
= target_read_memory (bp_tgt
->reqstd_address
,
2096 bp_tgt
->shadow_contents
,
2101 /* Write the breakpoint. */
2102 bp
= bp_write_record1
;
2103 val
= target_write_raw_memory (bp_tgt
->reqstd_address
,
2104 bp
, CSKY_WR_BKPT_MODE
);
2108 val
= target_read_memory (bp_tgt
->reqstd_address
,
2109 bp_tgt
->shadow_contents
,
2114 val
= target_read_memory (bp_tgt
->reqstd_address
- 2,
2119 val
= target_read_memory (bp_tgt
->reqstd_address
+ 4,
2124 bp_write_record1
[0] = bp_record
[0];
2125 bp_write_record1
[1] = bp_record
[1];
2126 bp_write_record2
[2] = bp_record
[2];
2127 bp_write_record2
[3] = bp_record
[3];
2129 /* Write the breakpoint. */
2130 bp
= bp_write_record1
;
2131 val
= target_write_raw_memory (bp_tgt
->reqstd_address
- 2, bp
,
2136 /* Write the breakpoint. */
2137 bp
= bp_write_record2
;
2138 val
= target_write_raw_memory (bp_tgt
->reqstd_address
+ 2, bp
,
2145 /* Restore the breakpoint shadow_contents to the target. */
2148 csky_memory_remove_breakpoint (struct gdbarch
*gdbarch
,
2149 struct bp_target_info
*bp_tgt
)
2152 gdb_byte bp_record
[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
2153 /* Different for shadow_len 2 or 4. */
2154 if (bp_tgt
->shadow_len
== 2)
2156 /* Do word-sized writes on word-aligned boundaries and read
2157 padding bytes as necessary. */
2158 if (bp_tgt
->reqstd_address
% 4 == 0)
2160 val
= target_read_memory (bp_tgt
->reqstd_address
+ 2,
2164 bp_record
[0] = bp_tgt
->shadow_contents
[0];
2165 bp_record
[1] = bp_tgt
->shadow_contents
[1];
2166 return target_write_raw_memory (bp_tgt
->reqstd_address
,
2167 bp_record
, CSKY_WR_BKPT_MODE
);
2171 val
= target_read_memory (bp_tgt
->reqstd_address
- 2,
2175 bp_record
[2] = bp_tgt
->shadow_contents
[0];
2176 bp_record
[3] = bp_tgt
->shadow_contents
[1];
2177 return target_write_raw_memory (bp_tgt
->reqstd_address
- 2,
2178 bp_record
, CSKY_WR_BKPT_MODE
);
2183 /* Do word-sized writes on word-aligned boundaries and read
2184 padding bytes as necessary. */
2185 if (bp_tgt
->placed_address
% 4 == 0)
2187 return target_write_raw_memory (bp_tgt
->reqstd_address
,
2188 bp_tgt
->shadow_contents
,
2193 val
= target_read_memory (bp_tgt
->reqstd_address
- 2,
2197 val
= target_read_memory (bp_tgt
->reqstd_address
+ 4,
2202 bp_record
[2] = bp_tgt
->shadow_contents
[0];
2203 bp_record
[3] = bp_tgt
->shadow_contents
[1];
2204 bp_record
[4] = bp_tgt
->shadow_contents
[2];
2205 bp_record
[5] = bp_tgt
->shadow_contents
[3];
2207 return target_write_raw_memory (bp_tgt
->reqstd_address
- 2,
2209 CSKY_WR_BKPT_MODE
* 2);
2214 /* Determine link register type. */
2217 csky_analyze_lr_type (struct gdbarch
*gdbarch
,
2218 CORE_ADDR start_pc
, CORE_ADDR end_pc
)
2221 unsigned int insn
, insn_len
;
2224 for (addr
= start_pc
; addr
< end_pc
; addr
+= insn_len
)
2226 insn_len
= csky_get_insn (gdbarch
, addr
, &insn
);
2229 if (CSKY_32_IS_MFCR_EPSR (insn
) || CSKY_32_IS_MFCR_EPC (insn
)
2230 || CSKY_32_IS_RTE (insn
))
2233 else if (CSKY_32_IS_MFCR_FPSR (insn
) || CSKY_32_IS_MFCR_FPC (insn
)
2234 || CSKY_32_IS_RFI (insn
))
2236 else if (CSKY_32_IS_JMP (insn
) || CSKY_32_IS_BR (insn
)
2237 || CSKY_32_IS_JMPIX (insn
) || CSKY_32_IS_JMPI (insn
))
2241 /* 16 bit instruction. */
2242 if (CSKY_16_IS_JMP (insn
) || CSKY_16_IS_BR (insn
)
2243 || CSKY_16_IS_JMPIX (insn
))
2250 /* Heuristic unwinder. */
2252 static struct csky_unwind_cache
*
2253 csky_frame_unwind_cache (struct frame_info
*this_frame
)
2255 CORE_ADDR prologue_start
, prologue_end
, func_end
, prev_pc
, block_addr
;
2256 struct csky_unwind_cache
*cache
;
2257 const struct block
*bl
;
2258 unsigned long func_size
= 0;
2259 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
2260 unsigned int sp_regnum
= CSKY_SP_REGNUM
;
2262 /* Default lr type is r15. */
2263 lr_type_t lr_type
= LR_TYPE_R15
;
2265 cache
= FRAME_OBSTACK_ZALLOC (struct csky_unwind_cache
);
2266 cache
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2268 /* Assume there is no frame until proven otherwise. */
2269 cache
->framereg
= sp_regnum
;
2271 cache
->framesize
= 0;
2273 prev_pc
= get_frame_pc (this_frame
);
2274 block_addr
= get_frame_address_in_block (this_frame
);
2275 if (find_pc_partial_function (block_addr
, NULL
, &prologue_start
,
2277 /* We couldn't find a function containing block_addr, so bail out
2278 and hope for the best. */
2281 /* Get the (function) symbol matching prologue_start. */
2282 bl
= block_for_pc (prologue_start
);
2284 func_size
= bl
->end () - bl
->start ();
2287 struct bound_minimal_symbol msymbol
2288 = lookup_minimal_symbol_by_pc (prologue_start
);
2289 if (msymbol
.minsym
!= NULL
)
2290 func_size
= msymbol
.minsym
->size ();
2293 /* If FUNC_SIZE is 0 we may have a special-case use of lr
2294 e.g. exception or interrupt. */
2296 lr_type
= csky_analyze_lr_type (gdbarch
, prologue_start
, func_end
);
2298 prologue_end
= std::min (func_end
, prev_pc
);
2300 /* Analyze the function prologue. */
2301 csky_analyze_prologue (gdbarch
, prologue_start
, prologue_end
,
2302 func_end
, this_frame
, cache
, lr_type
);
2304 /* gdbarch_sp_regnum contains the value and not the address. */
2305 cache
->saved_regs
[sp_regnum
].set_value (cache
->prev_sp
);
2309 /* Implement the this_id function for the normal unwinder. */
2312 csky_frame_this_id (struct frame_info
*this_frame
,
2313 void **this_prologue_cache
, struct frame_id
*this_id
)
2315 struct csky_unwind_cache
*cache
;
2318 if (*this_prologue_cache
== NULL
)
2319 *this_prologue_cache
= csky_frame_unwind_cache (this_frame
);
2320 cache
= (struct csky_unwind_cache
*) *this_prologue_cache
;
2322 /* This marks the outermost frame. */
2323 if (cache
->prev_sp
== 0)
2326 id
= frame_id_build (cache
->prev_sp
, get_frame_func (this_frame
));
2330 /* Implement the prev_register function for the normal unwinder. */
2332 static struct value
*
2333 csky_frame_prev_register (struct frame_info
*this_frame
,
2334 void **this_prologue_cache
, int regnum
)
2336 struct csky_unwind_cache
*cache
;
2338 if (*this_prologue_cache
== NULL
)
2339 *this_prologue_cache
= csky_frame_unwind_cache (this_frame
);
2340 cache
= (struct csky_unwind_cache
*) *this_prologue_cache
;
2342 return trad_frame_get_prev_register (this_frame
, cache
->saved_regs
,
2346 /* Data structures for the normal prologue-analysis-based
2349 static const struct frame_unwind csky_unwind_cache
= {
2352 default_frame_unwind_stop_reason
,
2354 csky_frame_prev_register
,
2356 default_frame_sniffer
,
2364 csky_stub_unwind_sniffer (const struct frame_unwind
*self
,
2365 struct frame_info
*this_frame
,
2366 void **this_prologue_cache
)
2368 CORE_ADDR addr_in_block
;
2370 addr_in_block
= get_frame_address_in_block (this_frame
);
2372 if (find_pc_partial_function (addr_in_block
, NULL
, NULL
, NULL
) == 0
2373 || in_plt_section (addr_in_block
))
2379 static struct csky_unwind_cache
*
2380 csky_make_stub_cache (struct frame_info
*this_frame
)
2382 struct csky_unwind_cache
*cache
;
2384 cache
= FRAME_OBSTACK_ZALLOC (struct csky_unwind_cache
);
2385 cache
->saved_regs
= trad_frame_alloc_saved_regs (this_frame
);
2386 cache
->prev_sp
= get_frame_register_unsigned (this_frame
, CSKY_SP_REGNUM
);
2392 csky_stub_this_id (struct frame_info
*this_frame
,
2394 struct frame_id
*this_id
)
2396 struct csky_unwind_cache
*cache
;
2398 if (*this_cache
== NULL
)
2399 *this_cache
= csky_make_stub_cache (this_frame
);
2400 cache
= (struct csky_unwind_cache
*) *this_cache
;
2402 /* Our frame ID for a stub frame is the current SP and LR. */
2403 *this_id
= frame_id_build (cache
->prev_sp
, get_frame_pc (this_frame
));
2406 static struct value
*
2407 csky_stub_prev_register (struct frame_info
*this_frame
,
2411 struct csky_unwind_cache
*cache
;
2413 if (*this_cache
== NULL
)
2414 *this_cache
= csky_make_stub_cache (this_frame
);
2415 cache
= (struct csky_unwind_cache
*) *this_cache
;
2417 /* If we are asked to unwind the PC, then return the LR. */
2418 if (prev_regnum
== CSKY_PC_REGNUM
)
2422 lr
= frame_unwind_register_unsigned (this_frame
, CSKY_LR_REGNUM
);
2423 return frame_unwind_got_constant (this_frame
, prev_regnum
, lr
);
2426 if (prev_regnum
== CSKY_SP_REGNUM
)
2427 return frame_unwind_got_constant (this_frame
, prev_regnum
, cache
->prev_sp
);
2429 return trad_frame_get_prev_register (this_frame
, cache
->saved_regs
,
2433 static frame_unwind csky_stub_unwind
= {
2436 default_frame_unwind_stop_reason
,
2438 csky_stub_prev_register
,
2440 csky_stub_unwind_sniffer
2443 /* Implement the this_base, this_locals, and this_args hooks
2444 for the normal unwinder. */
2447 csky_frame_base_address (struct frame_info
*this_frame
, void **this_cache
)
2449 struct csky_unwind_cache
*cache
;
2451 if (*this_cache
== NULL
)
2452 *this_cache
= csky_frame_unwind_cache (this_frame
);
2453 cache
= (struct csky_unwind_cache
*) *this_cache
;
2455 return cache
->prev_sp
- cache
->framesize
;
2458 static const struct frame_base csky_frame_base
= {
2460 csky_frame_base_address
,
2461 csky_frame_base_address
,
2462 csky_frame_base_address
2465 /* Initialize register access method. */
2468 csky_dwarf2_frame_init_reg (struct gdbarch
*gdbarch
, int regnum
,
2469 struct dwarf2_frame_state_reg
*reg
,
2470 struct frame_info
*this_frame
)
2472 if (regnum
== gdbarch_pc_regnum (gdbarch
))
2473 reg
->how
= DWARF2_FRAME_REG_RA
;
2474 else if (regnum
== gdbarch_sp_regnum (gdbarch
))
2475 reg
->how
= DWARF2_FRAME_REG_CFA
;
2478 /* Create csky register groups. */
2481 csky_init_reggroup ()
2483 cr_reggroup
= reggroup_new ("cr", USER_REGGROUP
);
2484 fr_reggroup
= reggroup_new ("fr", USER_REGGROUP
);
2485 vr_reggroup
= reggroup_new ("vr", USER_REGGROUP
);
2486 mmu_reggroup
= reggroup_new ("mmu", USER_REGGROUP
);
2487 prof_reggroup
= reggroup_new ("profiling", USER_REGGROUP
);
2490 /* Add register groups into reggroup list. */
2493 csky_add_reggroups (struct gdbarch
*gdbarch
)
2495 reggroup_add (gdbarch
, cr_reggroup
);
2496 reggroup_add (gdbarch
, fr_reggroup
);
2497 reggroup_add (gdbarch
, vr_reggroup
);
2498 reggroup_add (gdbarch
, mmu_reggroup
);
2499 reggroup_add (gdbarch
, prof_reggroup
);
2502 /* Return the groups that a CSKY register can be categorised into. */
2505 csky_register_reggroup_p (struct gdbarch
*gdbarch
, int regnum
,
2506 const struct reggroup
*reggroup
)
2510 if (gdbarch_register_name (gdbarch
, regnum
) == NULL
2511 || gdbarch_register_name (gdbarch
, regnum
)[0] == '\0')
2514 if (reggroup
== all_reggroup
)
2517 raw_p
= regnum
< gdbarch_num_regs (gdbarch
);
2518 if (reggroup
== save_reggroup
|| reggroup
== restore_reggroup
)
2521 if ((((regnum
>= CSKY_R0_REGNUM
) && (regnum
<= CSKY_R0_REGNUM
+ 31))
2522 || (regnum
== CSKY_PC_REGNUM
)
2523 || (regnum
== CSKY_EPC_REGNUM
)
2524 || (regnum
== CSKY_CR0_REGNUM
)
2525 || (regnum
== CSKY_EPSR_REGNUM
))
2526 && (reggroup
== general_reggroup
))
2529 if (((regnum
== CSKY_PC_REGNUM
)
2530 || ((regnum
>= CSKY_CR0_REGNUM
)
2531 && (regnum
<= CSKY_CR0_REGNUM
+ 30)))
2532 && (reggroup
== cr_reggroup
))
2535 if ((((regnum
>= CSKY_VR0_REGNUM
) && (regnum
<= CSKY_VR0_REGNUM
+ 15))
2536 || ((regnum
>= CSKY_FCR_REGNUM
)
2537 && (regnum
<= CSKY_FCR_REGNUM
+ 2)))
2538 && (reggroup
== vr_reggroup
))
2541 if (((regnum
>= CSKY_MMU_REGNUM
) && (regnum
<= CSKY_MMU_REGNUM
+ 8))
2542 && (reggroup
== mmu_reggroup
))
2545 if (((regnum
>= CSKY_PROFCR_REGNUM
)
2546 && (regnum
<= CSKY_PROFCR_REGNUM
+ 48))
2547 && (reggroup
== prof_reggroup
))
2550 if ((((regnum
>= CSKY_FR0_REGNUM
) && (regnum
<= CSKY_FR0_REGNUM
+ 15))
2551 || ((regnum
>= CSKY_FCR_REGNUM
) && (regnum
<= CSKY_FCR_REGNUM
+ 2)))
2552 && (reggroup
== fr_reggroup
))
2555 if (tdesc_has_registers (gdbarch_target_desc (gdbarch
)))
2557 if (tdesc_register_in_reggroup_p (gdbarch
, regnum
, reggroup
) > 0)
2564 /* Implement the dwarf2_reg_to_regnum gdbarch method. */
2567 csky_dwarf_reg_to_regnum (struct gdbarch
*gdbarch
, int dw_reg
)
2570 if (dw_reg
>= CSKY_R0_REGNUM
&& dw_reg
<= CSKY_R0_REGNUM
+ 31)
2573 /* For Hi, Lo, PC. */
2574 if (dw_reg
== CSKY_HI_REGNUM
|| dw_reg
== CSKY_LO_REGNUM
2575 || dw_reg
== CSKY_PC_REGNUM
)
2578 /* For Float and Vector pseudo registers. */
2579 if (dw_reg
>= FV_PSEUDO_REGNO_FIRST
&& dw_reg
<= FV_PSEUDO_REGNO_LAST
)
2583 xsnprintf (name_buf
, sizeof (name_buf
), "s%d",
2584 dw_reg
- FV_PSEUDO_REGNO_FIRST
);
2585 return user_reg_map_name_to_regnum (gdbarch
, name_buf
,
2589 /* Others, unknown. */
2593 /* Override interface for command: info register. */
2596 csky_print_registers_info (struct gdbarch
*gdbarch
, struct ui_file
*file
,
2597 struct frame_info
*frame
, int regnum
, int all
)
2599 /* Call default print_registers_info function. */
2600 default_print_registers_info (gdbarch
, file
, frame
, regnum
, all
);
2602 /* For command: info register. */
2603 if (regnum
== -1 && all
== 0)
2605 default_print_registers_info (gdbarch
, file
, frame
,
2607 default_print_registers_info (gdbarch
, file
, frame
,
2608 CSKY_EPC_REGNUM
, 0);
2609 default_print_registers_info (gdbarch
, file
, frame
,
2610 CSKY_CR0_REGNUM
, 0);
2611 default_print_registers_info (gdbarch
, file
, frame
,
2612 CSKY_EPSR_REGNUM
, 0);
2617 /* Check whether xml has discribled the essential regs. */
2620 csky_essential_reg_check (const struct csky_supported_tdesc_register
*reg
)
2622 if ((strcmp (reg
->name
, "pc") == 0)
2623 && (reg
->num
== CSKY_PC_REGNUM
))
2624 return CSKY_TDESC_REGS_PC_NUMBERED
;
2625 else if ((strcmp (reg
->name
, "r14") == 0)
2626 && (reg
->num
== CSKY_SP_REGNUM
))
2627 return CSKY_TDESC_REGS_SP_NUMBERED
;
2628 else if ((strcmp (reg
->name
, "r15") == 0)
2629 && (reg
->num
== CSKY_LR_REGNUM
))
2630 return CSKY_TDESC_REGS_LR_NUMBERED
;
2635 /* Check whether xml has discribled the fr0~fr15 regs. */
2638 csky_fr0_fr15_reg_check (const struct csky_supported_tdesc_register
*reg
) {
2640 for (i
= 0; i
< 16; i
++)
2642 if ((strcmp (reg
->name
, csky_supported_fpu_regs
[i
].name
) == 0)
2643 && (csky_supported_fpu_regs
[i
].num
== reg
->num
))
2650 /* Check whether xml has discribled the fr16~fr31 regs. */
2653 csky_fr16_fr31_reg_check (const struct csky_supported_tdesc_register
*reg
) {
2655 for (i
= 0; i
< 16; i
++)
2657 if ((strcmp (reg
->name
, csky_supported_fpu_regs
[i
+ 16].name
) == 0)
2658 && (csky_supported_fpu_regs
[i
+ 16].num
== reg
->num
))
2665 /* Check whether xml has discribled the vr0~vr15 regs. */
2668 csky_vr0_vr15_reg_check (const struct csky_supported_tdesc_register
*reg
) {
2670 for (i
= 0; i
< 16; i
++)
2672 if ((strcmp (reg
->name
, csky_supported_fpu_regs
[i
+ 32].name
) == 0)
2673 && (csky_supported_fpu_regs
[i
+ 32].num
== reg
->num
))
2680 /* Return pseudo reg's name. */
2683 csky_pseudo_register_name (struct gdbarch
*gdbarch
, int regno
)
2685 int num_regs
= gdbarch_num_regs (gdbarch
);
2686 csky_gdbarch_tdep
*tdep
2687 = gdbarch_tdep
<csky_gdbarch_tdep
> (gdbarch
);
2691 if (tdep
->fv_pseudo_registers_count
)
2693 static const char *const fv_pseudo_names
[] = {
2694 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
2695 "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15",
2696 "s16", "s17", "s18", "s19", "s20", "s21", "s22", "s23",
2697 "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
2698 "s32", "s33", "s34", "s35", "s36", "s37", "s38", "s39",
2699 "s40", "s41", "s42", "s43", "s44", "s45", "s46", "s47",
2700 "s48", "s49", "s50", "s51", "s52", "s53", "s54", "s55",
2701 "s56", "s57", "s58", "s59", "s60", "s61", "s62", "s63",
2702 "s64", "s65", "s66", "s67", "s68", "s69", "s70", "s71",
2703 "s72", "s73", "s74", "s75", "s76", "s77", "s78", "s79",
2704 "s80", "s81", "s82", "s83", "s84", "s85", "s86", "s87",
2705 "s88", "s89", "s90", "s91", "s92", "s93", "s94", "s95",
2706 "s96", "s97", "s98", "s99", "s100", "s101", "s102", "s103",
2707 "s104", "s105", "s106", "s107", "s108", "s109", "s110", "s111",
2708 "s112", "s113", "s114", "s115", "s116", "s117", "s118", "s119",
2709 "s120", "s121", "s122", "s123", "s124", "s125", "s126", "s127",
2712 if (regno
< tdep
->fv_pseudo_registers_count
)
2714 if ((regno
< 64) && ((regno
% 4) >= 2) && !tdep
->has_vr0
)
2716 else if ((regno
>= 64) && ((regno
% 4) >= 2))
2719 return fv_pseudo_names
[regno
];
2726 /* Read for csky pseudo regs. */
2728 static enum register_status
2729 csky_pseudo_register_read (struct gdbarch
*gdbarch
,
2730 struct readable_regcache
*regcache
,
2731 int regnum
, gdb_byte
*buf
)
2733 int num_regs
= gdbarch_num_regs (gdbarch
);
2734 csky_gdbarch_tdep
*tdep
2735 = gdbarch_tdep
<csky_gdbarch_tdep
> (gdbarch
);
2739 if (regnum
< tdep
->fv_pseudo_registers_count
)
2741 enum register_status status
;
2744 gdb_byte reg_buf
[16];
2746 /* Ensure getting s0~s63 from vrx if tdep->has_vr0 is ture. */
2751 gdb_regnum
= CSKY_VR0_REGNUM
+ (regnum
/ 4);
2752 offset
= (regnum
% 4) * 4;
2756 gdb_regnum
= CSKY_FR16_REGNUM
+ ((regnum
- 64) / 4);
2757 if ((regnum
% 4) >= 2)
2758 return REG_UNAVAILABLE
;
2759 offset
= (regnum
% 2) * 4;
2764 gdb_regnum
= CSKY_FR0_REGNUM
+ (regnum
/ 4);
2765 if ((regnum
% 4) >= 2)
2766 return REG_UNAVAILABLE
;
2767 offset
= (regnum
% 2) * 4;
2770 status
= regcache
->raw_read (gdb_regnum
, reg_buf
);
2771 if (status
== REG_VALID
)
2772 memcpy (buf
, reg_buf
+ offset
, 4);
2779 /* Write for csky pseudo regs. */
2782 csky_pseudo_register_write (struct gdbarch
*gdbarch
, struct regcache
*regcache
,
2783 int regnum
, const gdb_byte
*buf
)
2785 int num_regs
= gdbarch_num_regs (gdbarch
);
2786 csky_gdbarch_tdep
*tdep
2787 = gdbarch_tdep
<csky_gdbarch_tdep
> (gdbarch
);
2791 if (regnum
< tdep
->fv_pseudo_registers_count
)
2793 gdb_byte reg_buf
[16];
2801 gdb_regnum
= CSKY_VR0_REGNUM
+ (regnum
/ 4);
2802 offset
= (regnum
% 4) * 4;
2806 gdb_regnum
= CSKY_FR16_REGNUM
+ ((regnum
- 64) / 4);
2807 if ((regnum
% 4) >= 2)
2809 offset
= (regnum
% 2) * 4;
2814 gdb_regnum
= CSKY_FR0_REGNUM
+ (regnum
/ 4);
2815 if ((regnum
% 4) >= 2)
2817 offset
= (regnum
% 2) * 4;
2820 regcache
->raw_read (gdb_regnum
, reg_buf
);
2821 memcpy (reg_buf
+ offset
, buf
, 4);
2822 regcache
->raw_write (gdb_regnum
, reg_buf
);
2829 /* Initialize the current architecture based on INFO. If possible,
2830 re-use an architecture from ARCHES, which is a list of
2831 architectures already created during this debugging session.
2833 Called at program startup, when reading a core file, and when
2834 reading a binary file. */
2836 static struct gdbarch
*
2837 csky_gdbarch_init (struct gdbarch_info info
, struct gdbarch_list
*arches
)
2839 struct gdbarch
*gdbarch
;
2840 /* Analyze info.abfd. */
2841 unsigned int fpu_abi
= 0;
2842 unsigned int vdsp_version
= 0;
2843 unsigned int fpu_hardfp
= 0;
2844 /* Analyze info.target_desc */
2849 tdesc_arch_data_up tdesc_data
;
2851 if (tdesc_has_registers (info
.target_desc
))
2857 int feature_names_count
= ARRAY_SIZE (csky_supported_tdesc_feature_names
);
2858 int support_tdesc_regs_count
2859 = csky_get_supported_tdesc_registers_count();
2860 const struct csky_supported_tdesc_register
*tdesc_reg
;
2861 const struct tdesc_feature
*feature
;
2863 tdesc_data
= tdesc_data_alloc ();
2864 for (index
= 0; index
< feature_names_count
; index
++)
2866 feature
= tdesc_find_feature (info
.target_desc
,
2867 csky_supported_tdesc_feature_names
[index
]);
2868 if (feature
!= NULL
)
2870 for (i
= 0; i
< support_tdesc_regs_count
; i
++)
2872 tdesc_reg
= csky_get_supported_register_by_index (i
);
2875 numbered
= tdesc_numbered_register (feature
, tdesc_data
.get(),
2879 valid_p
|= csky_essential_reg_check (tdesc_reg
);
2880 has_fr0
|= csky_fr0_fr15_reg_check (tdesc_reg
);
2881 has_fr16
|= csky_fr16_fr31_reg_check (tdesc_reg
);
2882 has_vr0
|= csky_vr0_vr15_reg_check (tdesc_reg
);
2883 if (num_regs
< tdesc_reg
->num
)
2884 num_regs
= tdesc_reg
->num
;
2889 if (valid_p
!= CSKY_TDESC_REGS_ESSENTIAL_VALUE
)
2893 /* When the type of bfd file is srec(or any files are not elf),
2894 the E_FLAGS will be not credible. */
2895 if (info
.abfd
!= NULL
&& bfd_get_flavour (info
.abfd
) == bfd_target_elf_flavour
)
2897 /* Get FPU, VDSP build options. */
2898 fpu_abi
= bfd_elf_get_obj_attr_int (info
.abfd
,
2901 vdsp_version
= bfd_elf_get_obj_attr_int (info
.abfd
,
2903 Tag_CSKY_VDSP_VERSION
);
2904 fpu_hardfp
= bfd_elf_get_obj_attr_int (info
.abfd
,
2906 Tag_CSKY_FPU_HARDFP
);
2909 /* Find a candidate among the list of pre-declared architectures. */
2910 for (arches
= gdbarch_list_lookup_by_info (arches
, &info
);
2912 arches
= gdbarch_list_lookup_by_info (arches
->next
, &info
))
2914 csky_gdbarch_tdep
*tdep
2915 = gdbarch_tdep
<csky_gdbarch_tdep
> (arches
->gdbarch
);
2916 if (fpu_abi
!= tdep
->fpu_abi
)
2918 if (vdsp_version
!= tdep
->vdsp_version
)
2920 if (fpu_hardfp
!= tdep
->fpu_hardfp
)
2923 /* Found a match. */
2924 return arches
->gdbarch
;
2927 /* None found, create a new architecture from the information
2929 csky_gdbarch_tdep
*tdep
= new csky_gdbarch_tdep
;
2930 gdbarch
= gdbarch_alloc (&info
, tdep
);
2931 tdep
->fpu_abi
= fpu_abi
;
2932 tdep
->vdsp_version
= vdsp_version
;
2933 tdep
->fpu_hardfp
= fpu_hardfp
;
2935 if (tdesc_data
!= NULL
)
2937 if ((has_vr0
== CSKY_FULL16_ONEHOT_VALUE
)
2938 && (has_fr16
== CSKY_FULL16_ONEHOT_VALUE
))
2941 tdep
->fv_pseudo_registers_count
= 128;
2943 else if ((has_vr0
== CSKY_FULL16_ONEHOT_VALUE
)
2944 && (has_fr16
!= CSKY_FULL16_ONEHOT_VALUE
))
2947 tdep
->fv_pseudo_registers_count
= 64;
2949 else if ((has_fr0
== CSKY_FULL16_ONEHOT_VALUE
)
2950 && (has_vr0
!= CSKY_FULL16_ONEHOT_VALUE
))
2953 tdep
->fv_pseudo_registers_count
= 64;
2958 tdep
->fv_pseudo_registers_count
= 0;
2964 tdep
->fv_pseudo_registers_count
= 64;
2967 /* Target data types. */
2968 set_gdbarch_ptr_bit (gdbarch
, 32);
2969 set_gdbarch_addr_bit (gdbarch
, 32);
2970 set_gdbarch_short_bit (gdbarch
, 16);
2971 set_gdbarch_int_bit (gdbarch
, 32);
2972 set_gdbarch_long_bit (gdbarch
, 32);
2973 set_gdbarch_long_long_bit (gdbarch
, 64);
2974 set_gdbarch_float_bit (gdbarch
, 32);
2975 set_gdbarch_double_bit (gdbarch
, 64);
2976 set_gdbarch_float_format (gdbarch
, floatformats_ieee_single
);
2977 set_gdbarch_double_format (gdbarch
, floatformats_ieee_double
);
2979 /* Information about the target architecture. */
2980 set_gdbarch_return_value (gdbarch
, csky_return_value
);
2981 set_gdbarch_breakpoint_kind_from_pc (gdbarch
, csky_breakpoint_kind_from_pc
);
2982 set_gdbarch_sw_breakpoint_from_kind (gdbarch
, csky_sw_breakpoint_from_kind
);
2984 /* Register architecture. */
2985 set_gdbarch_num_regs (gdbarch
, CSKY_NUM_REGS
);
2986 set_gdbarch_pc_regnum (gdbarch
, CSKY_PC_REGNUM
);
2987 set_gdbarch_sp_regnum (gdbarch
, CSKY_SP_REGNUM
);
2988 set_gdbarch_register_name (gdbarch
, csky_register_name
);
2989 set_gdbarch_register_type (gdbarch
, csky_register_type
);
2990 set_gdbarch_read_pc (gdbarch
, csky_read_pc
);
2991 set_gdbarch_write_pc (gdbarch
, csky_write_pc
);
2992 set_gdbarch_print_registers_info (gdbarch
, csky_print_registers_info
);
2993 csky_add_reggroups (gdbarch
);
2994 set_gdbarch_register_reggroup_p (gdbarch
, csky_register_reggroup_p
);
2995 set_gdbarch_stab_reg_to_regnum (gdbarch
, csky_dwarf_reg_to_regnum
);
2996 set_gdbarch_dwarf2_reg_to_regnum (gdbarch
, csky_dwarf_reg_to_regnum
);
2997 dwarf2_frame_set_init_reg (gdbarch
, csky_dwarf2_frame_init_reg
);
2999 /* Functions to analyze frames. */
3000 frame_base_set_default (gdbarch
, &csky_frame_base
);
3001 set_gdbarch_skip_prologue (gdbarch
, csky_skip_prologue
);
3002 set_gdbarch_inner_than (gdbarch
, core_addr_lessthan
);
3003 set_gdbarch_frame_align (gdbarch
, csky_frame_align
);
3004 set_gdbarch_stack_frame_destroyed_p (gdbarch
, csky_stack_frame_destroyed_p
);
3006 /* Functions handling dummy frames. */
3007 set_gdbarch_push_dummy_call (gdbarch
, csky_push_dummy_call
);
3009 /* Frame unwinders. Use DWARF debug info if available,
3010 otherwise use our own unwinder. */
3011 dwarf2_append_unwinders (gdbarch
);
3012 frame_unwind_append_unwinder (gdbarch
, &csky_stub_unwind
);
3013 frame_unwind_append_unwinder (gdbarch
, &csky_unwind_cache
);
3016 set_gdbarch_memory_insert_breakpoint (gdbarch
,
3017 csky_memory_insert_breakpoint
);
3018 set_gdbarch_memory_remove_breakpoint (gdbarch
,
3019 csky_memory_remove_breakpoint
);
3021 /* Hook in ABI-specific overrides, if they have been registered. */
3022 gdbarch_init_osabi (info
, gdbarch
);
3024 /* Support simple overlay manager. */
3025 set_gdbarch_overlay_update (gdbarch
, simple_overlay_update
);
3026 set_gdbarch_char_signed (gdbarch
, 0);
3028 if (tdesc_data
!= nullptr)
3030 set_gdbarch_num_regs (gdbarch
, (num_regs
+ 1));
3031 tdesc_use_registers (gdbarch
, info
.target_desc
, std::move (tdesc_data
));
3032 set_gdbarch_register_type (gdbarch
, csky_register_type
);
3033 set_gdbarch_register_reggroup_p (gdbarch
,
3034 csky_register_reggroup_p
);
3037 if (tdep
->fv_pseudo_registers_count
)
3039 set_gdbarch_num_pseudo_regs (gdbarch
,
3040 tdep
->fv_pseudo_registers_count
);
3041 set_gdbarch_pseudo_register_read (gdbarch
,
3042 csky_pseudo_register_read
);
3043 set_gdbarch_pseudo_register_write (gdbarch
,
3044 csky_pseudo_register_write
);
3045 set_tdesc_pseudo_register_name (gdbarch
, csky_pseudo_register_name
);
3051 void _initialize_csky_tdep ();
3053 _initialize_csky_tdep ()
3056 register_gdbarch_init (bfd_arch_csky
, csky_gdbarch_init
);
3058 csky_init_reggroup ();
3060 /* Allow debugging this file's internals. */
3061 add_setshow_boolean_cmd ("csky", class_maintenance
, &csky_debug
,
3062 _("Set C-Sky debugging."),
3063 _("Show C-Sky debugging."),
3064 _("When on, C-Sky specific debugging is enabled."),
3067 &setdebuglist
, &showdebuglist
);