OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [amd64-windows-tdep.c] - Diff between revs 227 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 227 Rev 816
/* Copyright (C) 2009, 2010 Free Software Foundation, Inc.
/* Copyright (C) 2009, 2010 Free Software Foundation, Inc.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   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
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
#include "defs.h"
#include "defs.h"
#include "osabi.h"
#include "osabi.h"
#include "amd64-tdep.h"
#include "amd64-tdep.h"
#include "solib.h"
#include "solib.h"
#include "solib-target.h"
#include "solib-target.h"
#include "gdbtypes.h"
#include "gdbtypes.h"
#include "gdbcore.h"
#include "gdbcore.h"
#include "regcache.h"
#include "regcache.h"
 
 
/* The registers used to pass integer arguments during a function call.  */
/* The registers used to pass integer arguments during a function call.  */
static int amd64_windows_dummy_call_integer_regs[] =
static int amd64_windows_dummy_call_integer_regs[] =
{
{
  AMD64_RCX_REGNUM,          /* %rcx */
  AMD64_RCX_REGNUM,          /* %rcx */
  AMD64_RDX_REGNUM,          /* %rdx */
  AMD64_RDX_REGNUM,          /* %rdx */
  8,                         /* %r8 */
  8,                         /* %r8 */
  9                          /* %r9 */
  9                          /* %r9 */
};
};
 
 
/* Implement the "classify" method in the gdbarch_tdep structure
/* Implement the "classify" method in the gdbarch_tdep structure
   for amd64-windows.  */
   for amd64-windows.  */
 
 
