1 /* Target dependent code for GNU/Linux ARC.
3 Copyright 2020 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 #define REGOFF(offset) (offset * ARC_REGISTER_SIZE)
36 /* arc_linux_sc_reg_offsets[i] is the offset of register i in the `struct
37 sigcontext'. Array index is an internal GDB register number, as defined in
38 arc-tdep.h:arc_regnum.
40 From <include/uapi/asm/sigcontext.h> and <include/uapi/asm/ptrace.h>.
42 The layout of this struct is tightly bound to "arc_regnum" enum
43 in arc-tdep.h. Any change of order in there, must be reflected
45 static const int arc_linux_sc_reg_offsets
[] = {
47 REGOFF (22), REGOFF (21), REGOFF (20), REGOFF (19),
48 REGOFF (18), REGOFF (17), REGOFF (16), REGOFF (15),
49 REGOFF (14), REGOFF (13), REGOFF (12), REGOFF (11),
53 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
54 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
55 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
56 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
57 ARC_OFFSET_NO_REGISTER
,
59 REGOFF (9), /* R26 (GP) */
62 ARC_OFFSET_NO_REGISTER
, /* ILINK */
63 ARC_OFFSET_NO_REGISTER
, /* R30 */
64 REGOFF (7), /* BLINK */
67 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
68 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
69 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
70 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
71 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
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
,
78 REGOFF (4), /* LP_COUNT */
79 ARC_OFFSET_NO_REGISTER
, /* RESERVED */
80 ARC_OFFSET_NO_REGISTER
, /* LIMM */
81 ARC_OFFSET_NO_REGISTER
, /* PCL */
84 REGOFF (5), /* STATUS32 */
85 REGOFF (2), /* LP_START */
86 REGOFF (3), /* LP_END */
90 /* arc_linux_core_reg_offsets[i] is the offset in the .reg section of GDB
91 regnum i. Array index is an internal GDB register number, as defined in
92 arc-tdep.h:arc_regnum.
94 From include/uapi/asm/ptrace.h in the ARC Linux sources. */
96 /* The layout of this struct is tightly bound to "arc_regnum" enum
97 in arc-tdep.h. Any change of order in there, must be reflected
99 static const int arc_linux_core_reg_offsets
[] = {
101 REGOFF (22), REGOFF (21), REGOFF (20), REGOFF (19),
102 REGOFF (18), REGOFF (17), REGOFF (16), REGOFF (15),
103 REGOFF (14), REGOFF (13), REGOFF (12), REGOFF (11),
107 REGOFF (37), REGOFF (36), REGOFF (35), REGOFF (34),
108 REGOFF (33), REGOFF (32), REGOFF (31), REGOFF (30),
109 REGOFF (29), REGOFF (28), REGOFF (27), REGOFF (26),
112 REGOFF (9), /* R26 (GP) */
114 REGOFF (23), /* SP */
115 ARC_OFFSET_NO_REGISTER
, /* ILINK */
116 ARC_OFFSET_NO_REGISTER
, /* R30 */
117 REGOFF (7), /* BLINK */
120 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
121 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
122 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
123 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
124 ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
, ARC_OFFSET_NO_REGISTER
,
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
,
131 REGOFF (4), /* LP_COUNT */
132 ARC_OFFSET_NO_REGISTER
, /* RESERVED */
133 ARC_OFFSET_NO_REGISTER
, /* LIMM */
134 ARC_OFFSET_NO_REGISTER
, /* PCL */
136 REGOFF (39), /* PC */
137 REGOFF (5), /* STATUS32 */
138 REGOFF (2), /* LP_START */
139 REGOFF (3), /* LP_END */
140 REGOFF (1), /* BTA */
141 REGOFF (6) /* ERET */
144 /* Is THIS_FRAME a sigtramp function - the function that returns from
145 signal handler into normal execution flow? This is the case if the PC is
146 either at the start of, or in the middle of the two instructions:
148 mov r8, __NR_rt_sigreturn ; __NR_rt_sigreturn == 139
149 trap_s 0 ; `swi' for ARC700
151 On ARC uClibc Linux this function is called __default_rt_sa_restorer.
153 Returns TRUE if this is a sigtramp frame. */
156 arc_linux_is_sigtramp (struct frame_info
*this_frame
)
158 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
159 CORE_ADDR pc
= get_frame_pc (this_frame
);
163 debug_printf ("arc-linux: arc_linux_is_sigtramp, pc=%s\n",
164 paddress(gdbarch
, pc
));
167 static const gdb_byte insns_be_hs
[] = {
168 0x20, 0x8a, 0x12, 0xc2, /* mov r8,nr_rt_sigreturn */
169 0x78, 0x1e /* trap_s 0 */
171 static const gdb_byte insns_be_700
[] = {
172 0x20, 0x8a, 0x12, 0xc2, /* mov r8,nr_rt_sigreturn */
173 0x22, 0x6f, 0x00, 0x3f /* swi */
176 gdb_byte arc_sigtramp_insns
[sizeof (insns_be_700
)];
178 if (arc_mach_is_arcv2 (gdbarch
))
180 insns_sz
= sizeof (insns_be_hs
);
181 memcpy (arc_sigtramp_insns
, insns_be_hs
, insns_sz
);
185 insns_sz
= sizeof (insns_be_700
);
186 memcpy (arc_sigtramp_insns
, insns_be_700
, insns_sz
);
188 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_LITTLE
)
190 /* On little endian targets, ARC code section is in what is called
191 "middle endian", where half-words are in the big-endian order,
192 only bytes inside the halfwords are in the little endian order.
193 As a result it is very easy to convert big endian instruction to
194 little endian, since it is needed to swap bytes in the halfwords,
195 so there is no need to have information on whether that is a
196 4-byte instruction or 2-byte. */
197 gdb_assert ((insns_sz
% 2) == 0);
198 for (int i
= 0; i
< insns_sz
; i
+= 2)
199 std::swap (arc_sigtramp_insns
[i
], arc_sigtramp_insns
[i
+1]);
202 gdb_byte buf
[insns_sz
];
204 /* Read the memory at the PC. Since we are stopped, any breakpoint must
205 have been removed. */
206 if (!safe_frame_unwind_memory (this_frame
, pc
, buf
, insns_sz
))
208 /* Failed to unwind frame. */
212 /* Is that code the sigtramp instruction sequence? */
213 if (memcmp (buf
, arc_sigtramp_insns
, insns_sz
) == 0)
216 /* No - look one instruction earlier in the code... */
217 if (!safe_frame_unwind_memory (this_frame
, pc
- 4, buf
, insns_sz
))
219 /* Failed to unwind frame. */
223 return (memcmp (buf
, arc_sigtramp_insns
, insns_sz
) == 0);
226 /* Get sigcontext structure of sigtramp frame - it contains saved
227 registers of interrupted frame.
229 Stack pointer points to the rt_sigframe structure, and sigcontext can
239 unsigned long uc_flags;
240 struct ucontext *uc_link;
242 struct sigcontext uc_mcontext;
246 sizeof (struct siginfo) == 0x80
247 offsetof (struct ucontext, uc_mcontext) == 0x14
249 GDB cannot include linux headers and use offsetof () because those are
250 target headers and GDB might be built for a different run host. There
251 doesn't seem to be an established mechanism to figure out those offsets
252 via gdbserver, so the only way is to hardcode values in the GDB,
253 meaning that GDB will be broken if values will change. That seems to
254 be a very unlikely scenario and other arches (aarch64, alpha, amd64,
255 etc) in GDB hardcode values. */
258 arc_linux_sigcontext_addr (struct frame_info
*this_frame
)
260 const int ucontext_offset
= 0x80;
261 const int sigcontext_offset
= 0x14;
262 return get_frame_sp (this_frame
) + ucontext_offset
+ sigcontext_offset
;
265 /* Implement the "cannot_fetch_register" gdbarch method. */
268 arc_linux_cannot_fetch_register (struct gdbarch
*gdbarch
, int regnum
)
270 /* Assume that register is readable if it is unknown. */
273 case ARC_ILINK_REGNUM
:
274 case ARC_RESERVED_REGNUM
:
275 case ARC_LIMM_REGNUM
:
280 return !arc_mach_is_arcv2 (gdbarch
);
282 return (regnum
> ARC_BLINK_REGNUM
) && (regnum
< ARC_LP_COUNT_REGNUM
);
285 /* Implement the "cannot_store_register" gdbarch method. */
288 arc_linux_cannot_store_register (struct gdbarch
*gdbarch
, int regnum
)
290 /* Assume that register is writable if it is unknown. */
293 case ARC_ILINK_REGNUM
:
294 case ARC_RESERVED_REGNUM
:
295 case ARC_LIMM_REGNUM
:
301 return !arc_mach_is_arcv2 (gdbarch
);
303 return (regnum
> ARC_BLINK_REGNUM
) && (regnum
< ARC_LP_COUNT_REGNUM
);
306 /* For ARC Linux, breakpoints use the 16-bit TRAP_S 1 instruction, which
307 is 0x3e78 (little endian) or 0x783e (big endian). */
309 static const gdb_byte arc_linux_trap_s_be
[] = { 0x78, 0x3e };
310 static const gdb_byte arc_linux_trap_s_le
[] = { 0x3e, 0x78 };
311 static const int trap_size
= 2; /* Number of bytes to insert "trap". */
313 /* Implement the "breakpoint_kind_from_pc" gdbarch method. */
316 arc_linux_breakpoint_kind_from_pc (struct gdbarch
*gdbarch
, CORE_ADDR
*pcptr
)
321 /* Implement the "sw_breakpoint_from_kind" gdbarch method. */
323 static const gdb_byte
*
324 arc_linux_sw_breakpoint_from_kind (struct gdbarch
*gdbarch
,
327 gdb_assert (kind
== trap_size
);
329 return ((gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
330 ? arc_linux_trap_s_be
331 : arc_linux_trap_s_le
);
334 /* Implement the "software_single_step" gdbarch method. */
336 static std::vector
<CORE_ADDR
>
337 arc_linux_software_single_step (struct regcache
*regcache
)
339 struct gdbarch
*gdbarch
= regcache
->arch ();
340 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
341 struct disassemble_info di
= arc_disassemble_info (gdbarch
);
343 /* Read current instruction. */
344 struct arc_instruction curr_insn
;
345 arc_insn_decode (regcache_read_pc (regcache
), &di
, arc_delayed_print_insn
,
347 CORE_ADDR next_pc
= arc_insn_get_linear_next_pc (curr_insn
);
349 std::vector
<CORE_ADDR
> next_pcs
;
351 /* For instructions with delay slots, the fall thru is not the
352 instruction immediately after the current instruction, but the one
354 if (curr_insn
.has_delay_slot
)
356 struct arc_instruction next_insn
;
357 arc_insn_decode (next_pc
, &di
, arc_delayed_print_insn
, &next_insn
);
358 next_pcs
.push_back (arc_insn_get_linear_next_pc (next_insn
));
361 next_pcs
.push_back (next_pc
);
364 regcache_cooked_read_unsigned (regcache
, gdbarch_ps_regnum (gdbarch
),
367 if (curr_insn
.is_control_flow
)
369 CORE_ADDR branch_pc
= arc_insn_get_branch_target (curr_insn
);
370 if (branch_pc
!= next_pc
)
371 next_pcs
.push_back (branch_pc
);
373 /* Is current instruction the last in a loop body? */
374 else if (tdep
->has_hw_loops
)
376 /* If STATUS32.L is 1, then ZD-loops are disabled. */
377 if ((status32
& ARC_STATUS32_L_MASK
) == 0)
379 ULONGEST lp_end
, lp_start
, lp_count
;
380 regcache_cooked_read_unsigned (regcache
, ARC_LP_START_REGNUM
,
382 regcache_cooked_read_unsigned (regcache
, ARC_LP_END_REGNUM
, &lp_end
);
383 regcache_cooked_read_unsigned (regcache
, ARC_LP_COUNT_REGNUM
,
388 debug_printf ("arc-linux: lp_start = %s, lp_end = %s, "
389 "lp_count = %s, next_pc = %s\n",
390 paddress (gdbarch
, lp_start
),
391 paddress (gdbarch
, lp_end
),
392 pulongest (lp_count
),
393 paddress (gdbarch
, next_pc
));
396 if (next_pc
== lp_end
&& lp_count
> 1)
398 /* The instruction is in effect a jump back to the start of
400 next_pcs
.push_back (lp_start
);
405 /* Is this a delay slot? Then next PC is in BTA register. */
406 if ((status32
& ARC_STATUS32_DE_MASK
) != 0)
409 regcache_cooked_read_unsigned (regcache
, ARC_BTA_REGNUM
, &bta
);
410 next_pcs
.push_back (bta
);
416 /* Implement the "skip_solib_resolver" gdbarch method.
418 See glibc_skip_solib_resolver for details. */
421 arc_linux_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
423 /* For uClibc 0.9.26+.
425 An unresolved PLT entry points to "__dl_linux_resolve", which calls
426 "_dl_linux_resolver" to do the resolving and then eventually jumps to
429 So we look for the symbol `_dl_linux_resolver', and if we are there,
430 gdb sets a breakpoint at the return address, and continues. */
431 struct bound_minimal_symbol resolver
432 = lookup_minimal_symbol ("_dl_linux_resolver", NULL
, NULL
);
436 if (resolver
.minsym
!= nullptr)
438 CORE_ADDR res_addr
= BMSYMBOL_VALUE_ADDRESS (resolver
);
439 debug_printf ("arc-linux: skip_solib_resolver (): "
440 "pc = %s, resolver at %s\n",
441 print_core_address (gdbarch
, pc
),
442 print_core_address (gdbarch
, res_addr
));
446 debug_printf ("arc-linux: skip_solib_resolver (): "
447 "pc = %s, no resolver found\n",
448 print_core_address (gdbarch
, pc
));
452 if (resolver
.minsym
!= nullptr && BMSYMBOL_VALUE_ADDRESS (resolver
) == pc
)
454 /* Find the return address. */
455 return frame_unwind_caller_pc (get_current_frame ());
459 /* No breakpoint required. */
464 /* Populate REGCACHE with register REGNUM from BUF. */
467 supply_register (struct regcache
*regcache
, int regnum
, const gdb_byte
*buf
)
469 /* Skip non-existing registers. */
470 if ((arc_linux_core_reg_offsets
[regnum
] == ARC_OFFSET_NO_REGISTER
))
473 regcache
->raw_supply (regnum
, buf
+ arc_linux_core_reg_offsets
[regnum
]);
477 arc_linux_supply_gregset (const struct regset
*regset
,
478 struct regcache
*regcache
,
479 int regnum
, const void *gregs
, size_t size
)
481 gdb_static_assert (ARC_LAST_REGNUM
482 < ARRAY_SIZE (arc_linux_core_reg_offsets
));
484 const bfd_byte
*buf
= (const bfd_byte
*) gregs
;
486 /* REGNUM == -1 means writing all the registers. */
488 for (int reg
= 0; reg
<= ARC_LAST_REGNUM
; reg
++)
489 supply_register (regcache
, reg
, buf
);
490 else if (regnum
<= ARC_LAST_REGNUM
)
491 supply_register (regcache
, regnum
, buf
);
493 gdb_assert_not_reached ("Invalid regnum in arc_linux_supply_gregset.");
497 arc_linux_supply_v2_regset (const struct regset
*regset
,
498 struct regcache
*regcache
, int regnum
,
499 const void *v2_regs
, size_t size
)
501 const bfd_byte
*buf
= (const bfd_byte
*) v2_regs
;
503 /* user_regs_arcv2 is defined in linux arch/arc/include/uapi/asm/ptrace.h. */
504 if (regnum
== -1 || regnum
== ARC_R30_REGNUM
)
505 regcache
->raw_supply (ARC_R30_REGNUM
, buf
);
506 if (regnum
== -1 || regnum
== ARC_R58_REGNUM
)
507 regcache
->raw_supply (ARC_R58_REGNUM
, buf
+ REGOFF (1));
508 if (regnum
== -1 || regnum
== ARC_R59_REGNUM
)
509 regcache
->raw_supply (ARC_R59_REGNUM
, buf
+ REGOFF (2));
512 /* Populate BUF with register REGNUM from the REGCACHE. */
515 collect_register (const struct regcache
*regcache
, struct gdbarch
*gdbarch
,
516 int regnum
, gdb_byte
*buf
)
520 /* Skip non-existing registers. */
521 if (arc_linux_core_reg_offsets
[regnum
] == ARC_OFFSET_NO_REGISTER
)
524 /* The address where the execution has stopped is in pseudo-register
525 STOP_PC. However, when kernel code is returning from the exception,
526 it uses the value from ERET register. Since, TRAP_S (the breakpoint
527 instruction) commits, the ERET points to the next instruction. In
528 other words: ERET != STOP_PC. To jump back from the kernel code to
529 the correct address, ERET must be overwritten by GDB's STOP_PC. Else,
530 the program will continue at the address after the current instruction.
532 if (regnum
== gdbarch_pc_regnum (gdbarch
))
533 offset
= arc_linux_core_reg_offsets
[ARC_ERET_REGNUM
];
535 offset
= arc_linux_core_reg_offsets
[regnum
];
536 regcache
->raw_collect (regnum
, buf
+ offset
);
540 arc_linux_collect_gregset (const struct regset
*regset
,
541 const struct regcache
*regcache
,
542 int regnum
, void *gregs
, size_t size
)
544 gdb_static_assert (ARC_LAST_REGNUM
545 < ARRAY_SIZE (arc_linux_core_reg_offsets
));
547 gdb_byte
*buf
= (gdb_byte
*) gregs
;
548 struct gdbarch
*gdbarch
= regcache
->arch ();
550 /* REGNUM == -1 means writing all the registers. */
552 for (int reg
= 0; reg
<= ARC_LAST_REGNUM
; reg
++)
553 collect_register (regcache
, gdbarch
, reg
, buf
);
554 else if (regnum
<= ARC_LAST_REGNUM
)
555 collect_register (regcache
, gdbarch
, regnum
, buf
);
557 gdb_assert_not_reached ("Invalid regnum in arc_linux_collect_gregset.");
561 arc_linux_collect_v2_regset (const struct regset
*regset
,
562 const struct regcache
*regcache
, int regnum
,
563 void *v2_regs
, size_t size
)
565 bfd_byte
*buf
= (bfd_byte
*) v2_regs
;
567 if (regnum
== -1 || regnum
== ARC_R30_REGNUM
)
568 regcache
->raw_collect (ARC_R30_REGNUM
, buf
);
569 if (regnum
== -1 || regnum
== ARC_R58_REGNUM
)
570 regcache
->raw_collect (ARC_R58_REGNUM
, buf
+ REGOFF (1));
571 if (regnum
== -1 || regnum
== ARC_R59_REGNUM
)
572 regcache
->raw_collect (ARC_R59_REGNUM
, buf
+ REGOFF (2));
575 /* Linux regset definitions. */
577 static const struct regset arc_linux_gregset
= {
578 arc_linux_core_reg_offsets
,
579 arc_linux_supply_gregset
,
580 arc_linux_collect_gregset
,
583 static const struct regset arc_linux_v2_regset
= {
585 arc_linux_supply_v2_regset
,
586 arc_linux_collect_v2_regset
,
589 /* Implement the `iterate_over_regset_sections` gdbarch method. */
592 arc_linux_iterate_over_regset_sections (struct gdbarch
*gdbarch
,
593 iterate_over_regset_sections_cb
*cb
,
595 const struct regcache
*regcache
)
597 /* There are 40 registers in Linux user_regs_struct, although some of
598 them are now just a mere paddings, kept to maintain binary
599 compatibility with older tools. */
600 const int sizeof_gregset
= 40 * ARC_REGISTER_SIZE
;
602 cb (".reg", sizeof_gregset
, sizeof_gregset
, &arc_linux_gregset
, NULL
,
604 cb (".reg-arc-v2", ARC_LINUX_SIZEOF_V2_REGSET
, ARC_LINUX_SIZEOF_V2_REGSET
,
605 &arc_linux_v2_regset
, NULL
, cb_data
);
608 /* Implement the `core_read_description` gdbarch method. */
610 static const struct target_desc
*
611 arc_linux_core_read_description (struct gdbarch
*gdbarch
,
612 struct target_ops
*target
,
615 arc_arch_features features
616 = arc_arch_features_create (abfd
,
617 gdbarch_bfd_arch_info (gdbarch
)->mach
);
618 return arc_lookup_target_description (features
);
621 /* Initialization specific to Linux environment. */
624 arc_linux_init_osabi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
626 struct gdbarch_tdep
*tdep
= gdbarch_tdep (gdbarch
);
629 debug_printf ("arc-linux: GNU/Linux OS/ABI initialization.\n");
631 /* Fill in target-dependent info in ARC-private structure. */
632 tdep
->is_sigtramp
= arc_linux_is_sigtramp
;
633 tdep
->sigcontext_addr
= arc_linux_sigcontext_addr
;
634 tdep
->sc_reg_offset
= arc_linux_sc_reg_offsets
;
635 tdep
->sc_num_regs
= ARRAY_SIZE (arc_linux_sc_reg_offsets
);
637 /* If we are using Linux, we have in uClibc
638 (libc/sysdeps/linux/arc/bits/setjmp.h):
640 typedef int __jmp_buf[13+1+1+1]; //r13-r25, fp, sp, blink
642 Where "blink" is a stored PC of a caller function.
646 linux_init_abi (info
, gdbarch
, 0);
648 /* Set up target dependent GDB architecture entries. */
649 set_gdbarch_cannot_fetch_register (gdbarch
, arc_linux_cannot_fetch_register
);
650 set_gdbarch_cannot_store_register (gdbarch
, arc_linux_cannot_store_register
);
651 set_gdbarch_breakpoint_kind_from_pc (gdbarch
,
652 arc_linux_breakpoint_kind_from_pc
);
653 set_gdbarch_sw_breakpoint_from_kind (gdbarch
,
654 arc_linux_sw_breakpoint_from_kind
);
655 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
656 svr4_fetch_objfile_link_map
);
657 set_gdbarch_software_single_step (gdbarch
, arc_linux_software_single_step
);
658 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
659 set_gdbarch_skip_solib_resolver (gdbarch
, arc_linux_skip_solib_resolver
);
660 set_gdbarch_iterate_over_regset_sections
661 (gdbarch
, arc_linux_iterate_over_regset_sections
);
662 set_gdbarch_core_read_description (gdbarch
, arc_linux_core_read_description
);
664 /* GNU/Linux uses SVR4-style shared libraries, with 32-bit ints, longs
665 and pointers (ILP32). */
666 set_solib_svr4_fetch_link_map_offsets (gdbarch
,
667 svr4_ilp32_fetch_link_map_offsets
);
670 /* Suppress warning from -Wmissing-prototypes. */
671 extern initialize_file_ftype _initialize_arc_linux_tdep
;
674 _initialize_arc_linux_tdep ()
676 gdbarch_register_osabi (bfd_arch_arc
, 0, GDB_OSABI_LINUX
,
677 arc_linux_init_osabi
);