6d3d12ebef
This commit includes string.h in common-defs.h and removes all other inclusions. gdb/ 2014-08-07 Gary Benson <gbenson@redhat.com> * common/common-defs.h: Include string.h. * aarch64-tdep.c: Do not include string.h. * ada-exp.y: Likewise. * ada-lang.c: Likewise. * ada-lex.l: Likewise. * ada-typeprint.c: Likewise. * ada-valprint.c: Likewise. * aix-thread.c: Likewise. * alpha-linux-tdep.c: Likewise. * alpha-mdebug-tdep.c: Likewise. * alpha-nat.c: Likewise. * alpha-osf1-tdep.c: Likewise. * alpha-tdep.c: Likewise. * alphanbsd-tdep.c: Likewise. * amd64-dicos-tdep.c: Likewise. * amd64-linux-tdep.c: Likewise. * amd64-nat.c: Likewise. * amd64-sol2-tdep.c: Likewise. * amd64fbsd-tdep.c: Likewise. * amd64obsd-tdep.c: Likewise. * arch-utils.c: Likewise. * arm-linux-nat.c: Likewise. * arm-linux-tdep.c: Likewise. * arm-tdep.c: Likewise. * arm-wince-tdep.c: Likewise. * armbsd-tdep.c: Likewise. * armnbsd-nat.c: Likewise. * armnbsd-tdep.c: Likewise. * armobsd-tdep.c: Likewise. * avr-tdep.c: Likewise. * ax-gdb.c: Likewise. * ax-general.c: Likewise. * bcache.c: Likewise. * bfin-tdep.c: Likewise. * breakpoint.c: Likewise. * build-id.c: Likewise. * buildsym.c: Likewise. * c-exp.y: Likewise. * c-lang.c: Likewise. * c-typeprint.c: Likewise. * c-valprint.c: Likewise. * charset.c: Likewise. * cli-out.c: Likewise. * cli/cli-cmds.c: Likewise. * cli/cli-decode.c: Likewise. * cli/cli-dump.c: Likewise. * cli/cli-interp.c: Likewise. * cli/cli-logging.c: Likewise. * cli/cli-script.c: Likewise. * cli/cli-setshow.c: Likewise. * cli/cli-utils.c: Likewise. * coffread.c: Likewise. * common/agent.c: Likewise. * common/buffer.c: Likewise. * common/buffer.h: Likewise. * common/common-utils.c: Likewise. * common/filestuff.c: Likewise. * common/filestuff.c: Likewise. * common/format.c: Likewise. * common/print-utils.c: Likewise. * common/rsp-low.c: Likewise. * common/signals.c: Likewise. * common/vec.h: Likewise. * common/xml-utils.c: Likewise. * core-regset.c: Likewise. * corefile.c: Likewise. * corelow.c: Likewise. * cp-abi.c: Likewise. * cp-name-parser.y: Likewise. * cp-support.c: Likewise. * cp-valprint.c: Likewise. * cris-tdep.c: Likewise. * d-exp.y: Likewise. * darwin-nat.c: Likewise. * dbxread.c: Likewise. * dcache.c: Likewise. * demangle.c: Likewise. * dicos-tdep.c: Likewise. * disasm.c: Likewise. * doublest.c: Likewise. * dsrec.c: Likewise. * dummy-frame.c: Likewise. * dwarf2-frame.c: Likewise. * dwarf2loc.c: Likewise. * dwarf2read.c: Likewise. * elfread.c: Likewise. * environ.c: Likewise. * eval.c: Likewise. * event-loop.c: Likewise. * exceptions.c: Likewise. * exec.c: Likewise. * expprint.c: Likewise. * f-exp.y: Likewise. * f-lang.c: Likewise. * f-typeprint.c: Likewise. * f-valprint.c: Likewise. * fbsd-nat.c: Likewise. * findcmd.c: Likewise. * findvar.c: Likewise. * fork-child.c: Likewise. * frame.c: Likewise. * frv-linux-tdep.c: Likewise. * frv-tdep.c: Likewise. * gdb.c: Likewise. * gdb_bfd.c: Likewise. * gdbarch.c: Likewise. * gdbarch.sh: Likewise. * gdbtypes.c: Likewise. * gnu-nat.c: Likewise. * gnu-v2-abi.c: Likewise. * gnu-v3-abi.c: Likewise. * go-exp.y: Likewise. * go-lang.c: Likewise. * go32-nat.c: Likewise. * guile/guile.c: Likewise. * guile/scm-auto-load.c: Likewise. * hppa-hpux-tdep.c: Likewise. * hppa-linux-nat.c: Likewise. * hppanbsd-tdep.c: Likewise. * hppaobsd-tdep.c: Likewise. * i386-cygwin-tdep.c: Likewise. * i386-dicos-tdep.c: Likewise. * i386-linux-tdep.c: Likewise. * i386-nto-tdep.c: Likewise. * i386-sol2-tdep.c: Likewise. * i386-tdep.c: Likewise. * i386bsd-tdep.c: Likewise. * i386gnu-nat.c: Likewise. * i386nbsd-tdep.c: Likewise. * i386obsd-tdep.c: Likewise. * i387-tdep.c: Likewise. * ia64-libunwind-tdep.c: Likewise. * ia64-linux-nat.c: Likewise. * inf-child.c: Likewise. * inf-ptrace.c: Likewise. * inf-ttrace.c: Likewise. * infcall.c: Likewise. * infcmd.c: Likewise. * inflow.c: Likewise. * infrun.c: Likewise. * interps.c: Likewise. * iq2000-tdep.c: Likewise. * irix5-nat.c: Likewise. * jv-exp.y: Likewise. * jv-lang.c: Likewise. * jv-typeprint.c: Likewise. * jv-valprint.c: Likewise. * language.c: Likewise. * linux-fork.c: Likewise. * linux-nat.c: Likewise. * lm32-tdep.c: Likewise. * m2-exp.y: Likewise. * m2-typeprint.c: Likewise. * m32c-tdep.c: Likewise. * m32r-linux-nat.c: Likewise. * m32r-linux-tdep.c: Likewise. * m32r-rom.c: Likewise. * m32r-tdep.c: Likewise. * m68hc11-tdep.c: Likewise. * m68k-tdep.c: Likewise. * m68kbsd-tdep.c: Likewise. * m68klinux-nat.c: Likewise. * m68klinux-tdep.c: Likewise. * m88k-tdep.c: Likewise. * machoread.c: Likewise. * macrocmd.c: Likewise. * main.c: Likewise. * mdebugread.c: Likewise. * mem-break.c: Likewise. * memattr.c: Likewise. * memory-map.c: Likewise. * mep-tdep.c: Likewise. * mi/mi-cmd-break.c: Likewise. * mi/mi-cmd-disas.c: Likewise. * mi/mi-cmd-env.c: Likewise. * mi/mi-cmd-stack.c: Likewise. * mi/mi-cmd-var.c: Likewise. * mi/mi-cmds.c: Likewise. * mi/mi-console.c: Likewise. * mi/mi-getopt.c: Likewise. * mi/mi-interp.c: Likewise. * mi/mi-main.c: Likewise. * mi/mi-parse.c: Likewise. * microblaze-rom.c: Likewise. * microblaze-tdep.c: Likewise. * mingw-hdep.c: Likewise. * minidebug.c: Likewise. * minsyms.c: Likewise. * mips-irix-tdep.c: Likewise. * mips-linux-tdep.c: Likewise. * mips-tdep.c: Likewise. * mips64obsd-tdep.c: Likewise. * mipsnbsd-tdep.c: Likewise. * mipsread.c: Likewise. * mn10300-linux-tdep.c: Likewise. * mn10300-tdep.c: Likewise. * monitor.c: Likewise. * moxie-tdep.c: Likewise. * mt-tdep.c: Likewise. * nat/linux-btrace.c: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-procfs.c: Likewise. * nat/linux-ptrace.c: Likewise. * nat/linux-waitpid.c: Likewise. * nbsd-tdep.c: Likewise. * nios2-linux-tdep.c: Likewise. * nto-procfs.c: Likewise. * nto-tdep.c: Likewise. * objc-lang.c: Likewise. * objfiles.c: Likewise. * opencl-lang.c: Likewise. * osabi.c: Likewise. * osdata.c: Likewise. * p-exp.y: Likewise. * p-lang.c: Likewise. * p-typeprint.c: Likewise. * parse.c: Likewise. * posix-hdep.c: Likewise. * ppc-linux-nat.c: Likewise. * ppc-sysv-tdep.c: Likewise. * ppcfbsd-tdep.c: Likewise. * ppcnbsd-tdep.c: Likewise. * ppcobsd-tdep.c: Likewise. * printcmd.c: Likewise. * procfs.c: Likewise. * prologue-value.c: Likewise. * python/py-auto-load.c: Likewise. * python/py-gdb-readline.c: Likewise. * ravenscar-thread.c: Likewise. * regcache.c: Likewise. * registry.c: Likewise. * remote-fileio.c: Likewise. * remote-m32r-sdi.c: Likewise. * remote-mips.c: Likewise. * remote-notif.c: Likewise. * remote-sim.c: Likewise. * remote.c: Likewise. * reverse.c: Likewise. * rs6000-aix-tdep.c: Likewise. * ser-base.c: Likewise. * ser-go32.c: Likewise. * ser-mingw.c: Likewise. * ser-pipe.c: Likewise. * ser-tcp.c: Likewise. * ser-unix.c: Likewise. * serial.c: Likewise. * sh-tdep.c: Likewise. * sh64-tdep.c: Likewise. * shnbsd-tdep.c: Likewise. * skip.c: Likewise. * sol-thread.c: Likewise. * solib-dsbt.c: Likewise. * solib-frv.c: Likewise. * solib-osf.c: Likewise. * solib-som.c: Likewise. * solib-spu.c: Likewise. * solib-target.c: Likewise. * solib.c: Likewise. * somread.c: Likewise. * source.c: Likewise. * sparc-nat.c: Likewise. * sparc-sol2-tdep.c: Likewise. * sparc-tdep.c: Likewise. * sparc64-tdep.c: Likewise. * sparc64fbsd-tdep.c: Likewise. * sparc64nbsd-tdep.c: Likewise. * sparcnbsd-tdep.c: Likewise. * spu-linux-nat.c: Likewise. * spu-multiarch.c: Likewise. * spu-tdep.c: Likewise. * stabsread.c: Likewise. * stack.c: Likewise. * std-regs.c: Likewise. * symfile.c: Likewise. * symmisc.c: Likewise. * symtab.c: Likewise. * target.c: Likewise. * thread.c: Likewise. * tilegx-linux-nat.c: Likewise. * tilegx-tdep.c: Likewise. * top.c: Likewise. * tracepoint.c: Likewise. * tui/tui-command.c: Likewise. * tui/tui-data.c: Likewise. * tui/tui-disasm.c: Likewise. * tui/tui-file.c: Likewise. * tui/tui-layout.c: Likewise. * tui/tui-out.c: Likewise. * tui/tui-regs.c: Likewise. * tui/tui-source.c: Likewise. * tui/tui-stack.c: Likewise. * tui/tui-win.c: Likewise. * tui/tui-windata.c: Likewise. * tui/tui-winsource.c: Likewise. * typeprint.c: Likewise. * ui-file.c: Likewise. * ui-out.c: Likewise. * user-regs.c: Likewise. * utils.c: Likewise. * v850-tdep.c: Likewise. * valarith.c: Likewise. * valops.c: Likewise. * valprint.c: Likewise. * value.c: Likewise. * varobj.c: Likewise. * vax-tdep.c: Likewise. * vaxnbsd-tdep.c: Likewise. * vaxobsd-tdep.c: Likewise. * windows-nat.c: Likewise. * xcoffread.c: Likewise. * xml-support.c: Likewise. * xstormy16-tdep.c: Likewise. * xtensa-linux-nat.c: Likewise. gdb/gdbserver/ 2014-08-07 Gary Benson <gbenson@redhat.com> * server.h: Do not include string.h. * event-loop.c: Likewise. * linux-low.c: Likewise. * regcache.c: Likewise. * remote-utils.c: Likewise. * spu-low.c: Likewise. * utils.c: Likewise.
284 lines
7.4 KiB
C
284 lines
7.4 KiB
C
/* Target-dependent code for Cygwin running on i386's, for GDB.
|
|
|
|
Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
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/>. */
|
|
|
|
#include "defs.h"
|
|
#include "osabi.h"
|
|
#include "i386-tdep.h"
|
|
#include "windows-tdep.h"
|
|
#include "regset.h"
|
|
#include "gdb_obstack.h"
|
|
#include "xml-support.h"
|
|
#include "gdbcore.h"
|
|
#include "inferior.h"
|
|
|
|
/* Core file support. */
|
|
|
|
/* This vector maps GDB's idea of a register's number into an address
|
|
in the windows exception context vector. */
|
|
|
|
static int i386_windows_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_WINDOWS_SIZEOF_GREGSET 716
|
|
|
|
/* Return the appropriate register set for the core section identified
|
|
by SECT_NAME and SECT_SIZE. */
|
|
|
|
static const struct regset *
|
|
i386_windows_regset_from_core_section (struct gdbarch *gdbarch,
|
|
const char *sect_name, size_t sect_size)
|
|
{
|
|
if (strcmp (sect_name, ".reg") == 0
|
|
&& sect_size == I386_WINDOWS_SIZEOF_GREGSET)
|
|
return &i386_gregset;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
struct cpms_data
|
|
{
|
|
struct gdbarch *gdbarch;
|
|
struct obstack *obstack;
|
|
int module_count;
|
|
};
|
|
|
|
static void
|
|
core_process_module_section (bfd *abfd, asection *sect, void *obj)
|
|
{
|
|
struct cpms_data *data = obj;
|
|
enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
|
|
|
|
char *module_name;
|
|
size_t module_name_size;
|
|
CORE_ADDR base_addr;
|
|
|
|
gdb_byte *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 windows_core_module_info. */
|
|
|
|
base_addr =
|
|
extract_unsigned_integer (buf + 4, 4, byte_order);
|
|
|
|
module_name_size =
|
|
extract_unsigned_integer (buf + 8, 4, byte_order);
|
|
|
|
if (12 + module_name_size > bfd_get_section_size (sect))
|
|
goto out;
|
|
module_name = (char *) buf + 12;
|
|
|
|
/* The first module is the .exe itself. */
|
|
if (data->module_count != 0)
|
|
windows_xfer_shared_library (module_name, base_addr,
|
|
data->gdbarch, data->obstack);
|
|
data->module_count++;
|
|
|
|
out:
|
|
if (buf)
|
|
xfree (buf);
|
|
return;
|
|
}
|
|
|
|
static ULONGEST
|
|
windows_core_xfer_shared_libraries (struct gdbarch *gdbarch,
|
|
gdb_byte *readbuf,
|
|
ULONGEST offset, ULONGEST len)
|
|
{
|
|
struct obstack obstack;
|
|
const char *buf;
|
|
ULONGEST len_avail;
|
|
struct cpms_data data = { gdbarch, &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;
|
|
}
|
|
|
|
/* This is how we want PTIDs from core files to be printed. */
|
|
|
|
static char *
|
|
i386_windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
|
|
{
|
|
static char buf[80];
|
|
|
|
if (ptid_get_lwp (ptid) != 0)
|
|
{
|
|
snprintf (buf, sizeof (buf), "Thread 0x%lx", ptid_get_lwp (ptid));
|
|
return buf;
|
|
}
|
|
|
|
return normal_pid_to_str (ptid);
|
|
}
|
|
|
|
static CORE_ADDR
|
|
i386_cygwin_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
|
|
{
|
|
return i386_pe_skip_trampoline_code (frame, pc, NULL);
|
|
}
|
|
|
|
static const char *
|
|
i386_cygwin_auto_wide_charset (void)
|
|
{
|
|
return "UTF-16";
|
|
}
|
|
|
|
static void
|
|
i386_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
|
|
{
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
|
|
|
windows_init_abi (info, gdbarch);
|
|
|
|
set_gdbarch_skip_trampoline_code (gdbarch, i386_cygwin_skip_trampoline_code);
|
|
|
|
set_gdbarch_skip_main_prologue (gdbarch, i386_skip_main_prologue);
|
|
|
|
tdep->struct_return = reg_struct_return;
|
|
|
|
tdep->gregset_reg_offset = i386_windows_gregset_reg_offset;
|
|
tdep->gregset_num_regs = ARRAY_SIZE (i386_windows_gregset_reg_offset);
|
|
tdep->sizeof_gregset = I386_WINDOWS_SIZEOF_GREGSET;
|
|
|
|
/* Core file support. */
|
|
set_gdbarch_regset_from_core_section
|
|
(gdbarch, i386_windows_regset_from_core_section);
|
|
set_gdbarch_core_xfer_shared_libraries
|
|
(gdbarch, windows_core_xfer_shared_libraries);
|
|
set_gdbarch_core_pid_to_str (gdbarch, i386_windows_core_pid_to_str);
|
|
|
|
set_gdbarch_auto_wide_charset (gdbarch, i386_cygwin_auto_wide_charset);
|
|
}
|
|
|
|
static enum gdb_osabi
|
|
i386_cygwin_osabi_sniffer (bfd *abfd)
|
|
{
|
|
char *target_name = bfd_get_target (abfd);
|
|
|
|
if (strcmp (target_name, "pei-i386") == 0)
|
|
return GDB_OSABI_CYGWIN;
|
|
|
|
/* Cygwin uses elf core dumps. Do not claim all ELF executables,
|
|
check whether there is a .reg section of proper size. */
|
|
if (strcmp (target_name, "elf32-i386") == 0)
|
|
{
|
|
asection *section = bfd_get_section_by_name (abfd, ".reg");
|
|
if (section
|
|
&& bfd_section_size (abfd, section) == I386_WINDOWS_SIZEOF_GREGSET)
|
|
return GDB_OSABI_CYGWIN;
|
|
}
|
|
|
|
return GDB_OSABI_UNKNOWN;
|
|
}
|
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
void _initialize_i386_cygwin_tdep (void);
|
|
|
|
void
|
|
_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);
|
|
}
|