1 /* Target dependent code for GNU/Linux ARC.
3 Copyright 2020-2021 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* GDB header files. */
22 #include "linux-tdep.h"
24 #include "opcode/arc.h"
26 #include "solib-svr4.h"
28 /* ARC header files. */
29 #include "opcodes/arc-dis.h"
30 #include "arc-linux-tdep.h"
34 /* Print an "arc-linux" debug statement. */
36 #define arc_linux_debug_printf(fmt, ...) \
37 debug_prefixed_printf_cond (arc_debug, "arc-linux", fmt, ##__VA_ARGS__)
39 #define REGOFF(offset) (offset * ARC_REGISTER_SIZE)
41 /* arc_linux_sc_reg_offsets[i] is the offset of register i in the `struct
42 sigcontext'. Array index is an internal GDB register number, as defined in
43 arc-tdep.h:arc_regnum.
45 From <include/uapi/asm/sigcontext.h> and <include/uapi/asm/ptrace.h>.
47 The layout of this struct is tightly bound to "arc_regnum" enum
48 in arc-tdep.h. Any change of order in there, must be reflected
50 static const int arc_linux_sc_reg_offsets
[] = {
52 REGOFF (22), REGOFF (21), REGOFF (20), REGOFF (19),
53 REGOFF (18), REGOFF (17), REGOFF (16), REGOFF (15),
54 REGOFF (14), REGOFF (13), REGOFF (12), REGOFF (11),
58 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
59 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
60 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
61 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
62 ARC_OFFSET_NO_REGISTER
,
64 REGOFF (9), /* R26 (GP) */
67 ARC_OFFSET_NO_REGISTER
, /* ILINK */
68 ARC_OFFSET_NO_REGISTER
, /* R30 */
69 REGOFF (7), /* BLINK */
72 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
73 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
74 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
75 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
76 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
77 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
78 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
79 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
80 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
81 ARC_OFFSET_NO_REGISTER
,
83 REGOFF (4), /* LP_COUNT */
84 ARC_OFFSET_NO_REGISTER
, /* RESERVED */
85 ARC_OFFSET_NO_REGISTER
, /* LIMM */
86 ARC_OFFSET_NO_REGISTER
, /* PCL */
89 REGOFF (5), /* STATUS32 */
90 REGOFF (2), /* LP_START */
91 REGOFF (3), /* LP_END */
95 /* arc_linux_core_reg_offsets[i] is the offset in the .reg section of GDB
96 regnum i. Array index is an internal GDB register number, as defined in
97 arc-tdep.h:arc_regnum.
99 From include/uapi/asm/ptrace.h in the ARC Linux sources. */
101 /* The layout of this struct is tightly bound to "arc_regnum" enum
102 in arc-tdep.h. Any change of order in there, must be reflected
104 static const int arc_linux_core_reg_offsets
[] = {
106 REGOFF (22), REGOFF (21), REGOFF (20), REGOFF (19),
107 REGOFF (18), REGOFF (17), REGOFF (16), REGOFF (15),
108 REGOFF (14), REGOFF (13), REGOFF (12), REGOFF (11),
112 REGOFF (37), REGOFF (36), REGOFF (35), REGOFF (34),
113 REGOFF (33), REGOFF (32), REGOFF (31), REGOFF (30),
114 REGOFF (29), REGOFF (28), REGOFF (27), REGOFF (26),
117 REGOFF (9), /* R26 (GP) */
119 REGOFF (23), /* SP */
120 ARC_OFFSET_NO_REGISTER
, /* ILINK */
121 ARC_OFFSET_NO_REGISTER
, /* R30 */
122 REGOFF (7), /* BLINK */
125 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
126 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
127 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
128 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
129 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
130 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
131 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
132 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
133 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
134 ARC_OFFSET_NO_REGISTER
,
136 REGOFF (4), /* LP_COUNT */
137 ARC_OFFSET_NO_REGISTER
, /* RESERVED */
138 ARC_OFFSET_NO_REGISTER
, /* LIMM */
139 ARC_OFFSET_NO_REGISTER
, /* PCL */
141 REGOFF (39), /* PC */
142 REGOFF (5), /* STATUS32 */
143 REGOFF (2), /* LP_START */
144 REGOFF (3), /* LP_END */
145 REGOFF (1), /* BTA */
146 REGOFF (6) /* ERET */
149 /* Is THIS_FRAME a sigtramp function - the function that returns from
150 signal handler into normal execution flow? This is the case if the PC is
151 either at the start of, or in the middle of the two instructions:
153 mov r8, __NR_rt_sigreturn ; __NR_rt_sigreturn == 139
154 trap_s 0 ; `swi' for ARC700
156 On ARC uClibc Linux this function is called __default_rt_sa_restorer.
158 Returns TRUE if this is a sigtramp frame. */
161 arc_linux_is_sigtramp (struct frame_info
*this_frame
)
163 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
164 CORE_ADDR pc
= get_frame_pc (this_frame
);
166 arc_linux_debug_printf ("pc=%s", paddress(gdbarch
, pc
));
168 static const gdb_byte insns_be_hs
[] = {
169 0x20, 0x8a, 0x12, 0xc2, /* mov r8,nr_rt_sigreturn */
170 0x78, 0x1e /* trap_s 0 */
172 static const gdb_byte insns_be_700
[] = {
173 0x20, 0x8a, 0x12, 0xc2, /* mov r8,nr_rt_sigreturn */
174 0x22, 0x6f, 0x00, 0x3f /* swi */
177 gdb_byte arc_sigtramp_insns
[sizeof (insns_be_700
)];
179 if (arc_mach_is_arcv2 (gdbarch
))
181 insns_sz
= sizeof (insns_be_hs
);
182 memcpy (arc_sigtramp_insns
, insns_be_hs
, insns_sz
);
186 insns_sz
= sizeof (insns_be_700
);
187 memcpy (arc_sigtramp_insns
, insns_be_700
, insns_sz
);
189 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_LITTLE
)
191 /* On little endian targets, ARC code section is in what is called
192 "middle endian", where half-words are in the big-endian order,
193 only bytes inside the halfwords are in the little endian order.
194 As a result it is very easy to convert big endian instruction to
195 little endian, since it is needed to swap bytes in the halfwords,
196 so there is no need to have information on whether that is a
197 4-byte instruction or 2-byte. */
198 gdb_assert ((insns_sz
% 2) == 0);
199 for (int i
= 0; i
< insns_sz
; i
+= 2)
200 std::swap (arc_sigtramp_insns
[i
], arc_sigtramp_insns
[i
+1]);
203 gdb_byte buf
[insns_sz
];
205 /* Read the memory at the PC. Since we are stopped, any breakpoint must
206 have been removed. */
207 if (!safe_frame_unwind_memory (this_frame
, pc
, {buf
, insns_sz
}))
209 /* Failed to unwind frame. */
213 /* Is that code the sigtramp instruction sequence? */
214 if (memcmp (buf
, arc_sigtramp_insns
, insns_sz
) == 0)
217 /* No - look one instruction earlier in the code... */
218 if (!safe_frame_unwind_memory (this_frame
, pc
- 4, {buf
, insns_sz
}))
220 /* Failed to unwind frame. */
224 return (memcmp (buf
, arc_sigtramp_insns
, insns_sz
) == 0);
227 /* Get sigcontext structure of sigtramp frame - it contains saved
228 registers of interrupted frame.
230 Stack pointer points to the rt_sigframe structure, and sigcontext can
240 unsigned long uc_flags;
241 struct ucontext *uc_link;
243 struct sigcontext uc_mcontext;
247 sizeof (struct siginfo) == 0x80
248 offsetof (struct ucontext, uc_mcontext) == 0x14
250 GDB cannot include linux headers and use offsetof () because those are
251 target headers and GDB might be built for a different run host. There
252 doesn't seem to be an established mechanism to figure out those offsets
253 via gdbserver, so the only way is to hardcode values in the GDB,
254 meaning that GDB will be broken if values will change. That seems to
255 be a very unlikely scenario and other arches (aarch64, alpha, amd64,
256 etc) in GDB hardcode values. */
259 arc_linux_sigcontext_addr (struct frame_info
*this_frame
)
261 const int ucontext_offset
= 0x80;
262 const int sigcontext_offset
= 0x14;
263 return get_frame_sp (this_frame
) + ucontext_offset
+ sigcontext_offset
;
266 /* Implement the "cannot_fetch_register" gdbarch method. */
269 arc_linux_cannot_fetch_register (struct gdbarch
*gdbarch
, int regnum
)
271 /* Assume that register is readable if it is unknown. */
274 case ARC_ILINK_REGNUM
:
275 case ARC_RESERVED_REGNUM
:
276 case ARC_LIMM_REGNUM
:
281 return !arc_mach_is_arcv2 (gdbarch
);
283 return (regnum
> ARC_BLINK_REGNUM
) && (regnum
< ARC_LP_COUNT_REGNUM
);
286 /* Implement the "cannot_store_register" gdbarch method. */
289 arc_linux_cannot_store_register (struct gdbarch
*gdbarch
, int regnum
)
291 /* Assume that register is writable if it is unknown. */
294 case ARC_ILINK_REGNUM
:
295 case ARC_RESERVED_REGNUM
:
296 case ARC_LIMM_REGNUM
:
302 return !arc_mach_is_arcv2 (gdbarch
);
304 return (regnum
> ARC_BLINK_REGNUM
) && (regnum
< ARC_LP_COUNT_REGNUM
);
307 /* For ARC Linux, breakpoints use the 16-bit TRAP_S 1 instruction, which
308 is 0x3e78 (little endian) or 0x783e (big endian). */
310 static const gdb_byte arc_linux_trap_s_be
[] = { 0x78, 0x3e };
311 static const gdb_byte arc_linux_trap_s_le
[] = { 0x3e, 0x78 };
312 static const int trap_size
= 2; /* Number of bytes to insert "trap". */
314 /* Implement the "breakpoint_kind_from_pc" gdbarch method. */
317 arc_linux_breakpoint_kind_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
)
322 /* Implement the "sw_breakpoint_from_kind" gdbarch method. */
324 static const gdb_byte
*
325 arc_linux_sw_breakpoint_from_kind (struct gdbarch
*gdbarch
,
328 gdb_assert (kind
== trap_size
);
330 return ((gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
331 ? arc_linux_trap_s_be
332 : arc_linux_trap_s_le
);
335 /* Implement the "software_single_step" gdbarch method. */
337 static std::vector
<CORE_ADDR
>
338 arc_linux_software_single_step (struct regcache
*regcache
)
340 struct gdbarch
*gdbarch
= regcache
->arch ();
341 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
342 struct disassemble_info di
= arc_disassemble_info (gdbarch
);
344 /* Read current instruction. */
345 struct arc_instruction curr_insn
;
346 arc_insn_decode (regcache_read_pc (regcache
), &di
, arc_delayed_print_insn
,
348 CORE_ADDR next_pc
= arc_insn_get_linear_next_pc (curr_insn
);
350 std::vector
<CORE_ADDR
> next_pcs
;
352 /* For instructions with delay slots, the fall thru is not the
353 instruction immediately after the current instruction, but the one
355 if (curr_insn
.has_delay_slot
)
357 struct arc_instruction next_insn
;
358 arc_insn_decode (next_pc
, &di
, arc_delayed_print_insn
, &next_insn
);
359 next_pcs
.push_back (arc_insn_get_linear_next_pc (next_insn
));
362 next_pcs
.push_back (next_pc
);
365 regcache_cooked_read_unsigned (regcache
, gdbarch_ps_regnum (gdbarch
),
368 if (curr_insn
.is_control_flow
)
370 CORE_ADDR branch_pc
= arc_insn_get_branch_target (curr_insn
);
371 if (branch_pc
!= next_pc
)
372 next_pcs
.push_back (branch_pc
);
374 /* Is current instruction the last in a loop body? */
375 else if (tdep
->has_hw_loops
)
377 /* If STATUS32.L is 1, then ZD-loops are disabled. */
378 if ((status32
& ARC_STATUS32_L_MASK
) == 0)
380 ULONGEST lp_end
, lp_start
, lp_count
;
381 regcache_cooked_read_unsigned (regcache
, ARC_LP_START_REGNUM
,
383 regcache_cooked_read_unsigned (regcache
, ARC_LP_END_REGNUM
, &lp_end
);
384 regcache_cooked_read_unsigned (regcache
, ARC_LP_COUNT_REGNUM
,
387 arc_linux_debug_printf ("lp_start = %s, lp_end = %s, "
388 "lp_count = %s, next_pc = %s",
389 paddress (gdbarch
, lp_start
),
390 paddress (gdbarch
, lp_end
),
391 pulongest (lp_count
),
392 paddress (gdbarch
, next_pc
));
394 if (next_pc
== lp_end
&& lp_count
> 1)
396 /* The instruction is in effect a jump back to the start of
398 next_pcs
.push_back (lp_start
);
403 /* Is this a delay slot? Then next PC is in BTA register. */
404 if ((status32
& ARC_STATUS32_DE_MASK
) != 0)
407 regcache_cooked_read_unsigned (regcache
, ARC_BTA_REGNUM
, &bta
);
408 next_pcs
.push_back (bta
);
414 /* Implement the "skip_solib_resolver" gdbarch method.
416 See glibc_skip_solib_resolver for details. */
419 arc_linux_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
421 /* For uClibc 0.9.26+.
423 An unresolved PLT entry points to "__dl_linux_resolve", which calls
424 "_dl_linux_resolver" to do the resolving and then eventually jumps to
427 So we look for the symbol `_dl_linux_resolver', and if we are there,
428 gdb sets a breakpoint at the return address, and continues. */
429 struct bound_minimal_symbol resolver
430 = lookup_minimal_symbol ("_dl_linux_resolver", NULL
, NULL
);
434 if (resolver
.minsym
!= nullptr)
436 CORE_ADDR res_addr
= BMSYMBOL_VALUE_ADDRESS (resolver
);
437 arc_linux_debug_printf ("pc = %s, resolver at %s",
438 print_core_address (gdbarch
, pc
),
439 print_core_address (gdbarch
, res_addr
));
442 arc_linux_debug_printf ("pc = %s, no resolver found",
443 print_core_address (gdbarch
, pc
));
446 if (resolver
.minsym
!= nullptr && BMSYMBOL_VALUE_ADDRESS (resolver
) == pc
)
448 /* Find the return address. */
449 return frame_unwind_caller_pc (get_current_frame ());
453 /* No breakpoint required. */
458 /* Populate REGCACHE with register REGNUM from BUF. */
461 supply_register (struct regcache
*regcache
, int regnum
, const gdb_byte
*buf
)
463 /* Skip non-existing registers. */
464 if ((arc_linux_core_reg_offsets
[regnum
] == ARC_OFFSET_NO_REGISTER
))
467 regcache
->raw_supply (regnum
, buf
+ arc_linux_core_reg_offsets
[regnum
]);
471 arc_linux_supply_gregset (const struct regset
*regset
,
472 struct regcache
*regcache
,
473 int regnum
, const void *gregs
, size_t size
)
475 gdb_static_assert (ARC_LAST_REGNUM
476 < ARRAY_SIZE (arc_linux_core_reg_offsets
));
478 const bfd_byte
*buf
= (const bfd_byte
*) gregs
;
480 /* REGNUM == -1 means writing all the registers. */
482 for (int reg
= 0; reg
<= ARC_LAST_REGNUM
; reg
++)
483 supply_register (regcache
, reg
, buf
);
484 else if (regnum
<= ARC_LAST_REGNUM
)
485 supply_register (regcache
, regnum
, buf
);
487 gdb_assert_not_reached ("Invalid regnum in arc_linux_supply_gregset.");
491 arc_linux_supply_v2_regset (const struct regset
*regset
,
492 struct regcache
*regcache
, int regnum
,
493 const void *v2_regs
, size_t size
)
495 const bfd_byte
*buf
= (const bfd_byte
*) v2_regs
;
497 /* user_regs_arcv2 is defined in linux arch/arc/include/uapi/asm/ptrace.h. */
498 if (regnum
== -1 || regnum
== ARC_R30_REGNUM
)
499 regcache
->raw_supply (ARC_R30_REGNUM
, buf
);
500 if (regnum
== -1 || regnum
== ARC_R58_REGNUM
)
501 regcache
->raw_supply (ARC_R58_REGNUM
, buf
+ REGOFF (1));
502 if (regnum
== -1 || regnum
== ARC_R59_REGNUM
)
503 regcache
->raw_supply (ARC_R59_REGNUM
, buf
+ REGOFF (2));
506 /* Populate BUF with register REGNUM from the REGCACHE. */
509 collect_register (const struct regcache
*regcache
, struct gdbarch
*gdbarch
,
510 int regnum
, gdb_byte
*buf
)
514 /* Skip non-existing registers. */
515 if (arc_linux_core_reg_offsets
[regnum
] == ARC_OFFSET_NO_REGISTER
)
518 /* The address where the execution has stopped is in pseudo-register
519 STOP_PC. However, when kernel code is returning from the exception,
520 it uses the value from ERET register. Since, TRAP_S (the breakpoint
521 instruction) commits, the ERET points to the next instruction. In
522 other words: ERET != STOP_PC. To jump back from the kernel code to
523 the correct address, ERET must be overwritten by GDB's STOP_PC. Else,
524 the program will continue at the address after the current instruction.
526 if (regnum
== gdbarch_pc_regnum (gdbarch
))
527 offset
= arc_linux_core_reg_offsets
[ARC_ERET_REGNUM
];
529 offset
= arc_linux_core_reg_offsets
[regnum
];
530 regcache
->raw_collect (regnum
, buf
+ offset
);
534 arc_linux_collect_gregset (const struct regset
*regset
,
535 const struct regcache
*regcache
,
536 int regnum
, void *gregs
, size_t size
)
538 gdb_static_assert (ARC_LAST_REGNUM
539 < ARRAY_SIZE (arc_linux_core_reg_offsets
));
541 gdb_byte
*buf
= (gdb_byte
*) gregs
;
542 struct gdbarch
*gdbarch
= regcache
->arch ();
544 /* REGNUM == -1 means writing all the registers. */
546 for (int reg
= 0; reg
<= ARC_LAST_REGNUM
; reg
++)
547 collect_register (regcache
, gdbarch
, reg
, buf
);
548 else if (regnum
<= ARC_LAST_REGNUM
)
549 collect_register (regcache
, gdbarch
, regnum
, buf
);
551 gdb_assert_not_reached ("Invalid regnum in arc_linux_collect_gregset.");
555 arc_linux_collect_v2_regset (const struct regset
*regset
,
556 const struct regcache
*regcache
, int regnum
,
557 void *v2_regs
, size_t size
)
559 bfd_byte
*buf
= (bfd_byte
*) v2_regs
;
561 if (regnum
== -1 || regnum
== ARC_R30_REGNUM
)
562 regcache
->raw_collect (ARC_R30_REGNUM
, buf
);
563 if (regnum
== -1 || regnum
== ARC_R58_REGNUM
)
564 regcache
->raw_collect (ARC_R58_REGNUM
, buf
+ REGOFF (1));
565 if (regnum
== -1 || regnum
== ARC_R59_REGNUM
)
566 regcache
->raw_collect (ARC_R59_REGNUM
, buf
+ REGOFF (2));
569 /* Linux regset definitions. */
571 static const struct regset arc_linux_gregset
= {
572 arc_linux_core_reg_offsets
,
573 arc_linux_supply_gregset
,
574 arc_linux_collect_gregset
,
577 static const struct regset arc_linux_v2_regset
= {
579 arc_linux_supply_v2_regset
,
580 arc_linux_collect_v2_regset
,
583 /* Implement the `iterate_over_regset_sections` gdbarch method. */
586 arc_linux_iterate_over_regset_sections (struct gdbarch
*gdbarch
,
587 iterate_over_regset_sections_cb
*cb
,
589 const struct regcache
*regcache
)
591 /* There are 40 registers in Linux user_regs_struct, although some of
592 them are now just a mere paddings, kept to maintain binary
593 compatibility with older tools. */
594 const int sizeof_gregset
= 40 * ARC_REGISTER_SIZE
;
596 cb (".reg", sizeof_gregset
, sizeof_gregset
, &arc_linux_gregset
, NULL
,
598 cb (".reg-arc-v2", ARC_LINUX_SIZEOF_V2_REGSET
, ARC_LINUX_SIZEOF_V2_REGSET
,
599 &arc_linux_v2_regset
, NULL
, cb_data
);
602 /* Implement the `core_read_description` gdbarch method. */
604 static const struct target_desc
*
605 arc_linux_core_read_description (struct gdbarch
*gdbarch
,
606 struct target_ops
*target
,
609 arc_arch_features features
610 = arc_arch_features_create (abfd
,
611 gdbarch_bfd_arch_info (gdbarch
)->mach
);
612 return arc_lookup_target_description (features
);
615 /* Initialization specific to Linux environment. */
618 arc_linux_init_osabi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
620 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
622 arc_linux_debug_printf ("GNU/Linux OS/ABI initialization.");
624 /* Fill in target-dependent info in ARC-private structure. */
625 tdep
->is_sigtramp
= arc_linux_is_sigtramp
;
626 tdep
->sigcontext_addr
= arc_linux_sigcontext_addr
;
627 tdep
->sc_reg_offset
= arc_linux_sc_reg_offsets
;
628 tdep
->sc_num_regs
= ARRAY_SIZE (arc_linux_sc_reg_offsets
);
630 /* If we are using Linux, we have in uClibc
631 (libc/sysdeps/linux/arc/bits/setjmp.h):
633 typedef int __jmp_buf[13+1+1+1]; //r13-r25, fp, sp, blink
635 Where "blink" is a stored PC of a caller function.
639 linux_init_abi (info
, gdbarch
, 0);
641 /* Set up target dependent GDB architecture entries. */
642 set_gdbarch_cannot_fetch_register (gdbarch
, arc_linux_cannot_fetch_register
);
643 set_gdbarch_cannot_store_register (gdbarch
, arc_linux_cannot_store_register
);
644 set_gdbarch_breakpoint_kind_from_pc (gdbarch
,
645 arc_linux_breakpoint_kind_from_pc
);
646 set_gdbarch_sw_breakpoint_from_kind (gdbarch
,
647 arc_linux_sw_breakpoint_from_kind
);
648 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
649 svr4_fetch_objfile_link_map
);
650 set_gdbarch_software_single_step (gdbarch
, arc_linux_software_single_step
);
651 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
652 set_gdbarch_skip_solib_resolver (gdbarch
, arc_linux_skip_solib_resolver
);
653 set_gdbarch_iterate_over_regset_sections
654 (gdbarch
, arc_linux_iterate_over_regset_sections
);
655 set_gdbarch_core_read_description (gdbarch
, arc_linux_core_read_description
);
657 /* GNU/Linux uses SVR4-style shared libraries, with 32-bit ints, longs
658 and pointers (ILP32). */
659 set_solib_svr4_fetch_link_map_offsets (gdbarch
,
660 svr4_ilp32_fetch_link_map_offsets
);
663 /* Suppress warning from -Wmissing-prototypes. */
664 extern initialize_file_ftype _initialize_arc_linux_tdep
;
667 _initialize_arc_linux_tdep ()
669 gdbarch_register_osabi (bfd_arch_arc
, 0, GDB_OSABI_LINUX
,
670 arc_linux_init_osabi
);