]>
Commit | Line | Data |
---|---|---|
54fe9172 MK |
1 | /* Target-dependent code for NetBSD/sh. |
2 | ||
0b302171 | 3 | Copyright (C) 2002-2003, 2006-2012 Free Software Foundation, Inc. |
54fe9172 | 4 | |
13a38d45 JT |
5 | Contributed by Wasabi Systems, Inc. |
6 | ||
7 | This file is part of GDB. | |
8 | ||
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 | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
13a38d45 JT |
12 | (at your option) any later version. |
13 | ||
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. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
13a38d45 JT |
21 | |
22 | #include "defs.h" | |
23 | #include "gdbcore.h" | |
861fb77c | 24 | #include "regset.h" |
13a38d45 | 25 | #include "value.h" |
4be87837 | 26 | #include "osabi.h" |
13a38d45 | 27 | |
861fb77c | 28 | #include "gdb_string.h" |
9964235a | 29 | |
ab3b8126 | 30 | #include "sh-tdep.h" |
861fb77c | 31 | #include "solib-svr4.h" |
13a38d45 | 32 | |
c9ac0a72 | 33 | /* Convert a register number into an offset into a ptrace |
13a38d45 | 34 | register structure. */ |
c9ac0a72 | 35 | static const struct sh_corefile_regmap regmap[] = |
13a38d45 | 36 | { |
c9ac0a72 AS |
37 | {R0_REGNUM, 20 * 4}, |
38 | {R0_REGNUM + 1, 19 * 4}, | |
39 | {R0_REGNUM + 2, 18 * 4}, | |
40 | {R0_REGNUM + 3, 17 * 4}, | |
41 | {R0_REGNUM + 4, 16 * 4}, | |
42 | {R0_REGNUM + 5, 15 * 4}, | |
43 | {R0_REGNUM + 6, 14 * 4}, | |
44 | {R0_REGNUM + 7, 13 * 4}, | |
45 | {R0_REGNUM + 8, 12 * 4}, | |
46 | {R0_REGNUM + 9, 11 * 4}, | |
47 | {R0_REGNUM + 10, 10 * 4}, | |
48 | {R0_REGNUM + 11, 9 * 4}, | |
49 | {R0_REGNUM + 12, 8 * 4}, | |
50 | {R0_REGNUM + 13, 7 * 4}, | |
51 | {R0_REGNUM + 14, 6 * 4}, | |
52 | {R0_REGNUM + 15, 5 * 4}, | |
53 | {PC_REGNUM, 0 * 4}, | |
54 | {SR_REGNUM, 1 * 4}, | |
55 | {PR_REGNUM, 2 * 4}, | |
56 | {MACH_REGNUM, 3 * 4}, | |
57 | {MACL_REGNUM, 4 * 4}, | |
58 | {-1 /* Terminator. */, 0} | |
13a38d45 | 59 | }; |
861fb77c | 60 | \f |
13a38d45 JT |
61 | |
62 | static void | |
20cb8cda | 63 | shnbsd_init_abi (struct gdbarch_info info, |
13a38d45 JT |
64 | struct gdbarch *gdbarch) |
65 | { | |
c9ac0a72 AS |
66 | struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
67 | ||
68 | tdep->core_gregmap = (struct sh_corefile_regmap *)regmap; | |
861fb77c MK |
69 | |
70 | set_solib_svr4_fetch_link_map_offsets | |
71 | (gdbarch, svr4_ilp32_fetch_link_map_offsets); | |
72 | } | |
73 | \f | |
74 | ||
75 | /* OpenBSD uses uses the traditional NetBSD core file format, even for | |
76 | ports that use ELF. */ | |
77 | #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF | |
78 | ||
79 | static enum gdb_osabi | |
80 | shnbsd_core_osabi_sniffer (bfd *abfd) | |
81 | { | |
82 | if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) | |
83 | return GDB_OSABI_NETBSD_CORE; | |
84 | ||
85 | return GDB_OSABI_UNKNOWN; | |
13a38d45 JT |
86 | } |
87 | ||
63807e1d PA |
88 | /* Provide a prototype to silence -Wmissing-prototypes. */ |
89 | extern initialize_file_ftype _initialize_shnbsd_tdep; | |
90 | ||
13a38d45 | 91 | void |
20cb8cda | 92 | _initialize_shnbsd_tdep (void) |
13a38d45 | 93 | { |
861fb77c MK |
94 | /* BFD doesn't set a flavour for NetBSD style a.out core files. */ |
95 | gdbarch_register_osabi_sniffer (bfd_arch_sh, bfd_target_unknown_flavour, | |
96 | shnbsd_core_osabi_sniffer); | |
13a38d45 | 97 | |
05816f70 MK |
98 | gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD_ELF, |
99 | shnbsd_init_abi); | |
54fe9172 MK |
100 | gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_OPENBSD_ELF, |
101 | shnbsd_init_abi); | |
13a38d45 | 102 | } |