Update gnulib to current upstream master
[deliverable/binutils-gdb.git] / gdb / xtensa-linux-tdep.c
CommitLineData
94a0e877
MG
1/* Target-dependent code for GNU/Linux on Xtensa processors.
2
e2882c85 3 Copyright (C) 2007-2018 Free Software Foundation, Inc.
94a0e877
MG
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"
37d9e062 21#include "xtensa-tdep.h"
94a0e877 22#include "osabi.h"
a5ee0f0c 23#include "linux-tdep.h"
94a0e877
MG
24#include "solib-svr4.h"
25#include "symtab.h"
26
eb14d406
SDJ
27/* This enum represents the signals' numbers on the Xtensa
28 architecture. It just contains the signal definitions which are
29 different from the generic implementation.
30
31 It is derived from the file <arch/xtensa/include/uapi/asm/signal.h>,
32 from the Linux kernel tree. */
33
34enum
35 {
36 XTENSA_LINUX_SIGRTMIN = 32,
37 XTENSA_LINUX_SIGRTMAX = 63,
38 };
39
40/* Implementation of `gdbarch_gdb_signal_from_target', as defined in
41 gdbarch.h. */
42
43static enum gdb_signal
44xtensa_linux_gdb_signal_from_target (struct gdbarch *gdbarch,
45 int signal)
46{
47 if (signal >= XTENSA_LINUX_SIGRTMIN && signal <= XTENSA_LINUX_SIGRTMAX)
48 {
49 int offset = signal - XTENSA_LINUX_SIGRTMIN;
50
51 if (offset == 0)
52 return GDB_SIGNAL_REALTIME_32;
53 else
54 return (enum gdb_signal) (offset - 1
55 + (int) GDB_SIGNAL_REALTIME_33);
56 }
57 else if (signal > XTENSA_LINUX_SIGRTMAX)
58 return GDB_SIGNAL_UNKNOWN;
59
60 return linux_gdb_signal_from_target (gdbarch, signal);
61}
62
63/* Implementation of `gdbarch_gdb_signal_to_target', as defined in
64 gdbarch.h. */
65
66static int
67xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
68 enum gdb_signal signal)
69{
70 switch (signal)
71 {
72 /* GDB_SIGNAL_REALTIME_32 is not continuous in <gdb/signals.def>,
73 therefore we have to handle it here. */
74 case GDB_SIGNAL_REALTIME_32:
75 return XTENSA_LINUX_SIGRTMIN;
76
77 /* GDB_SIGNAL_REALTIME_64 is not valid on Xtensa. */
78 case GDB_SIGNAL_REALTIME_64:
79 return -1;
80 }
81
82 /* GDB_SIGNAL_REALTIME_33 to _63 are continuous.
83
84 Xtensa does not have _64. */
85 if (signal >= GDB_SIGNAL_REALTIME_33
86 && signal <= GDB_SIGNAL_REALTIME_63)
87 {
88 int offset = signal - GDB_SIGNAL_REALTIME_33;
89
90 return XTENSA_LINUX_SIGRTMIN + 1 + offset;
91 }
92
93 return linux_gdb_signal_to_target (gdbarch, signal);
94}
95
94a0e877
MG
96/* OS specific initialization of gdbarch. */
97
98static void
99xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
100{
37d9e062
MF
101 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
102
103 if (tdep->num_nopriv_regs < tdep->num_regs)
104 tdep->num_regs = tdep->num_nopriv_regs;
105
a5ee0f0c
PA
106 linux_init_abi (info, gdbarch);
107
94a0e877
MG
108 set_solib_svr4_fetch_link_map_offsets
109 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
eb14d406
SDJ
110
111 set_gdbarch_gdb_signal_from_target (gdbarch,
112 xtensa_linux_gdb_signal_from_target);
113 set_gdbarch_gdb_signal_to_target (gdbarch,
114 xtensa_linux_gdb_signal_to_target);
40045d91
MF
115
116 /* Enable TLS support. */
117 set_gdbarch_fetch_tls_load_module_address (gdbarch,
118 svr4_fetch_objfile_link_map);
94a0e877
MG
119}
120
121void
122_initialize_xtensa_linux_tdep (void)
123{
124 gdbarch_register_osabi (bfd_arch_xtensa, bfd_mach_xtensa, GDB_OSABI_LINUX,
125 xtensa_linux_init_abi);
126}
This page took 1.161722 seconds and 4 git commands to generate.