1 /* Target-dependent code for GNU/Linux on Xtensa processors.
3 Copyright (C) 2007-2019 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/>. */
21 #include "xtensa-tdep.h"
23 #include "linux-tdep.h"
24 #include "solib-svr4.h"
28 /* This enum represents the signals' numbers on the Xtensa
29 architecture. It just contains the signal definitions which are
30 different from the generic implementation.
32 It is derived from the file <arch/xtensa/include/uapi/asm/signal.h>,
33 from the Linux kernel tree. */
37 XTENSA_LINUX_SIGRTMIN = 32,
38 XTENSA_LINUX_SIGRTMAX = 63,
41 /* Implementation of `gdbarch_gdb_signal_from_target', as defined in
44 static enum gdb_signal
45 xtensa_linux_gdb_signal_from_target (struct gdbarch *gdbarch,
48 if (signal >= XTENSA_LINUX_SIGRTMIN && signal <= XTENSA_LINUX_SIGRTMAX)
50 int offset = signal - XTENSA_LINUX_SIGRTMIN;
53 return GDB_SIGNAL_REALTIME_32;
55 return (enum gdb_signal) (offset - 1
56 + (int) GDB_SIGNAL_REALTIME_33);
58 else if (signal > XTENSA_LINUX_SIGRTMAX)
59 return GDB_SIGNAL_UNKNOWN;
61 return linux_gdb_signal_from_target (gdbarch, signal);
64 /* Implementation of `gdbarch_gdb_signal_to_target', as defined in
68 xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
69 enum gdb_signal signal)
73 /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
74 therefore we have to handle it here. */
75 case GDB_SIGNAL_REALTIME_32:
76 return XTENSA_LINUX_SIGRTMIN;
78 /* GDB_SIGNAL_REALTIME_64 is not valid on Xtensa. */
79 case GDB_SIGNAL_REALTIME_64:
83 /* GDB_SIGNAL_REALTIME_33 to _63 are continuous.
85 Xtensa does not have _64. */
86 if (signal >= GDB_SIGNAL_REALTIME_33
87 && signal <= GDB_SIGNAL_REALTIME_63)
89 int offset = signal - GDB_SIGNAL_REALTIME_33;
91 return XTENSA_LINUX_SIGRTMIN + 1 + offset;
94 return linux_gdb_signal_to_target (gdbarch, signal);
97 /* OS specific initialization of gdbarch. */
100 xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
102 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
104 if (tdep->num_nopriv_regs < tdep->num_regs)
106 tdep->num_pseudo_regs += tdep->num_regs - tdep->num_nopriv_regs;
107 tdep->num_regs = tdep->num_nopriv_regs;
109 set_gdbarch_num_regs (gdbarch, tdep->num_regs);
110 set_gdbarch_num_pseudo_regs (gdbarch, tdep->num_pseudo_regs);
113 linux_init_abi (info, gdbarch);
115 set_solib_svr4_fetch_link_map_offsets
116 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
118 set_gdbarch_gdb_signal_from_target (gdbarch,
119 xtensa_linux_gdb_signal_from_target);
120 set_gdbarch_gdb_signal_to_target (gdbarch,
121 xtensa_linux_gdb_signal_to_target);
123 /* Enable TLS support. */
124 set_gdbarch_fetch_tls_load_module_address (gdbarch,
125 svr4_fetch_objfile_link_map);
129 _initialize_xtensa_linux_tdep (void)
131 gdbarch_register_osabi (bfd_arch_xtensa, bfd_mach_xtensa, GDB_OSABI_LINUX,
132 xtensa_linux_init_abi);