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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [amd64-windows-tdep.c] - Blame information for rev 280

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
/* Copyright (C) 2009, 2010 Free Software Foundation, Inc.
2
 
3
   This file is part of GDB.
4
 
5
   This program is free software; you can redistribute it and/or modify
6
   it under the terms of the GNU General Public License as published by
7
   the Free Software Foundation; either version 3 of the License, or
8
   (at your option) any later version.
9
 
10
   This program is distributed in the hope that it will be useful,
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
 
18
#include "defs.h"
19
#include "osabi.h"
20
#include "amd64-tdep.h"
21
#include "solib.h"
22
#include "solib-target.h"
23
#include "gdbtypes.h"
24
#include "gdbcore.h"
25
#include "regcache.h"
26
 
27
/* The registers used to pass integer arguments during a function call.  */
28
static int amd64_windows_dummy_call_integer_regs[] =
29
{
30
  AMD64_RCX_REGNUM,          /* %rcx */
31
  AMD64_RDX_REGNUM,          /* %rdx */
32
  8,                         /* %r8 */
33
  9                          /* %r9 */
34
};
35
 
36
/* Implement the "classify" method in the gdbarch_tdep structure
37
   for amd64-windows.  */
38
 
39
static void
40
amd64_windows_classify (struct type *type, enum amd64_reg_class class[2])
41
{
42
  switch (TYPE_CODE (type))
43
    {
44
      case TYPE_CODE_ARRAY:
45
        /* Arrays are always passed by memory.  */
46
        class[0] = class[1] = AMD64_MEMORY;
47
        break;
48
 
49
      case TYPE_CODE_STRUCT:
50
      case TYPE_CODE_UNION:
51
        /* Struct/Union types whose size is 1, 2, 4, or 8 bytes
52
           are passed as if they were integers of the same size.
53
           Types of different sizes are passed by memory.  */
54
        if (TYPE_LENGTH (type) == 1
55
            || TYPE_LENGTH (type) == 2
56
            || TYPE_LENGTH (type) == 4
57
            || TYPE_LENGTH (type) == 8)
58
          {
59
            class[0] = AMD64_INTEGER;
60
            class[1] = AMD64_NO_CLASS;
61
          }
62
        else
63
          class[0] = class[1] = AMD64_MEMORY;
64
        break;
65
 
66
      default:
67
        /* For all the other types, the conventions are the same as
68
           with the System V ABI.  */
69
        amd64_classify (type, class);
70
    }
71
}
72
 
73
/* Implement the "return_value" gdbarch method for amd64-windows.  */
74
 
75
static enum return_value_convention
76
amd64_windows_return_value (struct gdbarch *gdbarch, struct type *func_type,
77
                            struct type *type, struct regcache *regcache,
78
                            gdb_byte *readbuf, const gdb_byte *writebuf)
79
{
80
  int len = TYPE_LENGTH (type);
81
  int regnum = -1;
82
 
83
  /* See if our value is returned through a register.  If it is, then
84
     store the associated register number in REGNUM.  */
85
  switch (TYPE_CODE (type))
86
    {
87
      case TYPE_CODE_FLT:
88
      case TYPE_CODE_DECFLOAT:
89
        /* __m128, __m128i, __m128d, floats, and doubles are returned
90
           via XMM0.  */
91
        if (len == 4 || len == 8 || len == 16)
92
          regnum = AMD64_XMM0_REGNUM;
93
        break;
94
      default:
95
        /* All other values that are 1, 2, 4 or 8 bytes long are returned
96
           via RAX.  */
97
        if (len == 1 || len == 2 || len == 4 || len == 8)
98
          regnum = AMD64_RAX_REGNUM;
99
        break;
100
    }
101
 
102
  if (regnum < 0)
103
    {
104
      /* RAX contains the address where the return value has been stored.  */
105
      if (readbuf)
106
        {
107
          ULONGEST addr;
108
 
109
          regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr);
110
          read_memory (addr, readbuf, TYPE_LENGTH (type));
111
        }
112
      return RETURN_VALUE_ABI_RETURNS_ADDRESS;
113
    }
114
  else
115
    {
116
      /* Extract the return value from the register where it was stored.  */
117
      if (readbuf)
118
        regcache_raw_read_part (regcache, regnum, 0, len, readbuf);
119
      if (writebuf)
120
        regcache_raw_write_part (regcache, regnum, 0, len, writebuf);
121
      return RETURN_VALUE_REGISTER_CONVENTION;
122
    }
123
}
124
 
125
static void
126
amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
127
{
128
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
129
 
130
  amd64_init_abi (info, gdbarch);
131
 
132
  /* On Windows, "long"s are only 32bit.  */
133
  set_gdbarch_long_bit (gdbarch, 32);
134
 
135
  /* Function calls.  */
136
  tdep->call_dummy_num_integer_regs =
137
    ARRAY_SIZE (amd64_windows_dummy_call_integer_regs);
138
  tdep->call_dummy_integer_regs = amd64_windows_dummy_call_integer_regs;
139
  tdep->classify = amd64_windows_classify;
140
  tdep->memory_args_by_pointer = 1;
141
  tdep->integer_param_regs_saved_in_caller_frame = 1;
142
  set_gdbarch_return_value (gdbarch, amd64_windows_return_value);
143
 
144
  set_solib_ops (gdbarch, &solib_target_so_ops);
145
}
146
 
147
void
148
_initialize_amd64_windows_tdep (void)
149
{
150
  gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_CYGWIN,
151
                          amd64_windows_init_abi);
152
}
153
 

powered by: WebSVN 2.1.0

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