Rename gdb/ChangeLog to gdb/ChangeLog-2021
[binutils-gdb.git] / gdb / obsd-tdep.c
blobd3d74a2c5dabe8f4784310e57ccf16093d2e20e8
1 /* Target-dependent code for OpenBSD.
3 Copyright (C) 2005-2021 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/>. */
20 #include "defs.h"
21 #include "auxv.h"
22 #include "frame.h"
23 #include "symtab.h"
24 #include "objfiles.h"
26 #include "obsd-tdep.h"
28 CORE_ADDR
29 obsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
31 struct bound_minimal_symbol msym;
33 msym = lookup_minimal_symbol("_dl_bind", NULL, NULL);
34 if (msym.minsym && BMSYMBOL_VALUE_ADDRESS (msym) == pc)
35 return frame_unwind_caller_pc (get_current_frame ());
36 else
37 return find_solib_trampoline_target (get_current_frame (), pc);
40 /* OpenBSD signal numbers. From <sys/signal.h>. */
42 enum
44 OBSD_SIGHUP = 1,
45 OBSD_SIGINT = 2,
46 OBSD_SIGQUIT = 3,
47 OBSD_SIGILL = 4,
48 OBSD_SIGTRAP = 5,
49 OBSD_SIGABRT = 6,
50 OBSD_SIGEMT = 7,
51 OBSD_SIGFPE = 8,
52 OBSD_SIGKILL = 9,
53 OBSD_SIGBUS = 10,
54 OBSD_SIGSEGV = 11,
55 OBSD_SIGSYS = 12,
56 OBSD_SIGPIPE = 13,
57 OBSD_SIGALRM = 14,
58 OBSD_SIGTERM = 15,
59 OBSD_SIGURG = 16,
60 OBSD_SIGSTOP = 17,
61 OBSD_SIGTSTP = 18,
62 OBSD_SIGCONT = 19,
63 OBSD_SIGCHLD = 20,
64 OBSD_SIGTTIN = 21,
65 OBSD_SIGTTOU = 22,
66 OBSD_SIGIO = 23,
67 OBSD_SIGXCPU = 24,
68 OBSD_SIGXFSZ = 25,
69 OBSD_SIGVTALRM = 26,
70 OBSD_SIGPROF = 27,
71 OBSD_SIGWINCH = 28,
72 OBSD_SIGINFO = 29,
73 OBSD_SIGUSR1 = 30,
74 OBSD_SIGUSR2 = 31,
75 OBSD_SIGTHR = 32,
78 /* Implement the "gdb_signal_from_target" gdbarch method. */
80 static enum gdb_signal
81 obsd_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
83 switch (signal)
85 case 0:
86 return GDB_SIGNAL_0;
88 case OBSD_SIGHUP:
89 return GDB_SIGNAL_HUP;
91 case OBSD_SIGINT:
92 return GDB_SIGNAL_INT;
94 case OBSD_SIGQUIT:
95 return GDB_SIGNAL_QUIT;
97 case OBSD_SIGILL:
98 return GDB_SIGNAL_ILL;
100 case OBSD_SIGTRAP:
101 return GDB_SIGNAL_TRAP;
103 case OBSD_SIGABRT:
104 return GDB_SIGNAL_ABRT;
106 case OBSD_SIGEMT:
107 return GDB_SIGNAL_EMT;
109 case OBSD_SIGFPE:
110 return GDB_SIGNAL_FPE;
112 case OBSD_SIGKILL:
113 return GDB_SIGNAL_KILL;
115 case OBSD_SIGBUS:
116 return GDB_SIGNAL_BUS;
118 case OBSD_SIGSEGV:
119 return GDB_SIGNAL_SEGV;
121 case OBSD_SIGSYS:
122 return GDB_SIGNAL_SYS;
124 case OBSD_SIGPIPE:
125 return GDB_SIGNAL_PIPE;
127 case OBSD_SIGALRM:
128 return GDB_SIGNAL_ALRM;
130 case OBSD_SIGTERM:
131 return GDB_SIGNAL_TERM;
133 case OBSD_SIGURG:
134 return GDB_SIGNAL_URG;
136 case OBSD_SIGSTOP:
137 return GDB_SIGNAL_STOP;
139 case OBSD_SIGTSTP:
140 return GDB_SIGNAL_TSTP;
142 case OBSD_SIGCONT:
143 return GDB_SIGNAL_CONT;
145 case OBSD_SIGCHLD:
146 return GDB_SIGNAL_CHLD;
148 case OBSD_SIGTTIN:
149 return GDB_SIGNAL_TTIN;
151 case OBSD_SIGTTOU:
152 return GDB_SIGNAL_TTOU;
154 case OBSD_SIGIO:
155 return GDB_SIGNAL_IO;
157 case OBSD_SIGXCPU:
158 return GDB_SIGNAL_XCPU;
160 case OBSD_SIGXFSZ:
161 return GDB_SIGNAL_XFSZ;
163 case OBSD_SIGVTALRM:
164 return GDB_SIGNAL_VTALRM;
166 case OBSD_SIGPROF:
167 return GDB_SIGNAL_PROF;
169 case OBSD_SIGWINCH:
170 return GDB_SIGNAL_WINCH;
172 case OBSD_SIGINFO:
173 return GDB_SIGNAL_INFO;
175 case OBSD_SIGUSR1:
176 return GDB_SIGNAL_USR1;
178 case OBSD_SIGUSR2:
179 return GDB_SIGNAL_USR2;
182 return GDB_SIGNAL_UNKNOWN;
185 /* Implement the "gdb_signal_to_target" gdbarch method. */
187 static int
188 obsd_gdb_signal_to_target (struct gdbarch *gdbarch,
189 enum gdb_signal signal)
191 switch (signal)
193 case GDB_SIGNAL_0:
194 return 0;
196 case GDB_SIGNAL_HUP:
197 return OBSD_SIGHUP;
199 case GDB_SIGNAL_INT:
200 return OBSD_SIGINT;
202 case GDB_SIGNAL_QUIT:
203 return OBSD_SIGQUIT;
205 case GDB_SIGNAL_ILL:
206 return OBSD_SIGILL;
208 case GDB_SIGNAL_TRAP:
209 return OBSD_SIGTRAP;
211 case GDB_SIGNAL_ABRT:
212 return OBSD_SIGABRT;
214 case GDB_SIGNAL_EMT:
215 return OBSD_SIGEMT;
217 case GDB_SIGNAL_FPE:
218 return OBSD_SIGFPE;
220 case GDB_SIGNAL_KILL:
221 return OBSD_SIGKILL;
223 case GDB_SIGNAL_BUS:
224 return OBSD_SIGBUS;
226 case GDB_SIGNAL_SEGV:
227 return OBSD_SIGSEGV;
229 case GDB_SIGNAL_SYS:
230 return OBSD_SIGSYS;
232 case GDB_SIGNAL_PIPE:
233 return OBSD_SIGPIPE;
235 case GDB_SIGNAL_ALRM:
236 return OBSD_SIGALRM;
238 case GDB_SIGNAL_TERM:
239 return OBSD_SIGTERM;
241 case GDB_SIGNAL_URG:
242 return OBSD_SIGURG;
244 case GDB_SIGNAL_STOP:
245 return OBSD_SIGSTOP;
247 case GDB_SIGNAL_TSTP:
248 return OBSD_SIGTSTP;
250 case GDB_SIGNAL_CONT:
251 return OBSD_SIGCONT;
253 case GDB_SIGNAL_CHLD:
254 return OBSD_SIGCHLD;
256 case GDB_SIGNAL_TTIN:
257 return OBSD_SIGTTIN;
259 case GDB_SIGNAL_TTOU:
260 return OBSD_SIGTTOU;
262 case GDB_SIGNAL_IO:
263 return OBSD_SIGIO;
265 case GDB_SIGNAL_XCPU:
266 return OBSD_SIGXCPU;
268 case GDB_SIGNAL_XFSZ:
269 return OBSD_SIGXFSZ;
271 case GDB_SIGNAL_VTALRM:
272 return OBSD_SIGVTALRM;
274 case GDB_SIGNAL_PROF:
275 return OBSD_SIGPROF;
277 case GDB_SIGNAL_WINCH:
278 return OBSD_SIGWINCH;
280 case GDB_SIGNAL_USR1:
281 return OBSD_SIGUSR1;
283 case GDB_SIGNAL_USR2:
284 return OBSD_SIGUSR2;
286 case GDB_SIGNAL_INFO:
287 return OBSD_SIGINFO;
290 return -1;
293 void
294 obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
296 set_gdbarch_gdb_signal_from_target (gdbarch,
297 obsd_gdb_signal_from_target);
298 set_gdbarch_gdb_signal_to_target (gdbarch,
299 obsd_gdb_signal_to_target);
301 set_gdbarch_auxv_parse (gdbarch, svr4_auxv_parse);