GDB (xrefs)

/tmp/gdb-8.1/gdb/xtensa-linux-tdep.c
Go to the documentation of this file.
1 /* Target-dependent code for GNU/Linux on Xtensa processors.
2
3 Copyright (C) 2007-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 "solib-svr4.h"
24 #include "symtab.h"
25
26 /* This enum represents the signals' numbers on the Xtensa
27 architecture. It just contains the signal definitions which are
28 different from the generic implementation.
29
30 It is derived from the file <arch/xtensa/include/uapi/asm/signal.h>,
31 from the Linux kernel tree. */
32
33 enum
34 {
35 XTENSA_LINUX_SIGRTMIN = 32,
36 XTENSA_LINUX_SIGRTMAX = 63,
37 };
38
39 /* Implementation of `gdbarch_gdb_signal_from_target', as defined in
40 gdbarch.h. */
41
42 static enum gdb_signal
43 xtensa_linux_gdb_signal_from_target (struct gdbarch *gdbarch,
44 int signal)
45 {
46 if (signal >= XTENSA_LINUX_SIGRTMIN && signal <= XTENSA_LINUX_SIGRTMAX)
47 {
48 int offset = signal - XTENSA_LINUX_SIGRTMIN;
49
50 if (offset == 0)
51 return GDB_SIGNAL_REALTIME_32;
52 else
53 return (enum gdb_signal) (offset - 1
54 + (int) GDB_SIGNAL_REALTIME_33);
55 }
56 else if (signal > XTENSA_LINUX_SIGRTMAX)
57 return GDB_SIGNAL_UNKNOWN;
58
59 return linux_gdb_signal_from_target (gdbarch, signal);
60 }
61
62 /* Implementation of `gdbarch_gdb_signal_to_target', as defined in
63 gdbarch.h. */
64
65 static int
66 xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
67 enum gdb_signal signal)
68 {
69 switch (signal)
70 {
71 /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
72 therefore we have to handle it here. */
73 case GDB_SIGNAL_REALTIME_32:
74 return XTENSA_LINUX_SIGRTMIN;
75
76 /* GDB_SIGNAL_REALTIME_64 is not valid on Xtensa. */
77 case GDB_SIGNAL_REALTIME_64:
78 return -1;
79 }
80
81 /* GDB_SIGNAL_REALTIME_33 to _63 are continuous.
82
83 Xtensa does not have _64. */
84 if (signal >= GDB_SIGNAL_REALTIME_33
85 && signal <= GDB_SIGNAL_REALTIME_63)
86 {
87 int offset = signal - GDB_SIGNAL_REALTIME_33;
88
89 return XTENSA_LINUX_SIGRTMIN + 1 + offset;
90 }
91
92 return linux_gdb_signal_to_target (gdbarch, signal);
93 }
94
95 /* OS specific initialization of gdbarch. */
96
97 static void
98 xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
99 {
100 linux_init_abi (info, gdbarch);
101
102 set_solib_svr4_fetch_link_map_offsets
103 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
104
105 set_gdbarch_gdb_signal_from_target (gdbarch,
106 xtensa_linux_gdb_signal_from_target);
107 set_gdbarch_gdb_signal_to_target (gdbarch,
108 xtensa_linux_gdb_signal_to_target);
109
110 /* Enable TLS support. */
111 set_gdbarch_fetch_tls_load_module_address (gdbarch,
112 svr4_fetch_objfile_link_map);
113 }
114
115 void
116 _initialize_xtensa_linux_tdep (void)
117 {
118 gdbarch_register_osabi (bfd_arch_xtensa, bfd_mach_xtensa, GDB_OSABI_LINUX,
119 xtensa_linux_init_abi);
120 }
gdbarch
Definition: gdbarch.c:127
XTENSA_LINUX_SIGRTMIN
Definition: xtensa-linux-tdep.c:35
xtensa_linux_gdb_signal_from_target
static enum gdb_signal xtensa_linux_gdb_signal_from_target(struct gdbarch *gdbarch, int signal)
Definition: xtensa-linux-tdep.c:43
set_gdbarch_gdb_signal_to_target
void set_gdbarch_gdb_signal_to_target(struct gdbarch *gdbarch, gdbarch_gdb_signal_to_target_ftype gdb_signal_to_target)
Definition: gdbarch.c:4209
_initialize_xtensa_linux_tdep
void _initialize_xtensa_linux_tdep(void)
Definition: xtensa-linux-tdep.c:116
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
GDB_OSABI_LINUX
Definition: defs.h:517
set_gdbarch_gdb_signal_from_target
void set_gdbarch_gdb_signal_from_target(struct gdbarch *gdbarch, gdbarch_gdb_signal_from_target_ftype gdb_signal_from_target)
Definition: gdbarch.c:4185
linux_init_abi
void linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: linux-tdep.c:2492
svr4_ilp32_fetch_link_map_offsets
struct link_map_offsets * svr4_ilp32_fetch_link_map_offsets(void)
Definition: solib-svr4.c:3183
XTENSA_LINUX_SIGRTMAX
Definition: xtensa-linux-tdep.c:36
defs.h
svr4_fetch_objfile_link_map
CORE_ADDR svr4_fetch_objfile_link_map(struct objfile *objfile)
Definition: solib-svr4.c:1579
symtab.h
linux_gdb_signal_from_target
enum gdb_signal linux_gdb_signal_from_target(struct gdbarch *gdbarch, int signal)
Definition: linux-tdep.c:2003
solib-svr4.h
osabi.h
xtensa_linux_gdb_signal_to_target
static int xtensa_linux_gdb_signal_to_target(struct gdbarch *gdbarch, enum gdb_signal signal)
Definition: xtensa-linux-tdep.c:66
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
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
linux_gdb_signal_to_target
int linux_gdb_signal_to_target(struct gdbarch *gdbarch, enum gdb_signal signal)
Definition: linux-tdep.c:2126
offset
int offset
Definition: agent.c:65
linux-tdep.h
gdbarch_info
Definition: gdbarch.h:1626
xtensa_linux_init_abi
static void xtensa_linux_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
Definition: xtensa-linux-tdep.c:98