| OLD | NEW |
| 1 /* Target-dependent code for Cygwin running on i386's, for GDB. | 1 /* Target-dependent code for Cygwin running on i386's, for GDB. |
| 2 | 2 |
| 3 Copyright (C) 2003, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2003-2013 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 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 | 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 | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| 11 | 11 |
| 12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
| 16 | 16 |
| 17 You should have received a copy of the GNU General Public License | 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/>. */ | 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | 19 |
| 20 #include "defs.h" | 20 #include "defs.h" |
| 21 #include "osabi.h" | 21 #include "osabi.h" |
| 22 #include "gdb_string.h" | 22 #include <string.h> |
| 23 #include "i386-tdep.h" | 23 #include "i386-tdep.h" |
| 24 #include "windows-tdep.h" | 24 #include "windows-tdep.h" |
| 25 #include "regset.h" | 25 #include "regset.h" |
| 26 #include "gdb_obstack.h" | 26 #include "gdb_obstack.h" |
| 27 #include "xml-support.h" | 27 #include "xml-support.h" |
| 28 #include "gdbcore.h" | 28 #include "gdbcore.h" |
| 29 #include "solib.h" | |
| 30 #include "solib-target.h" | |
| 31 #include "inferior.h" | 29 #include "inferior.h" |
| 32 | 30 |
| 33 /* Core file support. */ | 31 /* Core file support. */ |
| 34 | 32 |
| 35 /* This vector maps GDB's idea of a register's number into an address | 33 /* This vector maps GDB's idea of a register's number into an address |
| 36 in the windows exception context vector. */ | 34 in the windows exception context vector. */ |
| 37 | 35 |
| 38 static int i386_windows_gregset_reg_offset[] = | 36 static int i386_windows_gregset_reg_offset[] = |
| 39 { | 37 { |
| 40 176, /* eax */ | 38 176, /* eax */ |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 static void | 120 static void |
| 123 core_process_module_section (bfd *abfd, asection *sect, void *obj) | 121 core_process_module_section (bfd *abfd, asection *sect, void *obj) |
| 124 { | 122 { |
| 125 struct cpms_data *data = obj; | 123 struct cpms_data *data = obj; |
| 126 enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch); | 124 enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch); |
| 127 | 125 |
| 128 char *module_name; | 126 char *module_name; |
| 129 size_t module_name_size; | 127 size_t module_name_size; |
| 130 CORE_ADDR base_addr; | 128 CORE_ADDR base_addr; |
| 131 | 129 |
| 132 char *buf = NULL; | 130 gdb_byte *buf = NULL; |
| 133 | 131 |
| 134 if (strncmp (sect->name, ".module", 7) != 0) | 132 if (strncmp (sect->name, ".module", 7) != 0) |
| 135 return; | 133 return; |
| 136 | 134 |
| 137 buf = xmalloc (bfd_get_section_size (sect) + 1); | 135 buf = xmalloc (bfd_get_section_size (sect) + 1); |
| 138 if (!buf) | 136 if (!buf) |
| 139 { | 137 { |
| 140 printf_unfiltered ("memory allocation failed for %s\n", sect->name); | 138 printf_unfiltered ("memory allocation failed for %s\n", sect->name); |
| 141 goto out; | 139 goto out; |
| 142 } | 140 } |
| 143 if (!bfd_get_section_contents (abfd, sect, | 141 if (!bfd_get_section_contents (abfd, sect, |
| 144 buf, 0, bfd_get_section_size (sect))) | 142 buf, 0, bfd_get_section_size (sect))) |
| 145 goto out; | 143 goto out; |
| 146 | 144 |
| 147 | 145 |
| 148 | 146 |
| 149 /* A DWORD (data_type) followed by struct windows_core_module_info. */ | 147 /* A DWORD (data_type) followed by struct windows_core_module_info. */ |
| 150 | 148 |
| 151 base_addr = | 149 base_addr = |
| 152 extract_unsigned_integer (buf + 4, 4, byte_order); | 150 extract_unsigned_integer (buf + 4, 4, byte_order); |
| 153 | 151 |
| 154 module_name_size = | 152 module_name_size = |
| 155 extract_unsigned_integer (buf + 8, 4, byte_order); | 153 extract_unsigned_integer (buf + 8, 4, byte_order); |
| 156 | 154 |
| 157 module_name = buf + 12; | 155 if (12 + module_name_size > bfd_get_section_size (sect)) |
| 158 if (module_name - buf + module_name_size > bfd_get_section_size (sect)) | |
| 159 goto out; | 156 goto out; |
| 157 module_name = (char *) buf + 12; |
| 160 | 158 |
| 161 /* The first module is the .exe itself. */ | 159 /* The first module is the .exe itself. */ |
| 162 if (data->module_count != 0) | 160 if (data->module_count != 0) |
| 163 windows_xfer_shared_library (module_name, base_addr, | 161 windows_xfer_shared_library (module_name, base_addr, |
| 164 data->gdbarch, data->obstack); | 162 data->gdbarch, data->obstack); |
| 165 data->module_count++; | 163 data->module_count++; |
| 166 | 164 |
| 167 out: | 165 out: |
| 168 if (buf) | 166 if (buf) |
| 169 xfree (buf); | 167 xfree (buf); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 i386_cygwin_auto_wide_charset (void) | 224 i386_cygwin_auto_wide_charset (void) |
| 227 { | 225 { |
| 228 return "UTF-16"; | 226 return "UTF-16"; |
| 229 } | 227 } |
| 230 | 228 |
| 231 static void | 229 static void |
| 232 i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | 230 i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) |
| 233 { | 231 { |
| 234 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); | 232 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); |
| 235 | 233 |
| 234 windows_init_abi (info, gdbarch); |
| 235 |
| 236 set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code); | 236 set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code); |
| 237 | 237 |
| 238 set_gdbarch_skip_main_prologue (gdbarch, i386_skip_main_prologue); | 238 set_gdbarch_skip_main_prologue (gdbarch, i386_skip_main_prologue); |
| 239 | 239 |
| 240 tdep->struct_return = reg_struct_return; | 240 tdep->struct_return = reg_struct_return; |
| 241 | 241 |
| 242 tdep->gregset_reg_offset = i386_windows_gregset_reg_offset; | 242 tdep->gregset_reg_offset = i386_windows_gregset_reg_offset; |
| 243 tdep->gregset_num_regs = ARRAY_SIZE (i386_windows_gregset_reg_offset); | 243 tdep->gregset_num_regs = ARRAY_SIZE (i386_windows_gregset_reg_offset); |
| 244 tdep->sizeof_gregset = I386_WINDOWS_SIZEOF_GREGSET; | 244 tdep->sizeof_gregset = I386_WINDOWS_SIZEOF_GREGSET; |
| 245 | 245 |
| 246 set_solib_ops (gdbarch, &solib_target_so_ops); | |
| 247 | |
| 248 /* Core file support. */ | 246 /* Core file support. */ |
| 249 set_gdbarch_regset_from_core_section | 247 set_gdbarch_regset_from_core_section |
| 250 (gdbarch, i386_windows_regset_from_core_section); | 248 (gdbarch, i386_windows_regset_from_core_section); |
| 251 set_gdbarch_core_xfer_shared_libraries | 249 set_gdbarch_core_xfer_shared_libraries |
| 252 (gdbarch, windows_core_xfer_shared_libraries); | 250 (gdbarch, windows_core_xfer_shared_libraries); |
| 253 set_gdbarch_core_pid_to_str (gdbarch, i386_windows_core_pid_to_str); | 251 set_gdbarch_core_pid_to_str (gdbarch, i386_windows_core_pid_to_str); |
| 254 | 252 |
| 255 set_gdbarch_auto_wide_charset (gdbarch, i386_cygwin_auto_wide_charset); | 253 set_gdbarch_auto_wide_charset (gdbarch, i386_cygwin_auto_wide_charset); |
| 256 | |
| 257 /* Canonical paths on this target look like | |
| 258 `c:\Program Files\Foo App\mydll.dll', for example. */ | |
| 259 set_gdbarch_has_dos_based_file_system (gdbarch, 1); | |
| 260 | |
| 261 set_gdbarch_iterate_over_objfiles_in_search_order | |
| 262 (gdbarch, windows_iterate_over_objfiles_in_search_order); | |
| 263 } | 254 } |
| 264 | 255 |
| 265 static enum gdb_osabi | 256 static enum gdb_osabi |
| 266 i386_cygwin_osabi_sniffer (bfd *abfd) | 257 i386_cygwin_osabi_sniffer (bfd *abfd) |
| 267 { | 258 { |
| 268 char *target_name = bfd_get_target (abfd); | 259 char *target_name = bfd_get_target (abfd); |
| 269 | 260 |
| 270 /* Interix also uses pei-i386. | |
| 271 We need a way to distinguish between the two. */ | |
| 272 if (strcmp (target_name, "pei-i386") == 0) | 261 if (strcmp (target_name, "pei-i386") == 0) |
| 273 return GDB_OSABI_CYGWIN; | 262 return GDB_OSABI_CYGWIN; |
| 274 | 263 |
| 275 /* Cygwin uses elf core dumps. Do not claim all ELF executables, | 264 /* Cygwin uses elf core dumps. Do not claim all ELF executables, |
| 276 check whether there is a .reg section of proper size. */ | 265 check whether there is a .reg section of proper size. */ |
| 277 if (strcmp (target_name, "elf32-i386") == 0) | 266 if (strcmp (target_name, "elf32-i386") == 0) |
| 278 { | 267 { |
| 279 asection *section = bfd_get_section_by_name (abfd, ".reg"); | 268 asection *section = bfd_get_section_by_name (abfd, ".reg"); |
| 280 if (section | 269 if (section |
| 281 && bfd_section_size (abfd, section) == I386_WINDOWS_SIZEOF_GREGSET) | 270 && bfd_section_size (abfd, section) == I386_WINDOWS_SIZEOF_GREGSET) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 294 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour, | 283 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour, |
| 295 i386_cygwin_osabi_sniffer); | 284 i386_cygwin_osabi_sniffer); |
| 296 | 285 |
| 297 /* Cygwin uses elf core dumps. */ | 286 /* Cygwin uses elf core dumps. */ |
| 298 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour, | 287 gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour, |
| 299 i386_cygwin_osabi_sniffer); | 288 i386_cygwin_osabi_sniffer); |
| 300 | 289 |
| 301 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_CYGWIN, | 290 gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_CYGWIN, |
| 302 i386_cygwin_init_abi); | 291 i386_cygwin_init_abi); |
| 303 } | 292 } |
| OLD | NEW |