GDB (API)
|
00001 /* Target-dependent code for NetBSD/sh. 00002 00003 Copyright (C) 2002-2013 Free Software Foundation, Inc. 00004 00005 Contributed by Wasabi Systems, Inc. 00006 00007 This file is part of GDB. 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00021 00022 #include "defs.h" 00023 #include "gdbcore.h" 00024 #include "regset.h" 00025 #include "value.h" 00026 #include "osabi.h" 00027 00028 #include "gdb_string.h" 00029 00030 #include "sh-tdep.h" 00031 #include "solib-svr4.h" 00032 00033 /* Convert a register number into an offset into a ptrace 00034 register structure. */ 00035 static const struct sh_corefile_regmap regmap[] = 00036 { 00037 {R0_REGNUM, 20 * 4}, 00038 {R0_REGNUM + 1, 19 * 4}, 00039 {R0_REGNUM + 2, 18 * 4}, 00040 {R0_REGNUM + 3, 17 * 4}, 00041 {R0_REGNUM + 4, 16 * 4}, 00042 {R0_REGNUM + 5, 15 * 4}, 00043 {R0_REGNUM + 6, 14 * 4}, 00044 {R0_REGNUM + 7, 13 * 4}, 00045 {R0_REGNUM + 8, 12 * 4}, 00046 {R0_REGNUM + 9, 11 * 4}, 00047 {R0_REGNUM + 10, 10 * 4}, 00048 {R0_REGNUM + 11, 9 * 4}, 00049 {R0_REGNUM + 12, 8 * 4}, 00050 {R0_REGNUM + 13, 7 * 4}, 00051 {R0_REGNUM + 14, 6 * 4}, 00052 {R0_REGNUM + 15, 5 * 4}, 00053 {PC_REGNUM, 0 * 4}, 00054 {SR_REGNUM, 1 * 4}, 00055 {PR_REGNUM, 2 * 4}, 00056 {MACH_REGNUM, 3 * 4}, 00057 {MACL_REGNUM, 4 * 4}, 00058 {-1 /* Terminator. */, 0} 00059 }; 00060 00061 00062 static void 00063 shnbsd_init_abi (struct gdbarch_info info, 00064 struct gdbarch *gdbarch) 00065 { 00066 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); 00067 00068 tdep->core_gregmap = (struct sh_corefile_regmap *)regmap; 00069 00070 set_solib_svr4_fetch_link_map_offsets 00071 (gdbarch, svr4_ilp32_fetch_link_map_offsets); 00072 } 00073 00074 00075 /* OpenBSD uses uses the traditional NetBSD core file format, even for 00076 ports that use ELF. */ 00077 #define GDB_OSABI_NETBSD_CORE GDB_OSABI_OPENBSD_ELF 00078 00079 static enum gdb_osabi 00080 shnbsd_core_osabi_sniffer (bfd *abfd) 00081 { 00082 if (strcmp (bfd_get_target (abfd), "netbsd-core") == 0) 00083 return GDB_OSABI_NETBSD_CORE; 00084 00085 return GDB_OSABI_UNKNOWN; 00086 } 00087 00088 /* Provide a prototype to silence -Wmissing-prototypes. */ 00089 extern initialize_file_ftype _initialize_shnbsd_tdep; 00090 00091 void 00092 _initialize_shnbsd_tdep (void) 00093 { 00094 /* BFD doesn't set a flavour for NetBSD style a.out core files. */ 00095 gdbarch_register_osabi_sniffer (bfd_arch_sh, bfd_target_unknown_flavour, 00096 shnbsd_core_osabi_sniffer); 00097 00098 gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_NETBSD_ELF, 00099 shnbsd_init_abi); 00100 gdbarch_register_osabi (bfd_arch_sh, 0, GDB_OSABI_OPENBSD_ELF, 00101 shnbsd_init_abi); 00102 }