summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2007-09-03 23:06:35 +0000
committerPedro Alves <palves@redhat.com>2007-09-03 23:06:35 +0000
commitde584861439dac10f422843cf2bf85d0ff4ad628 (patch)
tree56c67d72c95e69c0ebb4bcf43b3fa15ead551204
parent7160c4c357f1e15085c0cd6c9d56b5035f356f6e (diff)
downloadbinutils-gdb-de584861439dac10f422843cf2bf85d0ff4ad628.tar.gz
* gdbarch.sh (core_xfer_shared_libraries): New.
* corelow.c (core_xfer_partial): Handle TARGET_OBJECT_LIBRARIES. * gdb_obstack.h (obstack_grow_str, obstack_grow_str0): New. * xml-support.c (gdb_xml_parse): Debug output tweaks. (xml_escape_text): New. * xml-support.h (xml_escape_text): Declare. * config/i386/cygwin.mh (NATDEPFILES): Move corelow.o to ... * config/i386/cygwin.mt (TDEPFILES): ... here. * win32-nat.c: (fetch_elf_core_registers): Delete. (win32_elf_core_fn): Delete. (_initialize_core_win32): Delete. * i386-cygwin-tdep.c: Include "regset.h", "gdb_objstack.h", "xml-support.h" and "gdbcore.h". (i386_win32_gregset_reg_offset): New. (I386_WIN32_SIZEOF_GREGSET): New. (i386_win32_regset_from_core_section): New. (win32_xfer_shared_library): New. (struct cpms_data): New. (core_process_module_section): New. (win32_core_xfer_shared_libraries): New. (i386_cygwin_skip_trampoline_code): Register gregset_reg_offset, gregset_num_regs, sizeof_gregset members of tdep. Register regset_from_core_section and core_xfer_shared_libraries callbacks. * Makefile.in (i386-cygwin-tdep.o): Update dependencies. * gdbarch.h, gdbarch.c: Regenerate.
-rw-r--r--gdb/ChangeLog36
-rw-r--r--gdb/Makefile.in3
-rw-r--r--gdb/config/i386/cygwin.mh2
-rw-r--r--gdb/config/i386/cygwin.mt2
-rw-r--r--gdb/corelow.c12
-rw-r--r--gdb/gdb_obstack.h5
-rw-r--r--gdb/gdbarch.c39
-rw-r--r--gdb/gdbarch.h15
-rwxr-xr-xgdb/gdbarch.sh4
-rw-r--r--gdb/i386-cygwin-tdep.c215
-rw-r--r--gdb/win32-nat.c32
-rw-r--r--gdb/windows-nat.c32
-rw-r--r--gdb/xml-support.c67
-rw-r--r--gdb/xml-support.h42
14 files changed, 408 insertions, 98 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 09923d52bc0..7dce17cb42a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,39 @@
+2007-09-04 Pedro Alves <pedro_alves@portugalmail.pt>
+ Daniel Jacobowitz <dan@codesourcery.com>
+
+ * gdbarch.sh (core_xfer_shared_libraries): New.
+
+ * corelow.c (core_xfer_partial): Handle TARGET_OBJECT_LIBRARIES.
+
+ * gdb_obstack.h (obstack_grow_str, obstack_grow_str0): New.
+
+ * xml-support.c (gdb_xml_parse): Debug output tweaks.
+ (xml_escape_text): New.
+ * xml-support.h (xml_escape_text): Declare.
+
+ * config/i386/cygwin.mh (NATDEPFILES): Move corelow.o to ...
+ * config/i386/cygwin.mt (TDEPFILES): ... here.
+
+ * win32-nat.c: (fetch_elf_core_registers): Delete.
+ (win32_elf_core_fn): Delete.
+ (_initialize_core_win32): Delete.
+
+ * i386-cygwin-tdep.c: Include "regset.h", "gdb_objstack.h",
+ "xml-support.h" and "gdbcore.h".
+ (i386_win32_gregset_reg_offset): New.
+ (I386_WIN32_SIZEOF_GREGSET): New.
+ (i386_win32_regset_from_core_section): New.
+ (win32_xfer_shared_library): New.
+ (struct cpms_data): New.
+ (core_process_module_section): New.
+ (win32_core_xfer_shared_libraries): New.
+ (i386_cygwin_skip_trampoline_code): Register gregset_reg_offset,
+ gregset_num_regs, sizeof_gregset members of tdep. Register
+ regset_from_core_section and core_xfer_shared_libraries callbacks.
+
+ * Makefile.in (i386-cygwin-tdep.o): Update dependencies.
+ * gdbarch.h, gdbarch.c: Regenerate.
+
2007-09-03 Daniel Jacobowitz <dan@codesourcery.com>
* corelow.c (core_xfer_partial): Pass writebuf to
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index a8c7d3737f7..4deb4f5d60a 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2102,7 +2102,8 @@ i386bsd-nat.o: i386bsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
i386bsd-tdep.o: i386bsd-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
$(gdbcore_h) $(regcache_h) $(osabi_h) $(gdb_string_h) $(i386_tdep_h)
i386-cygwin-tdep.o: i386-cygwin-tdep.c $(defs_h) $(osabi_h) $(gdb_string_h) \
- $(i386_tdep_h)
+ $(i386_tdep_h) $(regset_h) $(gdb_obstack_h) $(xml_support_h) \
+ $(gdbcore_h)
i386fbsd-nat.o: i386fbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \
$(target_h) $(fbsd_nat_h) $(i386_tdep_h) $(i386bsd_nat_h) \
$(bsd_kvm_h)
diff --git a/gdb/config/i386/cygwin.mh b/gdb/config/i386/cygwin.mh
index 92a0d05d32d..36f6cc590db 100644
--- a/gdb/config/i386/cygwin.mh
+++ b/gdb/config/i386/cygwin.mh
@@ -1,4 +1,4 @@
MH_CFLAGS=
-NATDEPFILES= i386-nat.o win32-nat.o corelow.o
+NATDEPFILES= i386-nat.o win32-nat.o
NAT_FILE=nm-cygwin.h
XM_CLIBS=
diff --git a/gdb/config/i386/cygwin.mt b/gdb/config/i386/cygwin.mt
index 47cfbaaacb2..8ec3c44d09d 100644
--- a/gdb/config/i386/cygwin.mt
+++ b/gdb/config/i386/cygwin.mt
@@ -1,3 +1,3 @@
# Target: Intel 386 run win32
TDEPFILES= i386-tdep.o i386-cygwin-tdep.o i387-tdep.o \
- solib-target.o
+ solib-target.o corelow.o
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 28b0a2261d5..408e95ac62f 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -592,6 +592,18 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
}
return -1;
+ case TARGET_OBJECT_LIBRARIES:
+ if (core_gdbarch
+ && gdbarch_core_xfer_shared_libraries_p (core_gdbarch))
+ {
+ if (writebuf)
+ return -1;
+ return
+ gdbarch_core_xfer_shared_libraries (core_gdbarch,
+ readbuf, offset, len);
+ }
+ /* FALL THROUGH */
+
default:
if (ops->beneath != NULL)
return ops->beneath->to_xfer_partial (ops->beneath, object, annex,
diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
index fc8e687a4da..7e1a76ed3e7 100644
--- a/gdb/gdb_obstack.h
+++ b/gdb/gdb_obstack.h
@@ -40,4 +40,9 @@
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free xfree
+#define obstack_grow_str(OBSTACK,STRING) \
+ obstack_grow (OBSTACK, STRING, strlen (STRING))
+#define obstack_grow_str0(OBSTACK,STRING) \
+ obstack_grow0 (OBSTACK, STRING, strlen (STRING))
+
#endif
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 873a1e7abb7..e4bcaca2c8b 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -2,7 +2,7 @@
/* Dynamic architecture support for GDB, the GNU debugger.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of GDB.
@@ -11,12 +11,12 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -225,6 +225,7 @@ struct gdbarch
gdbarch_register_reggroup_p_ftype *register_reggroup_p;
gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
gdbarch_regset_from_core_section_ftype *regset_from_core_section;
+ gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries;
int vtable_function_descriptors;
int vbit_in_delta;
gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
@@ -346,6 +347,7 @@ struct gdbarch startup_gdbarch =
default_register_reggroup_p, /* register_reggroup_p */
0, /* fetch_pointer_argument */
0, /* regset_from_core_section */
+ 0, /* core_xfer_shared_libraries */
0, /* vtable_function_descriptors */
0, /* vbit_in_delta */
0, /* skip_permanent_breakpoint */
@@ -592,6 +594,7 @@ verify_gdbarch (struct gdbarch *current_gdbarch)
/* Skip verify of register_reggroup_p, invalid_p == 0 */
/* Skip verify of fetch_pointer_argument, has predicate */
/* Skip verify of regset_from_core_section, has predicate */
+ /* Skip verify of core_xfer_shared_libraries, has predicate */
/* Skip verify of vtable_function_descriptors, invalid_p == 0 */
/* Skip verify of vbit_in_delta, invalid_p == 0 */
/* Skip verify of skip_permanent_breakpoint, has predicate */
@@ -711,6 +714,12 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file)
"gdbarch_dump: convert_register_p = <0x%lx>\n",
(long) current_gdbarch->convert_register_p);
fprintf_unfiltered (file,
+ "gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = %d\n",
+ gdbarch_core_xfer_shared_libraries_p (current_gdbarch));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: core_xfer_shared_libraries = <0x%lx>\n",
+ (long) current_gdbarch->core_xfer_shared_libraries);
+ fprintf_unfiltered (file,
"gdbarch_dump: decr_pc_after_break = 0x%s\n",
paddr_nz (current_gdbarch->decr_pc_after_break));
fprintf_unfiltered (file,
@@ -2887,6 +2896,30 @@ set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch,
}
int
+gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->core_xfer_shared_libraries != NULL;
+}
+
+LONGEST
+gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->core_xfer_shared_libraries != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_core_xfer_shared_libraries called\n");
+ return gdbarch->core_xfer_shared_libraries (gdbarch, readbuf, offset, len);
+}
+
+void
+set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch,
+ gdbarch_core_xfer_shared_libraries_ftype core_xfer_shared_libraries)
+{
+ gdbarch->core_xfer_shared_libraries = core_xfer_shared_libraries;
+}
+
+int
gdbarch_vtable_function_descriptors (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 9395cf552e4..a573bde1244 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -2,7 +2,7 @@
/* Dynamic architecture support for GDB, the GNU debugger.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of GDB.
@@ -11,12 +11,12 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -649,6 +649,15 @@ typedef const struct regset * (gdbarch_regset_from_core_section_ftype) (struct g
extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size);
extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section);
+/* Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from
+ core file into buffer READBUF with length LEN. */
+
+extern int gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch);
+
+typedef LONGEST (gdbarch_core_xfer_shared_libraries_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
+extern LONGEST gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
+extern void set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries);
+
/* If the elements of C++ vtables are in-place function descriptors rather
than normal function pointers (which may point to code or a descriptor),
set this to one. */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 30e31fb1dd0..2307425c1de 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -634,6 +634,10 @@ F::CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct t
# name SECT_NAME and size SECT_SIZE.
M::const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size
+# Read offset OFFSET of TARGET_OBJECT_LIBRARIES formatted shared libraries list from
+# core file into buffer READBUF with length LEN.
+M::LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len
+
# If the elements of C++ vtables are in-place function descriptors rather
# than normal function pointers (which may point to code or a descriptor),
# set this to one.
diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
index f70d98c41f1..0185a0a36b3 100644
--- a/gdb/i386-cygwin-tdep.c
+++ b/gdb/i386-cygwin-tdep.c
@@ -19,10 +19,197 @@
#include "defs.h"
#include "osabi.h"
-
#include "gdb_string.h"
-
#include "i386-tdep.h"
+#include "regset.h"
+#include "gdb_obstack.h"
+#include "xml-support.h"
+#include "gdbcore.h"
+
+/* Core file support. */
+
+/* This vector maps GDB's idea of a register's number into an address
+ in the win32 exception context vector. */
+
+static int i386_win32_gregset_reg_offset[] =
+{
+ 176, /* eax */
+ 172, /* ecx */
+ 168, /* edx */
+ 164, /* ebx */
+
+ 196, /* esp */
+ 180, /* ebp */
+ 160, /* esi */
+ 156, /* edi */
+
+ 184, /* eip */
+ 192, /* eflags */
+ 188, /* cs */
+ 200, /* ss */
+
+ 152, /* ds */
+ 148, /* es */
+ 144, /* fs */
+ 140, /* gs */
+
+ 56, /* FloatSave.RegisterArea[0 * 10] */
+ 66, /* FloatSave.RegisterArea[1 * 10] */
+ 76, /* FloatSave.RegisterArea[2 * 10] */
+ 86, /* FloatSave.RegisterArea[3 * 10] */
+ 96, /* FloatSave.RegisterArea[4 * 10] */
+ 106, /* FloatSave.RegisterArea[5 * 10] */
+ 116, /* FloatSave.RegisterArea[6 * 10] */
+ 126, /* FloatSave.RegisterArea[7 * 10] */
+
+ 28, /* FloatSave.ControlWord */
+ 32, /* FloatSave.StatusWord */
+ 36, /* FloatSave.TagWord */
+ 44, /* FloatSave.ErrorSelector */
+ 40, /* FloatSave.ErrorOffset */
+ 52, /* FloatSave.DataSelector */
+ 48, /* FloatSave.DataOffset */
+ 44, /* FloatSave.ErrorSelector */
+
+ /* XMM0-7 */
+ 364, /* ExtendedRegisters[10*16] */
+ 380, /* ExtendedRegisters[11*16] */
+ 396, /* ExtendedRegisters[12*16] */
+ 412, /* ExtendedRegisters[13*16] */
+ 428, /* ExtendedRegisters[14*16] */
+ 444, /* ExtendedRegisters[15*16] */
+ 460, /* ExtendedRegisters[16*16] */
+ 476, /* ExtendedRegisters[17*16] */
+
+ /* MXCSR */
+ 228 /* ExtendedRegisters[24] */
+};
+
+#define I386_WIN32_SIZEOF_GREGSET 716
+
+/* Return the appropriate register set for the core section identified
+ by SECT_NAME and SECT_SIZE. */
+
+static const struct regset *
+i386_win32_regset_from_core_section (struct gdbarch *gdbarch,
+ const char *sect_name, size_t sect_size)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ if (strcmp (sect_name, ".reg") == 0
+ && sect_size == I386_WIN32_SIZEOF_GREGSET)
+ {
+ if (tdep->gregset == NULL)
+ tdep->gregset = regset_alloc (gdbarch, i386_supply_gregset,
+ i386_collect_gregset);
+ return tdep->gregset;
+ }
+
+ return NULL;
+}
+
+static void
+win32_xfer_shared_library (const char* so_name, CORE_ADDR load_addr,
+ struct obstack *obstack)
+{
+ char *p;
+ obstack_grow_str (obstack, "<library name=\"");
+ p = xml_escape_text (so_name);
+ obstack_grow_str (obstack, p);
+ xfree (p);
+ obstack_grow_str (obstack, "\"><segment address=\"0x");
+ /* The symbols in a dll are offset by 0x1000, which is the the
+ offset from 0 of the first byte in an image - because of the file
+ header and the section alignment. */
+ p = paddr_nz (load_addr + 0x1000);
+ obstack_grow_str (obstack, p);
+ obstack_grow_str (obstack, "\"/></library>");
+}
+
+struct cpms_data
+{
+ struct obstack *obstack;
+ int module_count;
+};
+
+static void
+core_process_module_section (bfd *abfd, asection *sect, void *obj)
+{
+ struct cpms_data *data = obj;
+
+ char *module_name;
+ size_t module_name_size;
+ CORE_ADDR base_addr;
+
+ char *buf = NULL;
+
+ if (strncmp (sect->name, ".module", 7) != 0)
+ return;
+
+ buf = xmalloc (bfd_get_section_size (sect) + 1);
+ if (!buf)
+ {
+ printf_unfiltered ("memory allocation failed for %s\n", sect->name);
+ goto out;
+ }
+ if (!bfd_get_section_contents (abfd, sect,
+ buf, 0, bfd_get_section_size (sect)))
+ goto out;
+
+
+
+ /* A DWORD (data_type) followed by struct win32_core_module_info. */
+
+ base_addr =
+ extract_unsigned_integer (buf + 4, 4);
+
+ module_name_size =
+ extract_unsigned_integer (buf + 8, 4);
+
+ module_name = buf + 12;
+ if (module_name - buf + module_name_size > bfd_get_section_size (sect))
+ goto out;
+
+ /* The first module is the .exe itself. */
+ if (data->module_count != 0)
+ win32_xfer_shared_library (module_name, base_addr, data->obstack);
+ data->module_count++;
+
+out:
+ if (buf)
+ xfree (buf);
+ return;
+}
+
+static LONGEST
+win32_core_xfer_shared_libraries (struct gdbarch *gdbarch,
+ gdb_byte *readbuf,
+ ULONGEST offset, LONGEST len)
+{
+ struct obstack obstack;
+ const char *buf;
+ LONGEST len_avail;
+ struct cpms_data data = { &obstack, 0 };
+
+ obstack_init (&obstack);
+ obstack_grow_str (&obstack, "<library-list>\n");
+ bfd_map_over_sections (core_bfd,
+ core_process_module_section,
+ &data);
+ obstack_grow_str0 (&obstack, "</library-list>\n");
+
+ buf = obstack_finish (&obstack);
+ len_avail = strlen (buf);
+ if (offset >= len_avail)
+ return 0;
+
+ if (len > len_avail - offset)
+ len = len_avail - offset;
+ memcpy (readbuf, buf + offset, len);
+
+ obstack_free (&obstack, NULL);
+ return len;
+}
static CORE_ADDR
i386_cygwin_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
@@ -38,18 +225,32 @@ i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code);
tdep->struct_return = reg_struct_return;
+
+ tdep->gregset_reg_offset = i386_win32_gregset_reg_offset;
+ tdep->gregset_num_regs = ARRAY_SIZE (i386_win32_gregset_reg_offset);
+ tdep->sizeof_gregset = I386_WIN32_SIZEOF_GREGSET;
+
+ /* Core file support. */
+ set_gdbarch_regset_from_core_section
+ (gdbarch, i386_win32_regset_from_core_section);
+ set_gdbarch_core_xfer_shared_libraries
+ (gdbarch, win32_core_xfer_shared_libraries);
}
static enum gdb_osabi
-i386_cygwin_osabi_sniffer (bfd * abfd)
-{
+i386_cygwin_osabi_sniffer (bfd *abfd)
+{
char *target_name = bfd_get_target (abfd);
- /* Interix also uses pei-i386.
+ /* Interix also uses pei-i386.
We need a way to distinguish between the two. */
if (strcmp (target_name, "pei-i386") == 0)
return GDB_OSABI_CYGWIN;
+ /* Cygwin uses elf core dumps. */
+ if (strcmp (target_name, "elf32-i386") == 0)
+ return GDB_OSABI_CYGWIN;
+
return GDB_OSABI_UNKNOWN;
}
@@ -62,6 +263,10 @@ _initialize_i386_cygwin_tdep (void)
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour,
i386_cygwin_osabi_sniffer);
+ /* Cygwin uses elf core dumps. */
+ gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
+ i386_cygwin_osabi_sniffer);
+
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_CYGWIN,
i386_cygwin_init_abi);
}
diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index df83f90e48e..7100e359122 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -2242,23 +2242,6 @@ win32_current_sos (void)
return start;
}
-static void
-fetch_elf_core_registers (struct regcache *regcache,
- char *core_reg_sect,
- unsigned core_reg_size,
- int which,
- CORE_ADDR reg_addr)
-{
- int r;
- if (core_reg_size < sizeof (CONTEXT))
- {
- error (_("Core file register section too small (%u bytes)."), core_reg_size);
- return;
- }
- for (r = 0; r < gdbarch_num_regs (current_gdbarch); r++)
- regcache_raw_supply (regcache, r, core_reg_sect + mappings[r]);
-}
-
static int
open_symbol_file_object (void *from_ttyp)
{
@@ -2460,21 +2443,6 @@ win32_win32_thread_alive (ptid_t ptid)
FALSE : TRUE;
}
-static struct core_fns win32_elf_core_fns =
-{
- bfd_target_elf_flavour,
- default_check_format,
- default_core_sniffer,
- fetch_elf_core_registers,
- NULL
-};
-
-void
-_initialize_core_win32 (void)
-{
- deprecated_add_core_fns (&win32_elf_core_fns);
-}
-
void
_initialize_check_for_gdb_ini (void)
{
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index df83f90e48e..7100e359122 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2242,23 +2242,6 @@ win32_current_sos (void)
return start;
}
-static void
-fetch_elf_core_registers (struct regcache *regcache,
- char *core_reg_sect,
- unsigned core_reg_size,
- int which,
- CORE_ADDR reg_addr)
-{
- int r;
- if (core_reg_size < sizeof (CONTEXT))
- {
- error (_("Core file register section too small (%u bytes)."), core_reg_size);
- return;
- }
- for (r = 0; r < gdbarch_num_regs (current_gdbarch); r++)
- regcache_raw_supply (regcache, r, core_reg_sect + mappings[r]);
-}
-
static int
open_symbol_file_object (void *from_ttyp)
{
@@ -2460,21 +2443,6 @@ win32_win32_thread_alive (ptid_t ptid)
FALSE : TRUE;
}
-static struct core_fns win32_elf_core_fns =
-{
- bfd_target_elf_flavour,
- default_check_format,
- default_core_sniffer,
- fetch_elf_core_registers,
- NULL
-};
-
-void
-_initialize_core_win32 (void)
-{
- deprecated_add_core_fns (&win32_elf_core_fns);
-}
-
void
_initialize_check_for_gdb_ini (void)
{
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 8a4762cb2b7..9cee5efbf77 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -544,6 +544,8 @@ gdb_xml_parse (struct gdb_xml_parser *parser, const char *buffer)
enum XML_Status status;
const char *error_string;
+ gdb_xml_debug (parser, _("Starting:\n%s"), buffer);
+
status = XML_Parse (parser->expat_parser, buffer, strlen (buffer), 1);
if (status == XML_STATUS_OK && parser->error.reason == 0)
@@ -869,8 +871,7 @@ xml_process_xincludes (const char *name, const char *text,
result = xstrdup (obstack_finish (&data->obstack));
if (depth == 0)
- gdb_xml_debug (parser, _("XInclude processing succeeded:\n%s"),
- result);
+ gdb_xml_debug (parser, _("XInclude processing succeeded."));
}
else
result = NULL;
@@ -934,6 +935,68 @@ show_debug_xml (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("XML debugging is %s.\n"), value);
}
+/* Return a malloc allocated string with special characters from TEXT
+ replaced by entity references. */
+
+char *
+xml_escape_text (const char *text)
+{
+ char *result;
+ int i, special;
+
+ /* Compute the length of the result. */
+ for (i = 0, special = 0; text[i] != '\0'; i++)
+ switch (text[i])
+ {
+ case '\'':
+ case '\"':
+ special += 5;
+ break;
+ case '&':
+ special += 4;
+ break;
+ case '<':
+ case '>':
+ special += 3;
+ break;
+ default:
+ break;
+ }
+
+ /* Expand the result. */
+ result = xmalloc (i + special + 1);
+ for (i = 0, special = 0; text[i] != '\0'; i++)
+ switch (text[i])
+ {
+ case '\'':
+ strcpy (result + i + special, "&apos;");
+ special += 5;
+ break;
+ case '\"':
+ strcpy (result + i + special, "&quot;");
+ special += 5;
+ break;
+ case '&':
+ strcpy (result + i + special, "&amp;");
+ special += 4;
+ break;
+ case '<':
+ strcpy (result + i + special, "&lt;");
+ special += 3;
+ break;
+ case '>':
+ strcpy (result + i + special, "&gt;");
+ special += 3;
+ break;
+ default:
+ result[i + special] = text[i];
+ break;
+ }
+ result[i + special] = '\0';
+
+ return result;
+}
+
void _initialize_xml_support (void);
void
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index b8377be1547..b480fe0b36c 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -28,24 +28,6 @@ struct gdb_xml_parser;
struct gdb_xml_element;
struct gdb_xml_attribute;
-/* Support for XInclude. */
-
-/* Callback to fetch a new XML file, based on the provided HREF. */
-
-typedef char *(*xml_fetch_another) (const char *href, void *baton);
-
-/* Return a new string which is the expansion of TEXT after processing
- <xi:include> tags. FETCHER will be called (with FETCHER_BATON) to
- retrieve any new files. DEPTH should be zero on the initial call.
-
- On failure, this function uses NAME in a warning and returns NULL.
- It may throw an exception, but does not for XML parsing
- problems. */
-
-char *xml_process_xincludes (const char *name, const char *text,
- xml_fetch_another fetcher, void *fetcher_baton,
- int depth);
-
/* Return an XML document which was compiled into GDB, from
the given FILENAME, or NULL if the file was not compiled in. */
@@ -62,8 +44,32 @@ LONGEST xml_builtin_xfer_partial (const char *filename,
/* The text of compiled-in XML documents, from xml-builtin.c
(generated). */
+
extern const char *xml_builtin[][2];
+/* Return a malloc allocated string with special characters from TEXT
+ replaced by entity references. */
+
+char *xml_escape_text (const char *text);
+
+/* Support for XInclude. */
+
+/* Callback to fetch a new XML file, based on the provided HREF. */
+
+typedef char *(*xml_fetch_another) (const char *href, void *baton);
+
+/* Return a new string which is the expansion of TEXT after processing
+ <xi:include> tags. FETCHER will be called (with FETCHER_BATON) to
+ retrieve any new files. DEPTH should be zero on the initial call.
+
+ On failure, this function uses NAME in a warning and returns NULL.
+ It may throw an exception, but does not for XML parsing
+ problems. */
+
+char *xml_process_xincludes (const char *name, const char *text,
+ xml_fetch_another fetcher, void *fetcher_baton,
+ int depth);
+
/* Simplified XML parser infrastructure. */
/* A name and value pair, used to record parsed attributes. */