GDB (xrefs)

/tmp/gdb-8.1/gdb/tilegx-linux-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for GNU/Linux on Tilera TILE-Gx processors.
2
3 Copyright (C) 2012-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20 #include "defs.h"
21 #include "osabi.h"
22 #include "linux-tdep.h"
23 #include "glibc-tdep.h"
24 #include "solib-svr4.h"
25 #include "symtab.h"
26 #include "regcache.h"
27 #include "regset.h"
28 #include "tramp-frame.h"
29 #include "trad-frame.h"
30 #include "tilegx-tdep.h"
31
32 /* Signal trampoline support. */
33
34 static void
35 tilegx_linux_sigframe_init (const struct tramp_frame *self,
36 struct frame_info *this_frame,
37 struct trad_frame_cache *this_cache,
38 CORE_ADDR func)
39 {
40 CORE_ADDR sp = get_frame_register_unsigned (this_frame, 54);
41
42 /* Base address of register save area. */
43 CORE_ADDR base = sp
44 + 16 /* Skip ABI_SAVE_AREA. */
45 + 128 /* Skip SIGINFO. */
46 + 40; /* Skip UCONTEXT. */
47
48 /* Address of saved LR register (R56) which holds previous PC. */
49 CORE_ADDR prev_pc = base + 56 * 8;
50
51 int i;
52
53 for (i = 0; i < 56; i++)
54 trad_frame_set_reg_addr (this_cache, i, base + i * 8);
55
56 trad_frame_set_reg_value (this_cache, 64,
57 get_frame_memory_unsigned (this_frame, prev_pc, 8));
58
59 /* Save a frame ID. */
60 trad_frame_set_id (this_cache, frame_id_build (base, func));
61 }
62
63 static const struct tramp_frame tilegx_linux_rt_sigframe =
64 {
65 SIGTRAMP_FRAME,
66 8,
67 {
68 { 0x00045fe551483000ULL, -1 }, /* { moveli r10, 139 } */
69 { 0x286b180051485000ULL, -1 }, /* { swint1 } */
70 { TRAMP_SENTINEL_INSN, -1 }
71 },
72 tilegx_linux_sigframe_init
73 };
74
75 /* Register map; must match struct pt_regs in "ptrace.h". */
76
77 static const struct regcache_map_entry tilegx_linux_regmap[] =
78 {
79 { TILEGX_NUM_EASY_REGS, TILEGX_FIRST_EASY_REGNUM, 8 },
80 { 1, TILEGX_PC_REGNUM, 8 },
81 { 1, TILEGX_FAULTNUM_REGNUM, 8 },
82 { 0 }
83 };
84
85 #define TILEGX_LINUX_SIZEOF_GREGSET (64 * 8)
86
87 /* TILE-Gx Linux kernel register set. */
88
89 static const struct regset tilegx_linux_regset =
90 {
91 tilegx_linux_regmap,
92 regcache_supply_regset, regcache_collect_regset
93 };
94
95
96 static void
97 tilegx_iterate_over_regset_sections (struct gdbarch *gdbarch,
98 iterate_over_regset_sections_cb *cb,
99 void *cb_data,
100 const struct regcache *regcache)
101 {
102 cb (".reg", TILEGX_LINUX_SIZEOF_GREGSET, &tilegx_linux_regset,
103 NULL, cb_data);
104 }
105
106 /* OS specific initialization of gdbarch. */
107
108 static void
109 tilegx_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
110 {
111 int arch_size = gdbarch_addr_bit (gdbarch);
112
113 linux_init_abi (info, gdbarch);
114
115 tramp_frame_prepend_unwinder (gdbarch, &tilegx_linux_rt_sigframe);
116
117 set_gdbarch_iterate_over_regset_sections
118 (gdbarch, tilegx_iterate_over_regset_sections);
119
120 /* GNU/Linux uses SVR4-style shared libraries. */
121 if (arch_size == 32)
122 set_solib_svr4_fetch_link_map_offsets (gdbarch,
123 svr4_ilp32_fetch_link_map_offsets);
124 else
125 set_solib_svr4_fetch_link_map_offsets (gdbarch,
126 svr4_lp64_fetch_link_map_offsets);
127
128 /* Enable TLS support. */
129 set_gdbarch_fetch_tls_load_module_address (gdbarch,
130 svr4_fetch_objfile_link_map);
131
132 /* Shared library handling. */
133 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
134 set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
135 }
136
137 void
138 _initialize_tilegx_linux_tdep (void)
139 {
140 gdbarch_register_osabi (bfd_arch_tilegx, bfd_mach_tilegx, GDB_OSABI_LINUX,
141 tilegx_linux_init_abi);
142 }
gdbarch
Definition: gdbarch.c:127
trad_frame_set_reg_addr
void trad_frame_set_reg_addr(struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr)
Definition: trad-frame.c:126
tilegx_linux_rt_sigframe
static const struct tramp_frame tilegx_linux_rt_sigframe
Definition: tilegx-linux-tdep.c:63
frame_id_build
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
Definition: frame.c:624
TILEGX_FAULTNUM_REGNUM
Definition: tilegx-tdep.h:104
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
set_gdbarch_fetch_tls_load_module_address
void set_gdbarch_fetch_tls_load_module_address(struct gdbarch *gdbarch, gdbarch_fetch_tls_load_module_address_ftype fetch_tls_load_module_address)
Definition: gdbarch.c:3038
TRAMP_SENTINEL_INSN
#define TRAMP_SENTINEL_INSN
Definition: tramp-frame.h:44
svr4_lp64_fetch_link_map_offsets
struct link_map_offsets * svr4_lp64_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3214
func
void(* func)(char *)
Definition: remote-fileio.c:1104
iterate_over_regset_sections_cb
void() iterate_over_regset_sections_cb(const char *sect_name, int size, const struct regset *regset, const char *human_name, void *cb_data)
Definition: gdbarch.h:99
set_gdbarch_skip_trampoline_code
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype skip_trampoline_code)
Definition: gdbarch.c:3316
glibc_skip_solib_resolver
CORE_ADDR glibc_skip_solib_resolver(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: glibc-tdep.c:38
tilegx_iterate_over_regset_sections
static void tilegx_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
Definition: tilegx-linux-tdep.c:97
trad_frame_set_id
void trad_frame_set_id(struct trad_frame_cache *this_trad_cache, struct frame_id this_id)
Definition: trad-frame.c:171
GDB_OSABI_LINUX
Definition: defs.h:517
regcache_supply_regset
void regcache_supply_regset(const struct regset *regset, struct regcache *regcache, int regnum, const void *buf, size_t size)
Definition: regcache.c:1192
linux_init_abi
void linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: linux-tdep.c:2492
SIGTRAMP_FRAME
Definition: frame.h:255
frame_info
Definition: frame.c:85
svr4_ilp32_fetch_link_map_offsets
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3183
TILEGX_PC_REGNUM
Definition: tilegx-tdep.h:102
get_frame_memory_unsigned
ULONGEST get_frame_memory_unsigned(struct frame_info *this_frame, CORE_ADDR addr, int len)
Definition: frame.c:2671
defs.h
tilegx_linux_regset
static const struct regset tilegx_linux_regset
Definition: tilegx-linux-tdep.c:89
svr4_fetch_objfile_link_map
CORE_ADDR svr4_fetch_objfile_link_map(struct objfile *objfile)
Definition: solib-svr4.c:1579
TILEGX_NUM_EASY_REGS
Definition: tilegx-tdep.h:92
regset
Definition: regset.h:34
_initialize_tilegx_linux_tdep
void _initialize_tilegx_linux_tdep(void)
Definition: tilegx-linux-tdep.c:138
symtab.h
tilegx_linux_sigframe_init
static void tilegx_linux_sigframe_init(const struct tramp_frame *self, struct frame_info *this_frame, struct trad_frame_cache *this_cache, CORE_ADDR func)
Definition: tilegx-linux-tdep.c:35
trad-frame.h
find_solib_trampoline_target
CORE_ADDR find_solib_trampoline_target(struct frame_info *frame, CORE_ADDR pc)
Definition: minsyms.c:1492
solib-svr4.h
osabi.h
trad_frame_cache
Definition: trad-frame.c:27
regcache.h
tilegx-tdep.h
tilegx_linux_regmap
static const struct regcache_map_entry tilegx_linux_regmap[]
Definition: tilegx-linux-tdep.c:77
set_solib_svr4_fetch_link_map_offsets
void set_solib_svr4_fetch_link_map_offsets(struct gdbarch *gdbarch, struct link_map_offsets *(*flmo)(void))
Definition: solib-svr4.c:3137
regcache_collect_regset
void regcache_collect_regset(const struct regset *regset, const struct regcache *regcache, int regnum, void *buf, size_t size)
Definition: regcache.c:1211
TILEGX_FIRST_EASY_REGNUM
Definition: tilegx-tdep.h:34
gdbarch_addr_bit
int gdbarch_addr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1848
trad_frame_set_reg_value
void trad_frame_set_reg_value(struct trad_frame_cache *this_trad_cache, int regnum, LONGEST val)
Definition: trad-frame.c:109
get_frame_register_unsigned
ULONGEST get_frame_register_unsigned(struct frame_info *frame, int regnum)
Definition: frame.c:1308
gdbarch_register_osabi
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
Definition: osabi.c:143
glibc-tdep.h
tramp-frame.h
TILEGX_LINUX_SIZEOF_GREGSET
#define TILEGX_LINUX_SIZEOF_GREGSET
Definition: tilegx-linux-tdep.c:85
tramp_frame_prepend_unwinder
void tramp_frame_prepend_unwinder(struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame)
Definition: tramp-frame.c:146
linux-tdep.h
tilegx_linux_init_abi
static void tilegx_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: tilegx-linux-tdep.c:109
regcache
Definition: regcache.h:232
gdbarch_info
Definition: gdbarch.h:1626
regset.h
tramp_frame
Definition: tramp-frame.h:46
set_gdbarch_iterate_over_regset_sections
void set_gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, gdbarch_iterate_over_regset_sections_ftype iterate_over_regset_sections)
Definition: gdbarch.c:3647
set_gdbarch_skip_solib_resolver
void set_gdbarch_skip_solib_resolver(struct gdbarch *gdbarch, gdbarch_skip_solib_resolver_ftype skip_solib_resolver)
Definition: gdbarch.c:3333
regcache_map_entry
Definition: regcache.h:157