Simplify DAP make_source callers
[binutils-gdb.git] / gdb / obsd-tdep.c
blob5142984bc84fcb1b8f4c1e8127e64dc284acdb38
1 /* Target-dependent code for OpenBSD.
3 Copyright (C) 2005-2024 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 "auxv.h"
21 #include "frame.h"
22 #include "symtab.h"
23 #include "objfiles.h"
25 #include "obsd-tdep.h"
27 CORE_ADDR
28 obsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
30 struct bound_minimal_symbol msym;
32 msym = lookup_minimal_symbol("_dl_bind", NULL, NULL);
33 if (msym.minsym && msym.value_address () == pc)
34 return frame_unwind_caller_pc (get_current_frame ());
35 else
36 return find_solib_trampoline_target (get_current_frame (), pc);
39 /* OpenBSD signal numbers. From <sys/signal.h>. */
41 enum
43 OBSD_SIGHUP = 1,
44 OBSD_SIGINT = 2,
45 OBSD_SIGQUIT = 3,
46 OBSD_SIGILL = 4,
47 OBSD_SIGTRAP = 5,
48 OBSD_SIGABRT = 6,
49 OBSD_SIGEMT = 7,
50 OBSD_SIGFPE = 8,
51 OBSD_SIGKILL = 9,
52 OBSD_SIGBUS = 10,
53 OBSD_SIGSEGV = 11,
54 OBSD_SIGSYS = 12,
55 OBSD_SIGPIPE = 13,
56 OBSD_SIGALRM = 14,
57 OBSD_SIGTERM = 15,
58 OBSD_SIGURG = 16,
59 OBSD_SIGSTOP = 17,
60 OBSD_SIGTSTP = 18,
61 OBSD_SIGCONT = 19,
62 OBSD_SIGCHLD = 20,
63 OBSD_SIGTTIN = 21,
64 OBSD_SIGTTOU = 22,
65 OBSD_SIGIO = 23,
66 OBSD_SIGXCPU = 24,
67 OBSD_SIGXFSZ = 25,
68 OBSD_SIGVTALRM = 26,
69 OBSD_SIGPROF = 27,
70 OBSD_SIGWINCH = 28,
71 OBSD_SIGINFO = 29,
72 OBSD_SIGUSR1 = 30,
73 OBSD_SIGUSR2 = 31,
74 OBSD_SIGTHR = 32,
77 /* Implement the "gdb_signal_from_target" gdbarch method. */
79 static enum gdb_signal
80 obsd_gdb_signal_from_target (struct gdbarch *gdbarch, int signal)
82 switch (signal)
84 case 0:
85 return GDB_SIGNAL_0;
87 case OBSD_SIGHUP:
88 return GDB_SIGNAL_HUP;
90 case OBSD_SIGINT:
91 return GDB_SIGNAL_INT;
93 case OBSD_SIGQUIT:
94 return GDB_SIGNAL_QUIT;
96 case OBSD_SIGILL:
97 return GDB_SIGNAL_ILL;
99 case OBSD_SIGTRAP:
100 return GDB_SIGNAL_TRAP;
102 case OBSD_SIGABRT:
103 return GDB_SIGNAL_ABRT;
105 case OBSD_SIGEMT:
106 return GDB_SIGNAL_EMT;
108 case OBSD_SIGFPE:
109 return GDB_SIGNAL_FPE;
111 case OBSD_SIGKILL:
112 return GDB_SIGNAL_KILL;
114 case OBSD_SIGBUS:
115 return GDB_SIGNAL_BUS;
117 case OBSD_SIGSEGV:
118 return GDB_SIGNAL_SEGV;
120 case OBSD_SIGSYS:
121 return GDB_SIGNAL_SYS;
123 case OBSD_SIGPIPE:
124 return GDB_SIGNAL_PIPE;
126 case OBSD_SIGALRM:
127 return GDB_SIGNAL_ALRM;
129 case OBSD_SIGTERM:
130 return GDB_SIGNAL_TERM;
132 case OBSD_SIGURG:
133 return GDB_SIGNAL_URG;
135 case OBSD_SIGSTOP:
136 return GDB_SIGNAL_STOP;
138 case OBSD_SIGTSTP:
139 return GDB_SIGNAL_TSTP;
141 case OBSD_SIGCONT:
142 return GDB_SIGNAL_CONT;
144 case OBSD_SIGCHLD:
145 return GDB_SIGNAL_CHLD;
147 case OBSD_SIGTTIN:
148 return GDB_SIGNAL_TTIN;
150 case OBSD_SIGTTOU:
151 return GDB_SIGNAL_TTOU;
153 case OBSD_SIGIO:
154 return GDB_SIGNAL_IO;
156 case OBSD_SIGXCPU:
157 return GDB_SIGNAL_XCPU;
159 case OBSD_SIGXFSZ:
160 return GDB_SIGNAL_XFSZ;
162 case OBSD_SIGVTALRM:
163 return GDB_SIGNAL_VTALRM;
165 case OBSD_SIGPROF:
166 return GDB_SIGNAL_PROF;
168 case OBSD_SIGWINCH:
169 return GDB_SIGNAL_WINCH;
171 case OBSD_SIGINFO:
172 return GDB_SIGNAL_INFO;
174 case OBSD_SIGUSR1:
175 return GDB_SIGNAL_USR1;
177 case OBSD_SIGUSR2:
178 return GDB_SIGNAL_USR2;
181 return GDB_SIGNAL_UNKNOWN;
184 /* Implement the "gdb_signal_to_target" gdbarch method. */
186 static int
187 obsd_gdb_signal_to_target (struct gdbarch *gdbarch,
188 enum gdb_signal signal)
190 switch (signal)
192 case GDB_SIGNAL_0:
193 return 0;
195 case GDB_SIGNAL_HUP:
196 return OBSD_SIGHUP;
198 case GDB_SIGNAL_INT:
199 return OBSD_SIGINT;
201 case GDB_SIGNAL_QUIT:
202 return OBSD_SIGQUIT;
204 case GDB_SIGNAL_ILL:
205 return OBSD_SIGILL;
207 case GDB_SIGNAL_TRAP:
208 return OBSD_SIGTRAP;
210 case GDB_SIGNAL_ABRT:
211 return OBSD_SIGABRT;
213 case GDB_SIGNAL_EMT:
214 return OBSD_SIGEMT;
216 case GDB_SIGNAL_FPE:
217 return OBSD_SIGFPE;
219 case GDB_SIGNAL_KILL:
220 return OBSD_SIGKILL;
222 case GDB_SIGNAL_BUS:
223 return OBSD_SIGBUS;
225 case GDB_SIGNAL_SEGV:
226 return OBSD_SIGSEGV;
228 case GDB_SIGNAL_SYS:
229 return OBSD_SIGSYS;
231 case GDB_SIGNAL_PIPE:
232 return OBSD_SIGPIPE;
234 case GDB_SIGNAL_ALRM:
235 return OBSD_SIGALRM;
237 case GDB_SIGNAL_TERM:
238 return OBSD_SIGTERM;
240 case GDB_SIGNAL_URG:
241 return OBSD_SIGURG;
243 case GDB_SIGNAL_STOP:
244 return OBSD_SIGSTOP;
246 case GDB_SIGNAL_TSTP:
247 return OBSD_SIGTSTP;
249 case GDB_SIGNAL_CONT:
250 return OBSD_SIGCONT;
252 case GDB_SIGNAL_CHLD:
253 return OBSD_SIGCHLD;
255 case GDB_SIGNAL_TTIN:
256 return OBSD_SIGTTIN;
258 case GDB_SIGNAL_TTOU:
259 return OBSD_SIGTTOU;
261 case GDB_SIGNAL_IO:
262 return OBSD_SIGIO;
264 case GDB_SIGNAL_XCPU:
265 return OBSD_SIGXCPU;
267 case GDB_SIGNAL_XFSZ:
268 return OBSD_SIGXFSZ;
270 case GDB_SIGNAL_VTALRM:
271 return OBSD_SIGVTALRM;
273 case GDB_SIGNAL_PROF:
274 return OBSD_SIGPROF;
276 case GDB_SIGNAL_WINCH:
277 return OBSD_SIGWINCH;
279 case GDB_SIGNAL_USR1:
280 return OBSD_SIGUSR1;
282 case GDB_SIGNAL_USR2:
283 return OBSD_SIGUSR2;
285 case GDB_SIGNAL_INFO:
286 return OBSD_SIGINFO;
289 return -1;
292 void
293 obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
295 set_gdbarch_gdb_signal_from_target (gdbarch,
296 obsd_gdb_signal_from_target);
297 set_gdbarch_gdb_signal_to_target (gdbarch,
298 obsd_gdb_signal_to_target);
300 set_gdbarch_auxv_parse (gdbarch, svr4_auxv_parse);