1 /* Target-dependent code for OpenBSD.
3 Copyright (C) 2005-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/>. */
25 #include "obsd-tdep.h"
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 && BMSYMBOL_VALUE_ADDRESS (msym) == pc)
34 return frame_unwind_caller_pc (get_current_frame ());
36 return find_solib_trampoline_target (get_current_frame (), pc);
39 /* OpenBSD signal numbers. From <sys/signal.h>. */
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)
88 return GDB_SIGNAL_HUP;
91 return GDB_SIGNAL_INT;
94 return GDB_SIGNAL_QUIT;
97 return GDB_SIGNAL_ILL;
100 return GDB_SIGNAL_TRAP;
103 return GDB_SIGNAL_ABRT;
106 return GDB_SIGNAL_EMT;
109 return GDB_SIGNAL_FPE;
112 return GDB_SIGNAL_KILL;
115 return GDB_SIGNAL_BUS;
118 return GDB_SIGNAL_SEGV;
121 return GDB_SIGNAL_SYS;
124 return GDB_SIGNAL_PIPE;
127 return GDB_SIGNAL_ALRM;
130 return GDB_SIGNAL_TERM;
133 return GDB_SIGNAL_URG;
136 return GDB_SIGNAL_STOP;
139 return GDB_SIGNAL_TSTP;
142 return GDB_SIGNAL_CONT;
145 return GDB_SIGNAL_CHLD;
148 return GDB_SIGNAL_TTIN;
151 return GDB_SIGNAL_TTOU;
154 return GDB_SIGNAL_IO;
157 return GDB_SIGNAL_XCPU;
160 return GDB_SIGNAL_XFSZ;
163 return GDB_SIGNAL_VTALRM;
166 return GDB_SIGNAL_PROF;
169 return GDB_SIGNAL_WINCH;
172 return GDB_SIGNAL_INFO;
175 return GDB_SIGNAL_USR1;
178 return GDB_SIGNAL_USR2;
181 return GDB_SIGNAL_UNKNOWN;
184 /* Implement the "gdb_signal_to_target" gdbarch method. */
187 obsd_gdb_signal_to_target (struct gdbarch *gdbarch,
188 enum gdb_signal signal)
201 case GDB_SIGNAL_QUIT:
207 case GDB_SIGNAL_TRAP:
210 case GDB_SIGNAL_ABRT:
219 case GDB_SIGNAL_KILL:
225 case GDB_SIGNAL_SEGV:
231 case GDB_SIGNAL_PIPE:
234 case GDB_SIGNAL_ALRM:
237 case GDB_SIGNAL_TERM:
243 case GDB_SIGNAL_STOP:
246 case GDB_SIGNAL_TSTP:
249 case GDB_SIGNAL_CONT:
252 case GDB_SIGNAL_CHLD:
255 case GDB_SIGNAL_TTIN:
258 case GDB_SIGNAL_TTOU:
264 case GDB_SIGNAL_XCPU:
267 case GDB_SIGNAL_XFSZ:
270 case GDB_SIGNAL_VTALRM:
271 return OBSD_SIGVTALRM;
273 case GDB_SIGNAL_PROF:
276 case GDB_SIGNAL_WINCH:
277 return OBSD_SIGWINCH;
279 case GDB_SIGNAL_USR1:
282 case GDB_SIGNAL_USR2:
285 case GDB_SIGNAL_INFO:
293 obsd_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
294 gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
296 struct type *int_type = builtin_type (gdbarch)->builtin_int;
297 struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
298 const int sizeof_auxv_type = TYPE_LENGTH (int_type);
299 const int sizeof_auxv_val = TYPE_LENGTH (ptr_type);
300 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
301 gdb_byte *ptr = *readptr;
306 if (endptr - ptr < 2 * sizeof_auxv_val)
309 *typep = extract_unsigned_integer (ptr, sizeof_auxv_type, byte_order);
310 ptr += sizeof_auxv_val; /* Alignment. */
311 *valp = extract_unsigned_integer (ptr, sizeof_auxv_val, byte_order);
312 ptr += sizeof_auxv_val;
319 obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
321 set_gdbarch_gdb_signal_from_target (gdbarch,
322 obsd_gdb_signal_from_target);
323 set_gdbarch_gdb_signal_to_target (gdbarch,
324 obsd_gdb_signal_to_target);
326 /* Unlike Linux, OpenBSD actually follows the ELF standard. */
327 set_gdbarch_auxv_parse (gdbarch, obsd_auxv_parse);