1 /* Common target-dependent code for NetBSD systems.
3 Copyright (C) 2002-2020 Free Software Foundation, Inc.
5 Contributed by Wasabi Systems, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "solib-svr4.h"
24 #include "nbsd-tdep.h"
28 /* FIXME: kettenis/20060115: We should really eliminate the next two
29 functions completely. */
31 struct link_map_offsets
*
32 nbsd_ilp32_solib_svr4_fetch_link_map_offsets (void)
34 return svr4_ilp32_fetch_link_map_offsets ();
37 struct link_map_offsets
*
38 nbsd_lp64_solib_svr4_fetch_link_map_offsets (void)
40 return svr4_lp64_fetch_link_map_offsets ();
44 nbsd_pc_in_sigtramp (CORE_ADDR pc
, const char *func_name
)
46 /* Check for libc-provided signal trampoline. All such trampolines
47 have function names which begin with "__sigtramp". */
49 return (func_name
!= NULL
50 && startswith (func_name
, "__sigtramp"));
53 /* This enum is derived from NETBSD's <sys/signal.h>. */
93 /* Implement the "gdb_signal_from_target" gdbarch method. */
95 static enum gdb_signal
96 nbsd_gdb_signal_from_target (struct gdbarch
*gdbarch
, int signal
)
104 return GDB_SIGNAL_HUP
;
107 return GDB_SIGNAL_INT
;
110 return GDB_SIGNAL_QUIT
;
113 return GDB_SIGNAL_ILL
;
116 return GDB_SIGNAL_TRAP
;
119 return GDB_SIGNAL_ABRT
;
122 return GDB_SIGNAL_EMT
;
125 return GDB_SIGNAL_FPE
;
128 return GDB_SIGNAL_KILL
;
131 return GDB_SIGNAL_BUS
;
134 return GDB_SIGNAL_SEGV
;
137 return GDB_SIGNAL_SYS
;
140 return GDB_SIGNAL_PIPE
;
143 return GDB_SIGNAL_ALRM
;
146 return GDB_SIGNAL_TERM
;
149 return GDB_SIGNAL_URG
;
152 return GDB_SIGNAL_STOP
;
155 return GDB_SIGNAL_TSTP
;
158 return GDB_SIGNAL_CONT
;
161 return GDB_SIGNAL_CHLD
;
164 return GDB_SIGNAL_TTIN
;
167 return GDB_SIGNAL_TTOU
;
170 return GDB_SIGNAL_IO
;
173 return GDB_SIGNAL_XCPU
;
176 return GDB_SIGNAL_XFSZ
;
179 return GDB_SIGNAL_VTALRM
;
182 return GDB_SIGNAL_PROF
;
185 return GDB_SIGNAL_WINCH
;
188 return GDB_SIGNAL_INFO
;
191 return GDB_SIGNAL_USR1
;
194 return GDB_SIGNAL_USR2
;
197 return GDB_SIGNAL_PWR
;
199 /* SIGRTMIN and SIGRTMAX are not continuous in <gdb/signals.def>,
200 therefore we have to handle them here. */
202 return GDB_SIGNAL_REALTIME_33
;
205 return GDB_SIGNAL_REALTIME_63
;
208 if (signal
>= NBSD_SIGRTMIN
+ 1 && signal
<= NBSD_SIGRTMAX
- 1)
210 int offset
= signal
- NBSD_SIGRTMIN
+ 1;
212 return (enum gdb_signal
) ((int) GDB_SIGNAL_REALTIME_34
+ offset
);
215 return GDB_SIGNAL_UNKNOWN
;
218 /* Implement the "gdb_signal_to_target" gdbarch method. */
221 nbsd_gdb_signal_to_target (struct gdbarch
*gdbarch
,
222 enum gdb_signal signal
)
235 case GDB_SIGNAL_QUIT
:
241 case GDB_SIGNAL_TRAP
:
244 case GDB_SIGNAL_ABRT
:
253 case GDB_SIGNAL_KILL
:
259 case GDB_SIGNAL_SEGV
:
265 case GDB_SIGNAL_PIPE
:
268 case GDB_SIGNAL_ALRM
:
271 case GDB_SIGNAL_TERM
:
277 case GDB_SIGNAL_TSTP
:
280 case GDB_SIGNAL_CONT
:
283 case GDB_SIGNAL_CHLD
:
286 case GDB_SIGNAL_TTIN
:
289 case GDB_SIGNAL_TTOU
:
295 case GDB_SIGNAL_XCPU
:
298 case GDB_SIGNAL_XFSZ
:
301 case GDB_SIGNAL_VTALRM
:
302 return NBSD_SIGVTALRM
;
304 case GDB_SIGNAL_PROF
:
307 case GDB_SIGNAL_WINCH
:
308 return NBSD_SIGWINCH
;
310 case GDB_SIGNAL_INFO
:
313 case GDB_SIGNAL_USR1
:
316 case GDB_SIGNAL_USR2
:
322 /* GDB_SIGNAL_REALTIME_33 is not continuous in <gdb/signals.def>,
323 therefore we have to handle it here. */
324 case GDB_SIGNAL_REALTIME_33
:
325 return NBSD_SIGRTMIN
;
327 /* Same comment applies to _64. */
328 case GDB_SIGNAL_REALTIME_63
:
329 return NBSD_SIGRTMAX
;
332 if (signal
>= GDB_SIGNAL_REALTIME_34
333 && signal
<= GDB_SIGNAL_REALTIME_62
)
335 int offset
= signal
- GDB_SIGNAL_REALTIME_32
;
337 return NBSD_SIGRTMIN
+ 1 + offset
;
343 /* Shared library resolver handling. */
346 nbsd_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
348 struct bound_minimal_symbol msym
;
350 msym
= lookup_minimal_symbol ("_rtld_bind_start", NULL
, NULL
);
351 if (msym
.minsym
&& BMSYMBOL_VALUE_ADDRESS (msym
) == pc
)
352 return frame_unwind_caller_pc (get_current_frame ());
354 return find_solib_trampoline_target (get_current_frame (), pc
);
357 /* See nbsd-tdep.h. */
360 nbsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
362 set_gdbarch_gdb_signal_from_target (gdbarch
, nbsd_gdb_signal_from_target
);
363 set_gdbarch_gdb_signal_to_target (gdbarch
, nbsd_gdb_signal_to_target
);
364 set_gdbarch_skip_solib_resolver (gdbarch
, nbsd_skip_solib_resolver
);