1 /* Target-dependent code for GNU/Linux on Tilera TILE-Gx processors.
3 Copyright (C) 2012-2013 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/>. */
22 #include "linux-tdep.h"
23 #include "glibc-tdep.h"
24 #include "solib-svr4.h"
28 #include "tramp-frame.h"
29 #include "trad-frame.h"
30 #include "tilegx-tdep.h"
32 /* Signal trampoline support. */
35 tilegx_linux_sigframe_init (const struct tramp_frame
*self
,
36 struct frame_info
*this_frame
,
37 struct trad_frame_cache
*this_cache
,
40 CORE_ADDR pc
= get_frame_register_unsigned (this_frame
, 64);
41 CORE_ADDR sp
= get_frame_register_unsigned (this_frame
, 54);
43 /* Base address of register save area. */
45 + 16 /* Skip ABI_SAVE_AREA. */
46 + 128 /* Skip SIGINFO. */
47 + 40; /* Skip UCONTEXT. */
49 /* Address of saved LR register (R56) which holds previous PC. */
50 CORE_ADDR prev_pc
= base
+ 56 * 8;
54 for (i
= 0; i
< 56; i
++)
55 trad_frame_set_reg_addr (this_cache
, i
, base
+ i
* 8);
57 trad_frame_set_reg_value (this_cache
, 64,
58 get_frame_memory_unsigned (this_frame
, prev_pc
, 8));
60 /* Save a frame ID. */
61 trad_frame_set_id (this_cache
, frame_id_build (base
, func
));
64 static const struct tramp_frame tilegx_linux_rt_sigframe
=
69 { 0x00045fe551483000ULL
, -1 }, /* { moveli r10, 139 } */
70 { 0x286b180051485000ULL
, -1 }, /* { swint1 } */
71 { TRAMP_SENTINEL_INSN
, -1 }
73 tilegx_linux_sigframe_init
76 /* Supply raw registers from REGCACHE to REGS. */
79 tilegx_linux_supply_regset (const struct regset
*regset
,
80 struct regcache
*regcache
,
81 int regnum
, const void *regs
, size_t len
)
83 struct gdbarch
*arch
= get_regcache_arch (regcache
);
84 const char *ptr
= regs
;
87 /* This logic must match that of struct pt_regs in "ptrace.h". */
88 for (i
= 0; i
< TILEGX_NUM_EASY_REGS
+ 2; i
++, ptr
+= tilegx_reg_size
)
90 int gri
= (i
< TILEGX_NUM_EASY_REGS
)
91 ? i
: (i
== TILEGX_NUM_EASY_REGS
)
92 ? TILEGX_PC_REGNUM
: TILEGX_FAULTNUM_REGNUM
;
94 if (regnum
== gri
|| regnum
== -1)
95 regcache_raw_supply (regcache
, gri
, ptr
);
99 /* TILE-Gx Linux kernel register set. */
100 static struct regset tilegx_linux_regset
=
103 tilegx_linux_supply_regset
106 static const struct regset
*
107 tilegx_regset_from_core_section (struct gdbarch
*gdbarch
,
108 const char *sect_name
,
111 if (strcmp (sect_name
, ".reg") == 0)
112 return &tilegx_linux_regset
;
117 /* OS specific initialization of gdbarch. */
120 tilegx_linux_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
122 int arch_size
= gdbarch_addr_bit (gdbarch
);
124 linux_init_abi (info
, gdbarch
);
126 tramp_frame_prepend_unwinder (gdbarch
, &tilegx_linux_rt_sigframe
);
128 set_gdbarch_regset_from_core_section (gdbarch
,
129 tilegx_regset_from_core_section
);
131 /* GNU/Linux uses SVR4-style shared libraries. */
133 set_solib_svr4_fetch_link_map_offsets (gdbarch
,
134 svr4_ilp32_fetch_link_map_offsets
);
136 set_solib_svr4_fetch_link_map_offsets (gdbarch
,
137 svr4_lp64_fetch_link_map_offsets
);
139 /* Enable TLS support. */
140 set_gdbarch_fetch_tls_load_module_address (gdbarch
,
141 svr4_fetch_objfile_link_map
);
143 /* Shared library handling. */
144 set_gdbarch_skip_trampoline_code (gdbarch
, find_solib_trampoline_target
);
145 set_gdbarch_skip_solib_resolver (gdbarch
, glibc_skip_solib_resolver
);
147 set_gdbarch_get_siginfo_type (gdbarch
, linux_get_siginfo_type
);
150 /* Provide a prototype to silence -Wmissing-prototypes. */
151 extern initialize_file_ftype _initialize_tilegx_linux_tdep
;
154 _initialize_tilegx_linux_tdep (void)
156 gdbarch_register_osabi (bfd_arch_tilegx
, bfd_mach_tilegx
, GDB_OSABI_LINUX
,
157 tilegx_linux_init_abi
);