static void
static void
amd64_windows_classify (struct type *type, enum amd64_reg_class class[2])
amd64_windows_classify (struct type *type, enum amd64_reg_class class[2])
{
{
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
      case TYPE_CODE_ARRAY:
      case TYPE_CODE_ARRAY:
        /* Arrays are always passed by memory.  */
        /* Arrays are always passed by memory.  */
        class[0] = class[1] = AMD64_MEMORY;
        class[0] = class[1] = AMD64_MEMORY;
        break;
        break;
 
 
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
      case TYPE_CODE_UNION:
        /* Struct/Union types whose size is 1, 2, 4, or 8 bytes
        /* Struct/Union types whose size is 1, 2, 4, or 8 bytes
           are passed as if they were integers of the same size.
           are passed as if they were integers of the same size.
           Types of different sizes are passed by memory.  */
           Types of different sizes are passed by memory.  */
        if (TYPE_LENGTH (type) == 1
        if (TYPE_LENGTH (type) == 1
            || TYPE_LENGTH (type) == 2
            || TYPE_LENGTH (type) == 2
            || TYPE_LENGTH (type) == 4
            || TYPE_LENGTH (type) == 4
            || TYPE_LENGTH (type) == 8)
            || TYPE_LENGTH (type) == 8)
          {
          {
            class[0] = AMD64_INTEGER;
            class[0] = AMD64_INTEGER;
            class[1] = AMD64_NO_CLASS;
            class[1] = AMD64_NO_CLASS;
          }
          }
        else
        else
          class[0] = class[1] = AMD64_MEMORY;
          class[0] = class[1] = AMD64_MEMORY;
        break;
        break;
 
 
      default:
      default:
        /* For all the other types, the conventions are the same as
        /* For all the other types, the conventions are the same as
           with the System V ABI.  */
           with the System V ABI.  */
        amd64_classify (type, class);
        amd64_classify (type, class);
    }
    }
}
}
 
 
/* Implement the "return_value" gdbarch method for amd64-windows.  */
/* Implement the "return_value" gdbarch method for amd64-windows.  */
 
 
static enum return_value_convention
static enum return_value_convention
amd64_windows_return_value (struct gdbarch *gdbarch, struct type *func_type,
amd64_windows_return_value (struct gdbarch *gdbarch, struct type *func_type,
                            struct type *type, struct regcache *regcache,
                            struct type *type, struct regcache *regcache,
                            gdb_byte *readbuf, const gdb_byte *writebuf)
                            gdb_byte *readbuf, const gdb_byte *writebuf)
{
{
  int len = TYPE_LENGTH (type);
  int len = TYPE_LENGTH (type);
  int regnum = -1;
  int regnum = -1;
 
 
  /* See if our value is returned through a register.  If it is, then
  /* See if our value is returned through a register.  If it is, then
     store the associated register number in REGNUM.  */
     store the associated register number in REGNUM.  */
  switch (TYPE_CODE (type))
  switch (TYPE_CODE (type))
    {
    {
      case TYPE_CODE_FLT:
      case TYPE_CODE_FLT:
      case TYPE_CODE_DECFLOAT:
      case TYPE_CODE_DECFLOAT:
        /* __m128, __m128i, __m128d, floats, and doubles are returned
        /* __m128, __m128i, __m128d, floats, and doubles are returned
           via XMM0.  */
           via XMM0.  */
        if (len == 4 || len == 8 || len == 16)
        if (len == 4 || len == 8 || len == 16)
          regnum = AMD64_XMM0_REGNUM;
          regnum = AMD64_XMM0_REGNUM;
        break;
        break;
      default:
      default:
        /* All other values that are 1, 2, 4 or 8 bytes long are returned
        /* All other values that are 1, 2, 4 or 8 bytes long are returned
           via RAX.  */
           via RAX.  */
        if (len == 1 || len == 2 || len == 4 || len == 8)
        if (len == 1 || len == 2 || len == 4 || len == 8)
          regnum = AMD64_RAX_REGNUM;
          regnum = AMD64_RAX_REGNUM;
        break;
        break;
    }
    }
 
 
  if (regnum < 0)
  if (regnum < 0)
    {
    {
      /* RAX contains the address where the return value has been stored.  */
      /* RAX contains the address where the return value has been stored.  */
      if (readbuf)
      if (readbuf)
        {
        {
          ULONGEST addr;
          ULONGEST addr;
 
 
          regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr);
          regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr);
          read_memory (addr, readbuf, TYPE_LENGTH (type));
          read_memory (addr, readbuf, TYPE_LENGTH (type));
        }
        }
      return RETURN_VALUE_ABI_RETURNS_ADDRESS;
      return RETURN_VALUE_ABI_RETURNS_ADDRESS;
    }
    }
  else
  else
    {
    {
      /* Extract the return value from the register where it was stored.  */
      /* Extract the return value from the register where it was stored.  */
      if (readbuf)
      if (readbuf)
        regcache_raw_read_part (regcache, regnum, 0, len, readbuf);
        regcache_raw_read_part (regcache, regnum, 0, len, readbuf);
      if (writebuf)
      if (writebuf)
        regcache_raw_write_part (regcache, regnum, 0, len, writebuf);
        regcache_raw_write_part (regcache, regnum, 0, len, writebuf);
      return RETURN_VALUE_REGISTER_CONVENTION;
      return RETURN_VALUE_REGISTER_CONVENTION;
    }
    }
}
}
 
 
static void
static void
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
{
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
 
  amd64_init_abi (info, gdbarch);
  amd64_init_abi (info, gdbarch);
 
 
  /* On Windows, "long"s are only 32bit.  */
  /* On Windows, "long"s are only 32bit.  */
  set_gdbarch_long_bit (gdbarch, 32);
  set_gdbarch_long_bit (gdbarch, 32);
 
 
  /* Function calls.  */
  /* Function calls.  */
  tdep->call_dummy_num_integer_regs =
  tdep->call_dummy_num_integer_regs =
    ARRAY_SIZE (amd64_windows_dummy_call_integer_regs);
    ARRAY_SIZE (amd64_windows_dummy_call_integer_regs);
  tdep->call_dummy_integer_regs = amd64_windows_dummy_call_integer_regs;
  tdep->call_dummy_integer_regs = amd64_windows_dummy_call_integer_regs;
  tdep->classify = amd64_windows_classify;
  tdep->classify = amd64_windows_classify;
  tdep->memory_args_by_pointer = 1;
  tdep->memory_args_by_pointer = 1;
  tdep->integer_param_regs_saved_in_caller_frame = 1;
  tdep->integer_param_regs_saved_in_caller_frame = 1;
  set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
  set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
 
 
  set_solib_ops (gdbarch, &solib_target_so_ops);
  set_solib_ops (gdbarch, &solib_target_so_ops);
}
}
 
 
void
void
_initialize_amd64_windows_tdep (void)
_initialize_amd64_windows_tdep (void)
{
{
  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_CYGWIN,
  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_CYGWIN,
                          amd64_windows_init_abi);
                          amd64_windows_init_abi);
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.