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/>. */
24 #include "solib-svr4.h"
25 #include "nbsd-tdep.h"
29 /* FIXME: kettenis/20060115: We should really eliminate the next two
30 functions completely. */
32 struct link_map_offsets
*
33 nbsd_ilp32_solib_svr4_fetch_link_map_offsets (void)
35 return svr4_ilp32_fetch_link_map_offsets ();
38 struct link_map_offsets
*
39 nbsd_lp64_solib_svr4_fetch_link_map_offsets (void)
41 return svr4_lp64_fetch_link_map_offsets ();
45 nbsd_pc_in_sigtramp (CORE_ADDR pc
, const char *func_name
)
47 /* Check for libc-provided signal trampoline. All such trampolines
48 have function names which begin with "__sigtramp". */
50 return (func_name
!= NULL
51 && startswith (func_name
, "__sigtramp"));
54 /* This enum is derived from NETBSD's <sys/signal.h>. */
94 /* Implement the "gdb_signal_from_target" gdbarch method. */
96 static enum gdb_signal
97 nbsd_gdb_signal_from_target (struct gdbarch
*gdbarch
, int signal
)
105 return GDB_SIGNAL_HUP
;
108 return GDB_SIGNAL_INT
;
111 return GDB_SIGNAL_QUIT
;
114 return GDB_SIGNAL_ILL
;
117 return GDB_SIGNAL_TRAP
;
120 return GDB_SIGNAL_ABRT
;
123 return GDB_SIGNAL_EMT
;
126 return GDB_SIGNAL_FPE
;
129 return GDB_SIGNAL_KILL
;
132 return GDB_SIGNAL_BUS
;
135 return GDB_SIGNAL_SEGV
;
138 return GDB_SIGNAL_SYS
;
141 return GDB_SIGNAL_PIPE
;
144 return GDB_SIGNAL_ALRM
;
147 return GDB_SIGNAL_TERM
;
150 return GDB_SIGNAL_URG
;
153 return GDB_SIGNAL_STOP
;
156 return GDB_SIGNAL_TSTP
;
159 return GDB_SIGNAL_CONT
;
162 return GDB_SIGNAL_CHLD
;
165 return GDB_SIGNAL_TTIN
;
168 return GDB_SIGNAL_TTOU
;
171 return GDB_SIGNAL_IO
;
174 return GDB_SIGNAL_XCPU
;
177 return GDB_SIGNAL_XFSZ
;
180 return GDB_SIGNAL_VTALRM
;
183 return GDB_SIGNAL_PROF
;
186 return GDB_SIGNAL_WINCH
;
189 return GDB_SIGNAL_INFO
;
192 return GDB_SIGNAL_USR1
;
195 return GDB_SIGNAL_USR2
;
198 return GDB_SIGNAL_PWR
;
200 /* SIGRTMIN and SIGRTMAX are not continuous in <gdb/signals.def>,
201 therefore we have to handle them here. */
203 return GDB_SIGNAL_REALTIME_33
;
206 return GDB_SIGNAL_REALTIME_63
;
209 if (signal
>= NBSD_SIGRTMIN
+ 1 && signal
<= NBSD_SIGRTMAX
- 1)
211 int offset
= signal
- NBSD_SIGRTMIN
+ 1;
213 return (enum gdb_signal
) ((int) GDB_SIGNAL_REALTIME_34
+ offset
);
216 return GDB_SIGNAL_UNKNOWN
;
219 /* Implement the "gdb_signal_to_target" gdbarch method. */
222 nbsd_gdb_signal_to_target (struct gdbarch
*gdbarch
,
223 enum gdb_signal signal
)
236 case GDB_SIGNAL_QUIT
:
242 case GDB_SIGNAL_TRAP
:
245 case GDB_SIGNAL_ABRT
:
254 case GDB_SIGNAL_KILL
:
260 case GDB_SIGNAL_SEGV
:
266 case GDB_SIGNAL_PIPE
:
269 case GDB_SIGNAL_ALRM
:
272 case GDB_SIGNAL_TERM
:
278 case GDB_SIGNAL_TSTP
:
281 case GDB_SIGNAL_CONT
:
284 case GDB_SIGNAL_CHLD
:
287 case GDB_SIGNAL_TTIN
:
290 case GDB_SIGNAL_TTOU
:
296 case GDB_SIGNAL_XCPU
:
299 case GDB_SIGNAL_XFSZ
:
302 case GDB_SIGNAL_VTALRM
:
303 return NBSD_SIGVTALRM
;
305 case GDB_SIGNAL_PROF
:
308 case GDB_SIGNAL_WINCH
:
309 return NBSD_SIGWINCH
;
311 case GDB_SIGNAL_INFO
:
314 case GDB_SIGNAL_USR1
:
317 case GDB_SIGNAL_USR2
:
323 /* GDB_SIGNAL_REALTIME_33 is not continuous in <gdb/signals.def>,
324 therefore we have to handle it here. */
325 case GDB_SIGNAL_REALTIME_33
:
326 return NBSD_SIGRTMIN
;
328 /* Same comment applies to _64. */
329 case GDB_SIGNAL_REALTIME_63
:
330 return NBSD_SIGRTMAX
;
333 if (signal
>= GDB_SIGNAL_REALTIME_34
334 && signal
<= GDB_SIGNAL_REALTIME_62
)
336 int offset
= signal
- GDB_SIGNAL_REALTIME_32
;
338 return NBSD_SIGRTMIN
+ 1 + offset
;
344 /* Shared library resolver handling. */
347 nbsd_skip_solib_resolver (struct gdbarch
*gdbarch
, CORE_ADDR pc
)
349 struct bound_minimal_symbol msym
;
351 msym
= lookup_minimal_symbol ("_rtld_bind_start", NULL
, NULL
);
352 if (msym
.minsym
&& BMSYMBOL_VALUE_ADDRESS (msym
) == pc
)
353 return frame_unwind_caller_pc (get_current_frame ());
355 return find_solib_trampoline_target (get_current_frame (), pc
);
358 /* See nbsd-tdep.h. */
361 nbsd_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
363 set_gdbarch_gdb_signal_from_target (gdbarch
, nbsd_gdb_signal_from_target
);
364 set_gdbarch_gdb_signal_to_target (gdbarch
, nbsd_gdb_signal_to_target
);
365 set_gdbarch_skip_solib_resolver (gdbarch
, nbsd_skip_solib_resolver
);
366 set_gdbarch_auxv_parse (gdbarch
, svr4_auxv_parse
);