]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/or1k-tdep.c
gdb: remove gdbcmd.h
[thirdparty/binutils-gdb.git] / gdb / or1k-tdep.c
1 /* Target-dependent code for the 32-bit OpenRISC 1000, for the GDB.
2 Copyright (C) 2008-2024 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #include "extract-store-integer.h"
20 #include "frame.h"
21 #include "inferior.h"
22 #include "symtab.h"
23 #include "value.h"
24 #include "cli/cli-cmds.h"
25 #include "language.h"
26 #include "gdbcore.h"
27 #include "symfile.h"
28 #include "objfiles.h"
29 #include "gdbtypes.h"
30 #include "target.h"
31 #include "regcache.h"
32 #include "gdbsupport/gdb-safe-ctype.h"
33 #include "reggroups.h"
34 #include "arch-utils.h"
35 #include "frame-unwind.h"
36 #include "frame-base.h"
37 #include "dwarf2/frame.h"
38 #include "trad-frame.h"
39 #include "regset.h"
40 #include "remote.h"
41 #include "target-descriptions.h"
42 #include <inttypes.h>
43 #include "dis-asm.h"
44 #include "gdbarch.h"
45
46 /* OpenRISC specific includes. */
47 #include "or1k-tdep.h"
48 #include "features/or1k.c"
49 \f
50
51 /* Global debug flag. */
52
53 static bool or1k_debug = false;
54
55 static void
56 show_or1k_debug (struct ui_file *file, int from_tty,
57 struct cmd_list_element *c, const char *value)
58 {
59 gdb_printf (file, _("OpenRISC debugging is %s.\n"), value);
60 }
61
62
63 /* The target-dependent structure for gdbarch. */
64
65 struct or1k_gdbarch_tdep : gdbarch_tdep_base
66 {
67 int bytes_per_word = 0;
68 int bytes_per_address = 0;
69 CGEN_CPU_DESC gdb_cgen_cpu_desc = nullptr;
70 };
71
72 /* Support functions for the architecture definition. */
73
74 /* Get an instruction from memory. */
75
76 static ULONGEST
77 or1k_fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR addr)
78 {
79 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
80 gdb_byte buf[OR1K_INSTLEN];
81
82 if (target_read_code (addr, buf, OR1K_INSTLEN)) {
83 memory_error (TARGET_XFER_E_IO, addr);
84 }
85
86 return extract_unsigned_integer (buf, OR1K_INSTLEN, byte_order);
87 }
88
89 /* Generic function to read bits from an instruction. */
90
91 static bool
92 or1k_analyse_inst (uint32_t inst, const char *format, ...)
93 {
94 /* Break out each field in turn, validating as we go. */
95 va_list ap;
96 int i;
97 int iptr = 0; /* Instruction pointer */
98
99 va_start (ap, format);
100
101 for (i = 0; 0 != format[i];)
102 {
103 const char *start_ptr;
104 char *end_ptr;
105
106 uint32_t bits; /* Bit substring of interest */
107 uint32_t width; /* Substring width */
108 uint32_t *arg_ptr;
109
110 switch (format[i])
111 {
112 case ' ':
113 i++;
114 break; /* Formatting: ignored */
115
116 case '0':
117 case '1': /* Constant bit field */
118 bits = (inst >> (OR1K_INSTBITLEN - iptr - 1)) & 0x1;
119
120 if ((format[i] - '0') != bits)
121 return false;
122
123 iptr++;
124 i++;
125 break;
126
127 case '%': /* Bit field */
128 i++;
129 start_ptr = &(format[i]);
130 width = strtoul (start_ptr, &end_ptr, 10);
131
132 /* Check we got something, and if so skip on. */
133 if (start_ptr == end_ptr)
134 error (_("bitstring \"%s\" at offset %d has no length field."),
135 format, i);
136
137 i += end_ptr - start_ptr;
138
139 /* Look for and skip the terminating 'b'. If it's not there, we
140 still give a fatal error, because these are fixed strings that
141 just should not be wrong. */
142 if ('b' != format[i++])
143 error (_("bitstring \"%s\" at offset %d has no terminating 'b'."),
144 format, i);
145
146 /* Break out the field. There is a special case with a bit width
147 of 32. */
148 if (32 == width)
149 bits = inst;
150 else
151 bits =
152 (inst >> (OR1K_INSTBITLEN - iptr - width)) & ((1 << width) - 1);
153
154 arg_ptr = va_arg (ap, uint32_t *);
155 *arg_ptr = bits;
156 iptr += width;
157 break;
158
159 default:
160 error (_("invalid character in bitstring \"%s\" at offset %d."),
161 format, i);
162 break;
163 }
164 }
165
166 /* Is the length OK? */
167 gdb_assert (OR1K_INSTBITLEN == iptr);
168
169 return true; /* Success */
170 }
171
172 /* This is used to parse l.addi instructions during various prologue
173 analysis routines. The l.addi instruction has semantics:
174
175 assembly: l.addi rD,rA,I
176 implementation: rD = rA + sign_extend(Immediate)
177
178 The rd_ptr, ra_ptr and simm_ptr must be non NULL pointers and are used
179 to store the parse results. Upon successful parsing true is returned,
180 false on failure. */
181
182 static bool
183 or1k_analyse_l_addi (uint32_t inst, unsigned int *rd_ptr,
184 unsigned int *ra_ptr, int *simm_ptr)
185 {
186 /* Instruction fields */
187 uint32_t rd, ra, i;
188
189 if (or1k_analyse_inst (inst, "10 0111 %5b %5b %16b", &rd, &ra, &i))
190 {
191 /* Found it. Construct the result fields. */
192 *rd_ptr = (unsigned int) rd;
193 *ra_ptr = (unsigned int) ra;
194 *simm_ptr = (int) (((i & 0x8000) == 0x8000) ? 0xffff0000 | i : i);
195
196 return true; /* Success */
197 }
198 else
199 return false; /* Failure */
200 }
201
202 /* This is used to to parse store instructions during various prologue
203 analysis routines. The l.sw instruction has semantics:
204
205 assembly: l.sw I(rA),rB
206 implementation: store rB contents to memory at effective address of
207 rA + sign_extend(Immediate)
208
209 The simm_ptr, ra_ptr and rb_ptr must be non NULL pointers and are used
210 to store the parse results. Upon successful parsing true is returned,
211 false on failure. */
212
213 static bool
214 or1k_analyse_l_sw (uint32_t inst, int *simm_ptr, unsigned int *ra_ptr,
215 unsigned int *rb_ptr)
216 {
217 /* Instruction fields */
218 uint32_t ihi, ilo, ra, rb;
219
220 if (or1k_analyse_inst (inst, "11 0101 %5b %5b %5b %11b", &ihi, &ra, &rb,
221 &ilo))
222
223 {
224 /* Found it. Construct the result fields. */
225 *simm_ptr = (int) ((ihi << 11) | ilo);
226 *simm_ptr |= ((ihi & 0x10) == 0x10) ? 0xffff0000 : 0;
227
228 *ra_ptr = (unsigned int) ra;
229 *rb_ptr = (unsigned int) rb;
230
231 return true; /* Success */
232 }
233 else
234 return false; /* Failure */
235 }
236 \f
237
238 /* Functions defining the architecture. */
239
240 /* Implement the return_value gdbarch method. */
241
242 static enum return_value_convention
243 or1k_return_value (struct gdbarch *gdbarch, struct value *functype,
244 struct type *valtype, struct regcache *regcache,
245 gdb_byte *readbuf, const gdb_byte *writebuf)
246 {
247 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
248 enum type_code rv_type = valtype->code ();
249 unsigned int rv_size = valtype->length ();
250 or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
251 int bpw = tdep->bytes_per_word;
252
253 /* Deal with struct/union as addresses. If an array won't fit in a
254 single register it is returned as address. Anything larger than 2
255 registers needs to also be passed as address (matches gcc
256 default_return_in_memory). */
257 if ((TYPE_CODE_STRUCT == rv_type) || (TYPE_CODE_UNION == rv_type)
258 || ((TYPE_CODE_ARRAY == rv_type) && (rv_size > bpw))
259 || (rv_size > 2 * bpw))
260 {
261 if (readbuf != NULL)
262 {
263 ULONGEST tmp;
264
265 regcache_cooked_read_unsigned (regcache, OR1K_RV_REGNUM, &tmp);
266 read_memory (tmp, readbuf, rv_size);
267 }
268 if (writebuf != NULL)
269 {
270 ULONGEST tmp;
271
272 regcache_cooked_read_unsigned (regcache, OR1K_RV_REGNUM, &tmp);
273 write_memory (tmp, writebuf, rv_size);
274 }
275
276 return RETURN_VALUE_ABI_RETURNS_ADDRESS;
277 }
278
279 if (rv_size <= bpw)
280 {
281 /* Up to one word scalars are returned in R11. */
282 if (readbuf != NULL)
283 {
284 ULONGEST tmp;
285
286 regcache_cooked_read_unsigned (regcache, OR1K_RV_REGNUM, &tmp);
287 store_unsigned_integer (readbuf, rv_size, byte_order, tmp);
288
289 }
290 if (writebuf != NULL)
291 {
292 gdb_byte *buf = XCNEWVEC(gdb_byte, bpw);
293
294 if (BFD_ENDIAN_BIG == byte_order)
295 memcpy (buf + (sizeof (gdb_byte) * bpw) - rv_size, writebuf,
296 rv_size);
297 else
298 memcpy (buf, writebuf, rv_size);
299
300 regcache->cooked_write (OR1K_RV_REGNUM, buf);
301
302 free (buf);
303 }
304 }
305 else
306 {
307 /* 2 word scalars are returned in r11/r12 (with the MS word in r11). */
308 if (readbuf != NULL)
309 {
310 ULONGEST tmp_lo;
311 ULONGEST tmp_hi;
312 ULONGEST tmp;
313
314 regcache_cooked_read_unsigned (regcache, OR1K_RV_REGNUM,
315 &tmp_hi);
316 regcache_cooked_read_unsigned (regcache, OR1K_RV_REGNUM + 1,
317 &tmp_lo);
318 tmp = (tmp_hi << (bpw * 8)) | tmp_lo;
319
320 store_unsigned_integer (readbuf, rv_size, byte_order, tmp);
321 }
322 if (writebuf != NULL)
323 {
324 gdb_byte *buf_lo = XCNEWVEC(gdb_byte, bpw);
325 gdb_byte *buf_hi = XCNEWVEC(gdb_byte, bpw);
326
327 /* This is cheating. We assume that we fit in 2 words exactly,
328 which wouldn't work if we had (say) a 6-byte scalar type on a
329 big endian architecture (with the OpenRISC 1000 usually is). */
330 memcpy (buf_hi, writebuf, rv_size - bpw);
331 memcpy (buf_lo, writebuf + bpw, bpw);
332
333 regcache->cooked_write (OR1K_RV_REGNUM, buf_hi);
334 regcache->cooked_write (OR1K_RV_REGNUM + 1, buf_lo);
335
336 free (buf_lo);
337 free (buf_hi);
338 }
339 }
340
341 return RETURN_VALUE_REGISTER_CONVENTION;
342 }
343
344 /* OR1K always uses a l.trap instruction for breakpoints. */
345
346 constexpr gdb_byte or1k_break_insn[] = {0x21, 0x00, 0x00, 0x01};
347
348 typedef BP_MANIPULATION (or1k_break_insn) or1k_breakpoint;
349
350 static int
351 or1k_delay_slot_p (struct gdbarch *gdbarch, CORE_ADDR pc)
352 {
353 const CGEN_INSN *insn;
354 CGEN_FIELDS tmp_fields;
355 or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
356
357 insn = cgen_lookup_insn (tdep->gdb_cgen_cpu_desc,
358 NULL,
359 or1k_fetch_instruction (gdbarch, pc),
360 NULL, 32, &tmp_fields, 0);
361
362 /* NULL here would mean the last instruction was not understood by cgen.
363 This should not usually happen, but if it does it's not a delay slot. */
364 if (insn == NULL)
365 return 0;
366
367 /* TODO: we should add a delay slot flag to the CGEN_INSN and remove
368 this hard coded test. */
369 return ((CGEN_INSN_NUM (insn) == OR1K_INSN_L_J)
370 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_JAL)
371 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_JR)
372 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_JALR)
373 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_BNF)
374 || (CGEN_INSN_NUM (insn) == OR1K_INSN_L_BF));
375 }
376
377 /* Implement the single_step_through_delay gdbarch method. */
378
379 static int
380 or1k_single_step_through_delay (struct gdbarch *gdbarch,
381 const frame_info_ptr &this_frame)
382 {
383 ULONGEST val;
384 CORE_ADDR ppc;
385 CORE_ADDR npc;
386 regcache *regcache = get_thread_regcache (inferior_thread ());
387
388 /* Get the previous and current instruction addresses. If they are not
389 adjacent, we cannot be in a delay slot. */
390 regcache_cooked_read_unsigned (regcache, OR1K_PPC_REGNUM, &val);
391 ppc = (CORE_ADDR) val;
392 regcache_cooked_read_unsigned (regcache, OR1K_NPC_REGNUM, &val);
393 npc = (CORE_ADDR) val;
394
395 if (0x4 != (npc - ppc))
396 return 0;
397
398 return or1k_delay_slot_p (gdbarch, ppc);
399 }
400
401 /* or1k_software_single_step() is called just before we want to resume
402 the inferior, if we want to single-step it but there is no hardware
403 or kernel single-step support (OpenRISC on GNU/Linux for example). We
404 find the target of the coming instruction skipping over delay slots
405 and breakpoint it. */
406
407 std::vector<CORE_ADDR>
408 or1k_software_single_step (struct regcache *regcache)
409 {
410 struct gdbarch *gdbarch = regcache->arch ();
411 CORE_ADDR pc, next_pc;
412
413 pc = regcache_read_pc (regcache);
414 next_pc = pc + 4;
415
416 if (or1k_delay_slot_p (gdbarch, pc))
417 next_pc += 4;
418
419 return {next_pc};
420 }
421
422 /* Name for or1k general registers. */
423
424 static const char *const or1k_reg_names[OR1K_NUM_REGS] = {
425 /* general purpose registers */
426 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
427 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
428 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
429 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
430
431 /* previous program counter, next program counter and status register */
432 "ppc", "npc", "sr"
433 };
434
435 static int
436 or1k_is_arg_reg (unsigned int regnum)
437 {
438 return (OR1K_FIRST_ARG_REGNUM <= regnum)
439 && (regnum <= OR1K_LAST_ARG_REGNUM);
440 }
441
442 static int
443 or1k_is_callee_saved_reg (unsigned int regnum)
444 {
445 return (OR1K_FIRST_SAVED_REGNUM <= regnum) && (0 == regnum % 2);
446 }
447
448 /* Implement the skip_prologue gdbarch method. */
449
450 static CORE_ADDR
451 or1k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
452 {
453 CORE_ADDR start_pc;
454 CORE_ADDR addr;
455 uint32_t inst;
456
457 unsigned int ra, rb, rd; /* for instruction analysis */
458 int simm;
459
460 int frame_size = 0;
461
462 /* Try using SAL first if we have symbolic information available. This
463 only works for DWARF 2, not STABS. */
464
465 if (find_pc_partial_function (pc, NULL, &start_pc, NULL))
466 {
467 CORE_ADDR prologue_end = skip_prologue_using_sal (gdbarch, pc);
468
469 if (0 != prologue_end)
470 {
471 struct symtab_and_line prologue_sal = find_pc_line (start_pc, 0);
472 struct compunit_symtab *compunit
473 = prologue_sal.symtab->compunit ();
474 const char *debug_format = compunit->debugformat ();
475
476 if ((NULL != debug_format)
477 && (strlen ("dwarf") <= strlen (debug_format))
478 && (0 == strncasecmp ("dwarf", debug_format, strlen ("dwarf"))))
479 return (prologue_end > pc) ? prologue_end : pc;
480 }
481 }
482
483 /* Look to see if we can find any of the standard prologue sequence. All
484 quite difficult, since any or all of it may be missing. So this is
485 just a best guess! */
486
487 addr = pc; /* Where we have got to */
488 inst = or1k_fetch_instruction (gdbarch, addr);
489
490 /* Look for the new stack pointer being set up. */
491 if (or1k_analyse_l_addi (inst, &rd, &ra, &simm)
492 && (OR1K_SP_REGNUM == rd) && (OR1K_SP_REGNUM == ra)
493 && (simm < 0) && (0 == (simm % 4)))
494 {
495 frame_size = -simm;
496 addr += OR1K_INSTLEN;
497 inst = or1k_fetch_instruction (gdbarch, addr);
498 }
499
500 /* Look for the frame pointer being manipulated. */
501 if (or1k_analyse_l_sw (inst, &simm, &ra, &rb)
502 && (OR1K_SP_REGNUM == ra) && (OR1K_FP_REGNUM == rb)
503 && (simm >= 0) && (0 == (simm % 4)))
504 {
505 addr += OR1K_INSTLEN;
506 inst = or1k_fetch_instruction (gdbarch, addr);
507
508 gdb_assert (or1k_analyse_l_addi (inst, &rd, &ra, &simm)
509 && (OR1K_FP_REGNUM == rd) && (OR1K_SP_REGNUM == ra)
510 && (simm == frame_size));
511
512 addr += OR1K_INSTLEN;
513 inst = or1k_fetch_instruction (gdbarch, addr);
514 }
515
516 /* Look for the link register being saved. */
517 if (or1k_analyse_l_sw (inst, &simm, &ra, &rb)
518 && (OR1K_SP_REGNUM == ra) && (OR1K_LR_REGNUM == rb)
519 && (simm >= 0) && (0 == (simm % 4)))
520 {
521 addr += OR1K_INSTLEN;
522 inst = or1k_fetch_instruction (gdbarch, addr);
523 }
524
525 /* Look for arguments or callee-saved register being saved. The register
526 must be one of the arguments (r3-r8) or the 10 callee saved registers
527 (r10, r12, r14, r16, r18, r20, r22, r24, r26, r28, r30). The base
528 register must be the FP (for the args) or the SP (for the callee_saved
529 registers). */
530 while (1)
531 {
532 if (or1k_analyse_l_sw (inst, &simm, &ra, &rb)
533 && (((OR1K_FP_REGNUM == ra) && or1k_is_arg_reg (rb))
534 || ((OR1K_SP_REGNUM == ra) && or1k_is_callee_saved_reg (rb)))
535 && (0 == (simm % 4)))
536 {
537 addr += OR1K_INSTLEN;
538 inst = or1k_fetch_instruction (gdbarch, addr);
539 }
540 else
541 {
542 /* Nothing else to look for. We have found the end of the
543 prologue. */
544 break;
545 }
546 }
547 return addr;
548 }
549
550 /* Implement the frame_align gdbarch method. */
551
552 static CORE_ADDR
553 or1k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
554 {
555 return align_down (sp, OR1K_STACK_ALIGN);
556 }
557
558 /* Implement the unwind_pc gdbarch method. */
559
560 static CORE_ADDR
561 or1k_unwind_pc (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
562 {
563 CORE_ADDR pc;
564
565 if (or1k_debug)
566 gdb_printf (gdb_stdlog, "or1k_unwind_pc, next_frame=%d\n",
567 frame_relative_level (next_frame));
568
569 pc = frame_unwind_register_unsigned (next_frame, OR1K_NPC_REGNUM);
570
571 if (or1k_debug)
572 gdb_printf (gdb_stdlog, "or1k_unwind_pc, pc=%s\n",
573 paddress (gdbarch, pc));
574
575 return pc;
576 }
577
578 /* Implement the unwind_sp gdbarch method. */
579
580 static CORE_ADDR
581 or1k_unwind_sp (struct gdbarch *gdbarch, const frame_info_ptr &next_frame)
582 {
583 CORE_ADDR sp;
584
585 if (or1k_debug)
586 gdb_printf (gdb_stdlog, "or1k_unwind_sp, next_frame=%d\n",
587 frame_relative_level (next_frame));
588
589 sp = frame_unwind_register_unsigned (next_frame, OR1K_SP_REGNUM);
590
591 if (or1k_debug)
592 gdb_printf (gdb_stdlog, "or1k_unwind_sp, sp=%s\n",
593 paddress (gdbarch, sp));
594
595 return sp;
596 }
597
598 /* Implement the push_dummy_code gdbarch method. */
599
600 static CORE_ADDR
601 or1k_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
602 CORE_ADDR function, struct value **args, int nargs,
603 struct type *value_type, CORE_ADDR * real_pc,
604 CORE_ADDR * bp_addr, struct regcache *regcache)
605 {
606 CORE_ADDR bp_slot;
607
608 /* Reserve enough room on the stack for our breakpoint instruction. */
609 bp_slot = sp - 4;
610 /* Store the address of that breakpoint. */
611 *bp_addr = bp_slot;
612 /* keeping the stack aligned. */
613 sp = or1k_frame_align (gdbarch, bp_slot);
614 /* The call starts at the callee's entry point. */
615 *real_pc = function;
616
617 return sp;
618 }
619
620 /* Implement the push_dummy_call gdbarch method. */
621
622 static CORE_ADDR
623 or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
624 struct regcache *regcache, CORE_ADDR bp_addr,
625 int nargs, struct value **args, CORE_ADDR sp,
626 function_call_return_method return_method,
627 CORE_ADDR struct_addr)
628 {
629
630 int argreg;
631 int argnum;
632 int first_stack_arg;
633 int stack_offset = 0;
634 int heap_offset = 0;
635 CORE_ADDR heap_sp = sp - 128;
636 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
637 or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
638 int bpa = tdep->bytes_per_address;
639 int bpw = tdep->bytes_per_word;
640 struct type *func_type = function->type ();
641
642 /* Return address */
643 regcache_cooked_write_unsigned (regcache, OR1K_LR_REGNUM, bp_addr);
644
645 /* Register for the next argument. */
646 argreg = OR1K_FIRST_ARG_REGNUM;
647
648 /* Location for a returned structure. This is passed as a silent first
649 argument. */
650 if (return_method == return_method_struct)
651 {
652 regcache_cooked_write_unsigned (regcache, OR1K_FIRST_ARG_REGNUM,
653 struct_addr);
654 argreg++;
655 }
656
657 /* Put as many args as possible in registers. */
658 for (argnum = 0; argnum < nargs; argnum++)
659 {
660 const gdb_byte *val;
661 gdb_byte valbuf[sizeof (ULONGEST)];
662
663 struct value *arg = args[argnum];
664 struct type *arg_type = check_typedef (arg->type ());
665 int len = arg_type->length ();
666 enum type_code typecode = arg_type->code ();
667
668 if (func_type->has_varargs () && argnum >= func_type->num_fields ())
669 break; /* end or regular args, varargs go to stack. */
670
671 /* Extract the value, either a reference or the data. */
672 if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
673 || (len > bpw * 2))
674 {
675 CORE_ADDR valaddr = arg->address ();
676
677 /* If the arg is fabricated (i.e. 3*i, instead of i) valaddr is
678 undefined. */
679 if (valaddr == 0)
680 {
681 /* The argument needs to be copied into the target space.
682 Since the bottom of the stack is reserved for function
683 arguments we store this at the these at the top growing
684 down. */
685 heap_offset += align_up (len, bpw);
686 valaddr = heap_sp + heap_offset;
687
688 write_memory (valaddr, arg->contents ().data (), len);
689 }
690
691 /* The ABI passes all structures by reference, so get its
692 address. */
693 store_unsigned_integer (valbuf, bpa, byte_order, valaddr);
694 len = bpa;
695 val = valbuf;
696 }
697 else
698 {
699 /* Everything else, we just get the value. */
700 val = arg->contents ().data ();
701 }
702
703 /* Stick the value in a register. */
704 if (len > bpw)
705 {
706 /* Big scalars use two registers, but need NOT be pair aligned. */
707
708 if (argreg <= (OR1K_LAST_ARG_REGNUM - 1))
709 {
710 ULONGEST regval = extract_unsigned_integer (val, len,
711 byte_order);
712
713 unsigned int bits_per_word = bpw * 8;
714 ULONGEST mask = (((ULONGEST) 1) << bits_per_word) - 1;
715 ULONGEST lo = regval & mask;
716 ULONGEST hi = regval >> bits_per_word;
717
718 regcache_cooked_write_unsigned (regcache, argreg, hi);
719 regcache_cooked_write_unsigned (regcache, argreg + 1, lo);
720 argreg += 2;
721 }
722 else
723 {
724 /* Run out of regs */
725 break;
726 }
727 }
728 else if (argreg <= OR1K_LAST_ARG_REGNUM)
729 {
730 /* Smaller scalars fit in a single register. */
731 regcache_cooked_write_unsigned
732 (regcache, argreg, extract_unsigned_integer (val, len,
733 byte_order));
734 argreg++;
735 }
736 else
737 {
738 /* Ran out of regs. */
739 break;
740 }
741 }
742
743 first_stack_arg = argnum;
744
745 /* If we get here with argnum < nargs, then arguments remain to be
746 placed on the stack. This is tricky, since they must be pushed in
747 reverse order and the stack in the end must be aligned. The only
748 solution is to do it in two stages, the first to compute the stack
749 size, the second to save the args. */
750
751 for (argnum = first_stack_arg; argnum < nargs; argnum++)
752 {
753 struct value *arg = args[argnum];
754 struct type *arg_type = check_typedef (arg->type ());
755 int len = arg_type->length ();
756 enum type_code typecode = arg_type->code ();
757
758 if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
759 || (len > bpw * 2))
760 {
761 /* Structures are passed as addresses. */
762 sp -= bpa;
763 }
764 else
765 {
766 /* Big scalars use more than one word. Code here allows for
767 future quad-word entities (e.g. long double.) */
768 sp -= align_up (len, bpw);
769 }
770
771 /* Ensure our dummy heap doesn't touch the stack, this could only
772 happen if we have many arguments including fabricated arguments. */
773 gdb_assert (heap_offset == 0 || ((heap_sp + heap_offset) < sp));
774 }
775
776 sp = gdbarch_frame_align (gdbarch, sp);
777 stack_offset = 0;
778
779 /* Push the remaining args on the stack. */
780 for (argnum = first_stack_arg; argnum < nargs; argnum++)
781 {
782 const gdb_byte *val;
783 gdb_byte valbuf[sizeof (ULONGEST)];
784
785 struct value *arg = args[argnum];
786 struct type *arg_type = check_typedef (arg->type ());
787 int len = arg_type->length ();
788 enum type_code typecode = arg_type->code ();
789 /* The EABI passes structures that do not fit in a register by
790 reference. In all other cases, pass the structure by value. */
791 if ((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)
792 || (len > bpw * 2))
793 {
794 store_unsigned_integer (valbuf, bpa, byte_order,
795 arg->address ());
796 len = bpa;
797 val = valbuf;
798 }
799 else
800 val = arg->contents ().data ();
801
802 while (len > 0)
803 {
804 int partial_len = (len < bpw ? len : bpw);
805
806 write_memory (sp + stack_offset, val, partial_len);
807 stack_offset += align_up (partial_len, bpw);
808 len -= partial_len;
809 val += partial_len;
810 }
811 }
812
813 /* Save the updated stack pointer. */
814 regcache_cooked_write_unsigned (regcache, OR1K_SP_REGNUM, sp);
815
816 if (heap_offset > 0)
817 sp = heap_sp;
818
819 return sp;
820 }
821
822 \f
823
824 /* Support functions for frame handling. */
825
826 /* Initialize a prologue cache
827
828 We build a cache, saying where registers of the prev frame can be found
829 from the data so far set up in this this.
830
831 We also compute a unique ID for this frame, based on the function start
832 address and the stack pointer (as it will be, even if it has yet to be
833 computed.
834
835 STACK FORMAT
836 ============
837
838 The OR1K has a falling stack frame and a simple prolog. The Stack
839 pointer is R1 and the frame pointer R2. The frame base is therefore the
840 address held in R2 and the stack pointer (R1) is the frame base of the
841 next frame.
842
843 l.addi r1,r1,-frame_size # SP now points to end of new stack frame
844
845 The stack pointer may not be set up in a frameless function (e.g. a
846 simple leaf function).
847
848 l.sw fp_loc(r1),r2 # old FP saved in new stack frame
849 l.addi r2,r1,frame_size # FP now points to base of new stack frame
850
851 The frame pointer is not necessarily saved right at the end of the stack
852 frame - OR1K saves enough space for any args to called functions right
853 at the end (this is a difference from the Architecture Manual).
854
855 l.sw lr_loc(r1),r9 # Link (return) address
856
857 The link register is usually saved at fp_loc - 4. It may not be saved at
858 all in a leaf function.
859
860 l.sw reg_loc(r1),ry # Save any callee saved regs
861
862 The offsets x for the callee saved registers generally (always?) rise in
863 increments of 4, starting at fp_loc + 4. If the frame pointer is
864 omitted (an option to GCC), then it may not be saved at all. There may
865 be no callee saved registers.
866
867 So in summary none of this may be present. However what is present
868 seems always to follow this fixed order, and occur before any
869 substantive code (it is possible for GCC to have more flexible
870 scheduling of the prologue, but this does not seem to occur for OR1K).
871
872 ANALYSIS
873 ========
874
875 This prolog is used, even for -O3 with GCC.
876
877 All this analysis must allow for the possibility that the PC is in the
878 middle of the prologue. Data in the cache should only be set up insofar
879 as it has been computed.
880
881 HOWEVER. The frame_id must be created with the SP *as it will be* at
882 the end of the Prologue. Otherwise a recursive call, checking the frame
883 with the PC at the start address will end up with the same frame_id as
884 the caller.
885
886 A suite of "helper" routines are used, allowing reuse for
887 or1k_skip_prologue().
888
889 Reportedly, this is only valid for frames less than 0x7fff in size. */
890
891 static struct trad_frame_cache *
892 or1k_frame_cache (const frame_info_ptr &this_frame, void **prologue_cache)
893 {
894 struct gdbarch *gdbarch;
895 struct trad_frame_cache *info;
896
897 CORE_ADDR this_pc;
898 CORE_ADDR this_sp;
899 CORE_ADDR this_sp_for_id;
900 int frame_size = 0;
901
902 CORE_ADDR start_addr;
903 CORE_ADDR end_addr;
904
905 if (or1k_debug)
906 gdb_printf (gdb_stdlog,
907 "or1k_frame_cache, prologue_cache = %s\n",
908 host_address_to_string (*prologue_cache));
909
910 /* Nothing to do if we already have this info. */
911 if (NULL != *prologue_cache)
912 return (struct trad_frame_cache *) *prologue_cache;
913
914 /* Get a new prologue cache and populate it with default values. */
915 info = trad_frame_cache_zalloc (this_frame);
916 *prologue_cache = info;
917
918 /* Find the start address of this function (which is a normal frame, even
919 if the next frame is the sentinel frame) and the end of its prologue. */
920 this_pc = get_frame_pc (this_frame);
921 find_pc_partial_function (this_pc, NULL, &start_addr, NULL);
922
923 /* Get the stack pointer if we have one (if there's no process executing
924 yet we won't have a frame. */
925 this_sp = (NULL == this_frame) ? 0 :
926 get_frame_register_unsigned (this_frame, OR1K_SP_REGNUM);
927
928 /* Return early if GDB couldn't find the function. */
929 if (start_addr == 0)
930 {
931 if (or1k_debug)
932 gdb_printf (gdb_stdlog, " couldn't find function\n");
933
934 /* JPB: 28-Apr-11. This is a temporary patch, to get round GDB
935 crashing right at the beginning. Build the frame ID as best we
936 can. */
937 trad_frame_set_id (info, frame_id_build (this_sp, this_pc));
938
939 return info;
940 }
941
942 /* The default frame base of this frame (for ID purposes only - frame
943 base is an overloaded term) is its stack pointer. For now we use the
944 value of the SP register in this frame. However if the PC is in the
945 prologue of this frame, before the SP has been set up, then the value
946 will actually be that of the prev frame, and we'll need to adjust it
947 later. */
948 trad_frame_set_this_base (info, this_sp);
949 this_sp_for_id = this_sp;
950
951 /* The default is to find the PC of the previous frame in the link
952 register of this frame. This may be changed if we find the link
953 register was saved on the stack. */
954 trad_frame_set_reg_realreg (info, OR1K_NPC_REGNUM, OR1K_LR_REGNUM);
955
956 /* We should only examine code that is in the prologue. This is all code
957 up to (but not including) end_addr. We should only populate the cache
958 while the address is up to (but not including) the PC or end_addr,
959 whichever is first. */
960 gdbarch = get_frame_arch (this_frame);
961 end_addr = or1k_skip_prologue (gdbarch, start_addr);
962
963 /* All the following analysis only occurs if we are in the prologue and
964 have executed the code. Check we have a sane prologue size, and if
965 zero we are frameless and can give up here. */
966 if (end_addr < start_addr)
967 error (_("end addr %s is less than start addr %s"),
968 paddress (gdbarch, end_addr), paddress (gdbarch, start_addr));
969
970 if (end_addr == start_addr)
971 frame_size = 0;
972 else
973 {
974 /* We have a frame. Look for the various components. */
975 CORE_ADDR addr = start_addr; /* Where we have got to */
976 uint32_t inst = or1k_fetch_instruction (gdbarch, addr);
977
978 unsigned int ra, rb, rd; /* for instruction analysis */
979 int simm;
980
981 /* Look for the new stack pointer being set up. */
982 if (or1k_analyse_l_addi (inst, &rd, &ra, &simm)
983 && (OR1K_SP_REGNUM == rd) && (OR1K_SP_REGNUM == ra)
984 && (simm < 0) && (0 == (simm % 4)))
985 {
986 frame_size = -simm;
987 addr += OR1K_INSTLEN;
988 inst = or1k_fetch_instruction (gdbarch, addr);
989
990 /* If the PC has not actually got to this point, then the frame
991 base will be wrong, and we adjust it.
992
993 If we are past this point, then we need to populate the stack
994 accordingly. */
995 if (this_pc <= addr)
996 {
997 /* Only do if executing. */
998 if (0 != this_sp)
999 {
1000 this_sp_for_id = this_sp + frame_size;
1001 trad_frame_set_this_base (info, this_sp_for_id);
1002 }
1003 }
1004 else
1005 {
1006 /* We are past this point, so the stack pointer of the prev
1007 frame is frame_size greater than the stack pointer of this
1008 frame. */
1009 trad_frame_set_reg_value (info, OR1K_SP_REGNUM,
1010 this_sp + frame_size);
1011 }
1012 }
1013
1014 /* From now on we are only populating the cache, so we stop once we
1015 get to either the end OR the current PC. */
1016 end_addr = (this_pc < end_addr) ? this_pc : end_addr;
1017
1018 /* Look for the frame pointer being manipulated. */
1019 if ((addr < end_addr)
1020 && or1k_analyse_l_sw (inst, &simm, &ra, &rb)
1021 && (OR1K_SP_REGNUM == ra) && (OR1K_FP_REGNUM == rb)
1022 && (simm >= 0) && (0 == (simm % 4)))
1023 {
1024 addr += OR1K_INSTLEN;
1025 inst = or1k_fetch_instruction (gdbarch, addr);
1026
1027 /* At this stage, we can find the frame pointer of the previous
1028 frame on the stack of the current frame. */
1029 trad_frame_set_reg_addr (info, OR1K_FP_REGNUM, this_sp + simm);
1030
1031 /* Look for the new frame pointer being set up. */
1032 if ((addr < end_addr)
1033 && or1k_analyse_l_addi (inst, &rd, &ra, &simm)
1034 && (OR1K_FP_REGNUM == rd) && (OR1K_SP_REGNUM == ra)
1035 && (simm == frame_size))
1036 {
1037 addr += OR1K_INSTLEN;
1038 inst = or1k_fetch_instruction (gdbarch, addr);
1039
1040 /* If we have got this far, the stack pointer of the previous
1041 frame is the frame pointer of this frame. */
1042 trad_frame_set_reg_realreg (info, OR1K_SP_REGNUM,
1043 OR1K_FP_REGNUM);
1044 }
1045 }
1046
1047 /* Look for the link register being saved. */
1048 if ((addr < end_addr)
1049 && or1k_analyse_l_sw (inst, &simm, &ra, &rb)
1050 && (OR1K_SP_REGNUM == ra) && (OR1K_LR_REGNUM == rb)
1051 && (simm >= 0) && (0 == (simm % 4)))
1052 {
1053 addr += OR1K_INSTLEN;
1054 inst = or1k_fetch_instruction (gdbarch, addr);
1055
1056 /* If the link register is saved in the this frame, it holds the
1057 value of the PC in the previous frame. This overwrites the
1058 previous information about finding the PC in the link
1059 register. */
1060 trad_frame_set_reg_addr (info, OR1K_NPC_REGNUM, this_sp + simm);
1061 }
1062
1063 /* Look for arguments or callee-saved register being saved. The
1064 register must be one of the arguments (r3-r8) or the 10 callee
1065 saved registers (r10, r12, r14, r16, r18, r20, r22, r24, r26, r28,
1066 r30). The base register must be the FP (for the args) or the SP
1067 (for the callee_saved registers). */
1068 while (addr < end_addr)
1069 {
1070 if (or1k_analyse_l_sw (inst, &simm, &ra, &rb)
1071 && (((OR1K_FP_REGNUM == ra) && or1k_is_arg_reg (rb))
1072 || ((OR1K_SP_REGNUM == ra)
1073 && or1k_is_callee_saved_reg (rb)))
1074 && (0 == (simm % 4)))
1075 {
1076 addr += OR1K_INSTLEN;
1077 inst = or1k_fetch_instruction (gdbarch, addr);
1078
1079 /* The register in the previous frame can be found at this
1080 location in this frame. */
1081 trad_frame_set_reg_addr (info, rb, this_sp + simm);
1082 }
1083 else
1084 break; /* Not a register save instruction. */
1085 }
1086 }
1087
1088 /* Build the frame ID */
1089 trad_frame_set_id (info, frame_id_build (this_sp_for_id, start_addr));
1090
1091 if (or1k_debug)
1092 {
1093 gdb_printf (gdb_stdlog, " this_sp_for_id = %s\n",
1094 paddress (gdbarch, this_sp_for_id));
1095 gdb_printf (gdb_stdlog, " start_addr = %s\n",
1096 paddress (gdbarch, start_addr));
1097 }
1098
1099 return info;
1100 }
1101
1102 /* Implement the this_id function for the stub unwinder. */
1103
1104 static void
1105 or1k_frame_this_id (const frame_info_ptr &this_frame,
1106 void **prologue_cache, struct frame_id *this_id)
1107 {
1108 struct trad_frame_cache *info = or1k_frame_cache (this_frame,
1109 prologue_cache);
1110
1111 trad_frame_get_id (info, this_id);
1112 }
1113
1114 /* Implement the prev_register function for the stub unwinder. */
1115
1116 static struct value *
1117 or1k_frame_prev_register (const frame_info_ptr &this_frame,
1118 void **prologue_cache, int regnum)
1119 {
1120 struct trad_frame_cache *info = or1k_frame_cache (this_frame,
1121 prologue_cache);
1122
1123 return trad_frame_get_register (info, this_frame, regnum);
1124 }
1125
1126 /* Data structures for the normal prologue-analysis-based unwinder. */
1127
1128 static const struct frame_unwind or1k_frame_unwind = {
1129 "or1k prologue",
1130 NORMAL_FRAME,
1131 default_frame_unwind_stop_reason,
1132 or1k_frame_this_id,
1133 or1k_frame_prev_register,
1134 NULL,
1135 default_frame_sniffer,
1136 NULL,
1137 };
1138
1139 /* Architecture initialization for OpenRISC 1000. */
1140
1141 static struct gdbarch *
1142 or1k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1143 {
1144 const struct bfd_arch_info *binfo;
1145 tdesc_arch_data_up tdesc_data;
1146 const struct target_desc *tdesc = info.target_desc;
1147
1148 /* Find a candidate among the list of pre-declared architectures. */
1149 arches = gdbarch_list_lookup_by_info (arches, &info);
1150 if (NULL != arches)
1151 return arches->gdbarch;
1152
1153 /* None found, create a new architecture from the information
1154 provided. Can't initialize all the target dependencies until we
1155 actually know which target we are talking to, but put in some defaults
1156 for now. */
1157 binfo = info.bfd_arch_info;
1158 gdbarch *gdbarch
1159 = gdbarch_alloc (&info, gdbarch_tdep_up (new or1k_gdbarch_tdep));
1160 or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
1161
1162 tdep->bytes_per_word = binfo->bits_per_word / binfo->bits_per_byte;
1163 tdep->bytes_per_address = binfo->bits_per_address / binfo->bits_per_byte;
1164
1165 /* Target data types */
1166 set_gdbarch_short_bit (gdbarch, 16);
1167 set_gdbarch_int_bit (gdbarch, 32);
1168 set_gdbarch_long_bit (gdbarch, 32);
1169 set_gdbarch_long_long_bit (gdbarch, 64);
1170 set_gdbarch_float_bit (gdbarch, 32);
1171 set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
1172 set_gdbarch_double_bit (gdbarch, 64);
1173 set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
1174 set_gdbarch_long_double_bit (gdbarch, 64);
1175 set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
1176 set_gdbarch_ptr_bit (gdbarch, binfo->bits_per_address);
1177 set_gdbarch_addr_bit (gdbarch, binfo->bits_per_address);
1178 set_gdbarch_char_signed (gdbarch, 1);
1179
1180 /* Information about the target architecture */
1181 set_gdbarch_return_value (gdbarch, or1k_return_value);
1182 set_gdbarch_breakpoint_kind_from_pc (gdbarch,
1183 or1k_breakpoint::kind_from_pc);
1184 set_gdbarch_sw_breakpoint_from_kind (gdbarch,
1185 or1k_breakpoint::bp_from_kind);
1186 set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
1187
1188 /* Register architecture */
1189 set_gdbarch_num_regs (gdbarch, OR1K_NUM_REGS);
1190 set_gdbarch_num_pseudo_regs (gdbarch, OR1K_NUM_PSEUDO_REGS);
1191 set_gdbarch_sp_regnum (gdbarch, OR1K_SP_REGNUM);
1192 set_gdbarch_pc_regnum (gdbarch, OR1K_NPC_REGNUM);
1193 set_gdbarch_ps_regnum (gdbarch, OR1K_SR_REGNUM);
1194 set_gdbarch_deprecated_fp_regnum (gdbarch, OR1K_FP_REGNUM);
1195
1196 /* Functions to analyse frames */
1197 set_gdbarch_skip_prologue (gdbarch, or1k_skip_prologue);
1198 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1199 set_gdbarch_frame_align (gdbarch, or1k_frame_align);
1200 set_gdbarch_frame_red_zone_size (gdbarch, OR1K_FRAME_RED_ZONE_SIZE);
1201
1202 /* Functions to access frame data */
1203 set_gdbarch_unwind_pc (gdbarch, or1k_unwind_pc);
1204 set_gdbarch_unwind_sp (gdbarch, or1k_unwind_sp);
1205
1206 /* Functions handling dummy frames */
1207 set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
1208 set_gdbarch_push_dummy_code (gdbarch, or1k_push_dummy_code);
1209 set_gdbarch_push_dummy_call (gdbarch, or1k_push_dummy_call);
1210
1211 /* Frame unwinders. Use DWARF debug info if available, otherwise use our
1212 own unwinder. */
1213 dwarf2_append_unwinders (gdbarch);
1214 frame_unwind_append_unwinder (gdbarch, &or1k_frame_unwind);
1215
1216 /* Get a CGEN CPU descriptor for this architecture. */
1217 {
1218
1219 const char *mach_name = binfo->printable_name;
1220 enum cgen_endian endian = (info.byte_order == BFD_ENDIAN_BIG
1221 ? CGEN_ENDIAN_BIG : CGEN_ENDIAN_LITTLE);
1222
1223 tdep->gdb_cgen_cpu_desc =
1224 or1k_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name,
1225 CGEN_CPU_OPEN_ENDIAN, endian, CGEN_CPU_OPEN_END);
1226
1227 or1k_cgen_init_asm (tdep->gdb_cgen_cpu_desc);
1228 }
1229
1230 /* If this mach has a delay slot. */
1231 if (binfo->mach == bfd_mach_or1k)
1232 set_gdbarch_single_step_through_delay (gdbarch,
1233 or1k_single_step_through_delay);
1234
1235 if (!tdesc_has_registers (info.target_desc))
1236 /* Pick a default target description. */
1237 tdesc = tdesc_or1k;
1238
1239 /* Check any target description for validity. */
1240 if (tdesc_has_registers (tdesc))
1241 {
1242 const struct tdesc_feature *feature;
1243 int valid_p;
1244 int i;
1245
1246 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.or1k.group0");
1247 if (feature == NULL)
1248 return NULL;
1249
1250 tdesc_data = tdesc_data_alloc ();
1251
1252 valid_p = 1;
1253
1254 for (i = 0; i < OR1K_NUM_REGS; i++)
1255 valid_p &= tdesc_numbered_register (feature, tdesc_data.get (), i,
1256 or1k_reg_names[i]);
1257
1258 if (!valid_p)
1259 return NULL;
1260 }
1261
1262 if (tdesc_data != NULL)
1263 tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
1264
1265 /* Hook in ABI-specific overrides, if they have been registered. */
1266 gdbarch_init_osabi (info, gdbarch);
1267
1268 return gdbarch;
1269 }
1270
1271 /* Dump the target specific data for this architecture. */
1272
1273 static void
1274 or1k_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
1275 {
1276 or1k_gdbarch_tdep *tdep = gdbarch_tdep<or1k_gdbarch_tdep> (gdbarch);
1277
1278 if (NULL == tdep)
1279 return; /* Nothing to report */
1280
1281 gdb_printf (file, "or1k_dump_tdep: %d bytes per word\n",
1282 tdep->bytes_per_word);
1283 gdb_printf (file, "or1k_dump_tdep: %d bytes per address\n",
1284 tdep->bytes_per_address);
1285 }
1286 \f
1287
1288 void _initialize_or1k_tdep ();
1289 void
1290 _initialize_or1k_tdep ()
1291 {
1292 /* Register this architecture. */
1293 gdbarch_register (bfd_arch_or1k, or1k_gdbarch_init, or1k_dump_tdep);
1294
1295 initialize_tdesc_or1k ();
1296
1297 /* Debugging flag. */
1298 add_setshow_boolean_cmd ("or1k", class_maintenance, &or1k_debug,
1299 _("Set OpenRISC debugging."),
1300 _("Show OpenRISC debugging."),
1301 _("When on, OpenRISC specific debugging is enabled."),
1302 NULL,
1303 show_or1k_debug,
1304 &setdebuglist, &showdebuglist);
1305 }