merge from gcc
[deliverable/binutils-gdb.git] / gdb / x86-64-tdep.c
CommitLineData
e53bef9f 1/* Target-dependent code for AMD64.
ce0eebec 2
e53bef9f 3 Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
53e95fcf
JS
4 Contributed by Jiri Smid, SuSE Labs.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
22
23#include "defs.h"
c4f35dd8
MK
24#include "arch-utils.h"
25#include "block.h"
26#include "dummy-frame.h"
27#include "frame.h"
28#include "frame-base.h"
29#include "frame-unwind.h"
53e95fcf 30#include "inferior.h"
53e95fcf 31#include "gdbcmd.h"
c4f35dd8
MK
32#include "gdbcore.h"
33#include "objfiles.h"
53e95fcf 34#include "regcache.h"
2c261fae 35#include "regset.h"
53e95fcf 36#include "symfile.h"
c4f35dd8 37
82dbc5f7 38#include "gdb_assert.h"
c4f35dd8
MK
39
40#include "x86-64-tdep.h"
41#include "i387-tdep.h"
53e95fcf 42
e53bef9f
MK
43/* Note that the AMD64 architecture was previously known as x86-64.
44 The latter is (forever) engraved into the canonical system name as
45 returned bu config.guess, and used as the name for the AMD64 port
46 of GNU/Linux. The BSD's have renamed their ports to amd64; they
47 don't like to shout. For GDB we prefer the amd64_-prefix over the
48 x86_64_-prefix since it's so much easier to type. */
49
402ecd56 50/* Register information. */
c4f35dd8 51
e53bef9f 52struct amd64_register_info
de220d0f 53{
de220d0f
ML
54 char *name;
55 struct type **type;
56};
53e95fcf 57
e53bef9f 58static struct amd64_register_info amd64_register_info[] =
c4f35dd8
MK
59{
60 { "rax", &builtin_type_int64 },
61 { "rbx", &builtin_type_int64 },
62 { "rcx", &builtin_type_int64 },
63 { "rdx", &builtin_type_int64 },
64 { "rsi", &builtin_type_int64 },
65 { "rdi", &builtin_type_int64 },
66 { "rbp", &builtin_type_void_data_ptr },
67 { "rsp", &builtin_type_void_data_ptr },
68
69 /* %r8 is indeed register number 8. */
70 { "r8", &builtin_type_int64 },
71 { "r9", &builtin_type_int64 },
72 { "r10", &builtin_type_int64 },
73 { "r11", &builtin_type_int64 },
74 { "r12", &builtin_type_int64 },
75 { "r13", &builtin_type_int64 },
76 { "r14", &builtin_type_int64 },
77 { "r15", &builtin_type_int64 },
78 { "rip", &builtin_type_void_func_ptr },
79 { "eflags", &builtin_type_int32 },
80 { "ds", &builtin_type_int32 },
81 { "es", &builtin_type_int32 },
82 { "fs", &builtin_type_int32 },
83 { "gs", &builtin_type_int32 },
84
85 /* %st0 is register number 22. */
86 { "st0", &builtin_type_i387_ext },
87 { "st1", &builtin_type_i387_ext },
88 { "st2", &builtin_type_i387_ext },
89 { "st3", &builtin_type_i387_ext },
90 { "st4", &builtin_type_i387_ext },
91 { "st5", &builtin_type_i387_ext },
92 { "st6", &builtin_type_i387_ext },
93 { "st7", &builtin_type_i387_ext },
94 { "fctrl", &builtin_type_int32 },
95 { "fstat", &builtin_type_int32 },
96 { "ftag", &builtin_type_int32 },
97 { "fiseg", &builtin_type_int32 },
98 { "fioff", &builtin_type_int32 },
99 { "foseg", &builtin_type_int32 },
100 { "fooff", &builtin_type_int32 },
101 { "fop", &builtin_type_int32 },
102
103 /* %xmm0 is register number 38. */
104 { "xmm0", &builtin_type_v4sf },
105 { "xmm1", &builtin_type_v4sf },
106 { "xmm2", &builtin_type_v4sf },
107 { "xmm3", &builtin_type_v4sf },
108 { "xmm4", &builtin_type_v4sf },
109 { "xmm5", &builtin_type_v4sf },
110 { "xmm6", &builtin_type_v4sf },
111 { "xmm7", &builtin_type_v4sf },
112 { "xmm8", &builtin_type_v4sf },
113 { "xmm9", &builtin_type_v4sf },
114 { "xmm10", &builtin_type_v4sf },
115 { "xmm11", &builtin_type_v4sf },
116 { "xmm12", &builtin_type_v4sf },
117 { "xmm13", &builtin_type_v4sf },
118 { "xmm14", &builtin_type_v4sf },
119 { "xmm15", &builtin_type_v4sf },
120 { "mxcsr", &builtin_type_int32 }
0e04a514
ML
121};
122
c4f35dd8 123/* Total number of registers. */
e53bef9f
MK
124#define AMD64_NUM_REGS \
125 (sizeof (amd64_register_info) / sizeof (amd64_register_info[0]))
de220d0f 126
c4f35dd8 127/* Return the name of register REGNUM. */
b6779aa2 128
c4f35dd8 129static const char *
e53bef9f 130amd64_register_name (int regnum)
53e95fcf 131{
e53bef9f
MK
132 if (regnum >= 0 && regnum < AMD64_NUM_REGS)
133 return amd64_register_info[regnum].name;
53e95fcf 134
c4f35dd8 135 return NULL;
53e95fcf
JS
136}
137
138/* Return the GDB type object for the "standard" data type of data in
c4f35dd8 139 register REGNUM. */
53e95fcf 140
c4f35dd8 141static struct type *
e53bef9f 142amd64_register_type (struct gdbarch *gdbarch, int regnum)
53e95fcf 143{
e53bef9f 144 gdb_assert (regnum >= 0 && regnum < AMD64_NUM_REGS);
4657573b 145
e53bef9f 146 return *amd64_register_info[regnum].type;
53e95fcf
JS
147}
148
c4f35dd8
MK
149/* DWARF Register Number Mapping as defined in the System V psABI,
150 section 3.6. */
53e95fcf 151
e53bef9f 152static int amd64_dwarf_regmap[] =
0e04a514 153{
c4f35dd8 154 /* General Purpose Registers RAX, RDX, RCX, RBX, RSI, RDI. */
f82b2acd 155 X86_64_RAX_REGNUM, X86_64_RDX_REGNUM, 2, 1,
c4f35dd8
MK
156 4, X86_64_RDI_REGNUM,
157
158 /* Frame Pointer Register RBP. */
159 X86_64_RBP_REGNUM,
160
161 /* Stack Pointer Register RSP. */
162 X86_64_RSP_REGNUM,
163
164 /* Extended Integer Registers 8 - 15. */
165 8, 9, 10, 11, 12, 13, 14, 15,
166
59207364
MK
167 /* Return Address RA. Mapped to RIP. */
168 X86_64_RIP_REGNUM,
c4f35dd8
MK
169
170 /* SSE Registers 0 - 7. */
171 X86_64_XMM0_REGNUM + 0, X86_64_XMM1_REGNUM,
172 X86_64_XMM0_REGNUM + 2, X86_64_XMM0_REGNUM + 3,
173 X86_64_XMM0_REGNUM + 4, X86_64_XMM0_REGNUM + 5,
174 X86_64_XMM0_REGNUM + 6, X86_64_XMM0_REGNUM + 7,
175
176 /* Extended SSE Registers 8 - 15. */
177 X86_64_XMM0_REGNUM + 8, X86_64_XMM0_REGNUM + 9,
178 X86_64_XMM0_REGNUM + 10, X86_64_XMM0_REGNUM + 11,
179 X86_64_XMM0_REGNUM + 12, X86_64_XMM0_REGNUM + 13,
180 X86_64_XMM0_REGNUM + 14, X86_64_XMM0_REGNUM + 15,
181
182 /* Floating Point Registers 0-7. */
f82b2acd 183 X86_64_ST0_REGNUM + 0, X86_64_ST0_REGNUM + 1,
c4f35dd8
MK
184 X86_64_ST0_REGNUM + 2, X86_64_ST0_REGNUM + 3,
185 X86_64_ST0_REGNUM + 4, X86_64_ST0_REGNUM + 5,
186 X86_64_ST0_REGNUM + 6, X86_64_ST0_REGNUM + 7
187};
0e04a514 188
e53bef9f
MK
189static const int amd64_dwarf_regmap_len =
190 (sizeof (amd64_dwarf_regmap) / sizeof (amd64_dwarf_regmap[0]));
0e04a514 191
c4f35dd8
MK
192/* Convert DWARF register number REG to the appropriate register
193 number used by GDB. */
26abbdc4 194
c4f35dd8 195static int
e53bef9f 196amd64_dwarf_reg_to_regnum (int reg)
53e95fcf 197{
c4f35dd8 198 int regnum = -1;
53e95fcf 199
e53bef9f
MK
200 if (reg >= 0 || reg < amd64_dwarf_regmap_len)
201 regnum = amd64_dwarf_regmap[reg];
53e95fcf 202
c4f35dd8
MK
203 if (regnum == -1)
204 warning ("Unmapped DWARF Register #%d encountered\n", reg);
205
206 return regnum;
53e95fcf 207}
d532c08f
MK
208
209/* Return nonzero if a value of type TYPE stored in register REGNUM
210 needs any special handling. */
211
212static int
e53bef9f 213amd64_convert_register_p (int regnum, struct type *type)
d532c08f
MK
214{
215 return i386_fp_regnum_p (regnum);
216}
53e95fcf
JS
217\f
218
efb1c01c
MK
219/* Register classes as defined in the psABI. */
220
221enum amd64_reg_class
222{
223 AMD64_INTEGER,
224 AMD64_SSE,
225 AMD64_SSEUP,
226 AMD64_X87,
227 AMD64_X87UP,
228 AMD64_COMPLEX_X87,
229 AMD64_NO_CLASS,
230 AMD64_MEMORY
231};
232
233/* Return the union class of CLASS1 and CLASS2. See the psABI for
234 details. */
235
236static enum amd64_reg_class
237amd64_merge_classes (enum amd64_reg_class class1, enum amd64_reg_class class2)
238{
239 /* Rule (a): If both classes are equal, this is the resulting class. */
240 if (class1 == class2)
241 return class1;
242
243 /* Rule (b): If one of the classes is NO_CLASS, the resulting class
244 is the other class. */
245 if (class1 == AMD64_NO_CLASS)
246 return class2;
247 if (class2 == AMD64_NO_CLASS)
248 return class1;
249
250 /* Rule (c): If one of the classes is MEMORY, the result is MEMORY. */
251 if (class1 == AMD64_MEMORY || class2 == AMD64_MEMORY)
252 return AMD64_MEMORY;
253
254 /* Rule (d): If one of the classes is INTEGER, the result is INTEGER. */
255 if (class1 == AMD64_INTEGER || class2 == AMD64_INTEGER)
256 return AMD64_INTEGER;
257
258 /* Rule (e): If one of the classes is X87, X87UP, COMPLEX_X87 class,
259 MEMORY is used as class. */
260 if (class1 == AMD64_X87 || class1 == AMD64_X87UP
261 || class1 == AMD64_COMPLEX_X87 || class2 == AMD64_X87
262 || class2 == AMD64_X87UP || class2 == AMD64_COMPLEX_X87)
263 return AMD64_MEMORY;
264
265 /* Rule (f): Otherwise class SSE is used. */
266 return AMD64_SSE;
267}
268
269static void amd64_classify (struct type *type, enum amd64_reg_class class[2]);
270
271/* Classify TYPE according to the rules for aggregate (structures and
272 arrays) and union types, and store the result in CLASS. */
c4f35dd8
MK
273
274static void
efb1c01c 275amd64_classify_aggregate (struct type *type, enum amd64_reg_class class[2])
53e95fcf
JS
276{
277 int len = TYPE_LENGTH (type);
278
efb1c01c
MK
279 /* 1. If the size of an object is larger than two eightbytes, or in
280 C++, is a non-POD structure or union type, or contains
281 unaligned fields, it has class memory. */
282 if (len > 16)
53e95fcf 283 {
efb1c01c
MK
284 class[0] = class[1] = AMD64_MEMORY;
285 return;
53e95fcf 286 }
efb1c01c
MK
287
288 /* 2. Both eightbytes get initialized to class NO_CLASS. */
289 class[0] = class[1] = AMD64_NO_CLASS;
290
291 /* 3. Each field of an object is classified recursively so that
292 always two fields are considered. The resulting class is
293 calculated according to the classes of the fields in the
294 eightbyte: */
295
296 if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
8ffd9b1b 297 {
efb1c01c
MK
298 struct type *subtype = check_typedef (TYPE_TARGET_TYPE (type));
299
300 /* All fields in an array have the same type. */
301 amd64_classify (subtype, class);
302 if (len > 8 && class[1] == AMD64_NO_CLASS)
303 class[1] = class[0];
8ffd9b1b 304 }
53e95fcf
JS
305 else
306 {
efb1c01c 307 int i;
53e95fcf 308
efb1c01c
MK
309 /* Structure or union. */
310 gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
311 || TYPE_CODE (type) == TYPE_CODE_UNION);
312
313 for (i = 0; i < TYPE_NFIELDS (type); i++)
53e95fcf 314 {
efb1c01c
MK
315 struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
316 int pos = TYPE_FIELD_BITPOS (type, i) / 64;
317 enum amd64_reg_class subclass[2];
318
319 gdb_assert (pos == 0 || pos == 1);
320
321 amd64_classify (subtype, subclass);
322 class[pos] = amd64_merge_classes (class[pos], subclass[0]);
323 if (pos == 0)
324 class[1] = amd64_merge_classes (class[1], subclass[1]);
53e95fcf 325 }
53e95fcf 326 }
efb1c01c
MK
327
328 /* 4. Then a post merger cleanup is done: */
329
330 /* Rule (a): If one of the classes is MEMORY, the whole argument is
331 passed in memory. */
332 if (class[0] == AMD64_MEMORY || class[1] == AMD64_MEMORY)
333 class[0] = class[1] = AMD64_MEMORY;
334
335 /* Rule (b): If SSEUP is not preceeded by SSE, it is converted to
336 SSE. */
337 if (class[0] == AMD64_SSEUP)
338 class[0] = AMD64_SSE;
339 if (class[1] == AMD64_SSEUP && class[0] != AMD64_SSE)
340 class[1] = AMD64_SSE;
341}
342
343/* Classify TYPE, and store the result in CLASS. */
344
345static void
346amd64_classify (struct type *type, enum amd64_reg_class class[2])
347{
348 enum type_code code = TYPE_CODE (type);
349 int len = TYPE_LENGTH (type);
350
351 class[0] = class[1] = AMD64_NO_CLASS;
352
353 /* Arguments of types (signed and unsigned) _Bool, char, short, int,
354 long, long long, and pointers are in the INTEGER class. */
355 if ((code == TYPE_CODE_INT || code == TYPE_CODE_ENUM
356 || code == TYPE_CODE_PTR || code == TYPE_CODE_REF)
357 && (len == 1 || len == 2 || len == 4 || len == 8))
358 class[0] = AMD64_INTEGER;
359
360 /* Arguments of types float, double and __m64 are in class SSE. */
361 else if (code == TYPE_CODE_FLT && (len == 4 || len == 8))
362 /* FIXME: __m64 . */
363 class[0] = AMD64_SSE;
364
365 /* Arguments of types __float128 and __m128 are split into two
366 halves. The least significant ones belong to class SSE, the most
367 significant one to class SSEUP. */
368 /* FIXME: __float128, __m128. */
369
370 /* The 64-bit mantissa of arguments of type long double belongs to
371 class X87, the 16-bit exponent plus 6 bytes of padding belongs to
372 class X87UP. */
373 else if (code == TYPE_CODE_FLT && len == 16)
374 /* Class X87 and X87UP. */
375 class[0] = AMD64_X87, class[1] = AMD64_X87UP;
376
377 /* Aggregates. */
378 else if (code == TYPE_CODE_ARRAY || code == TYPE_CODE_STRUCT
379 || code == TYPE_CODE_UNION)
380 amd64_classify_aggregate (type, class);
381}
382
383static enum return_value_convention
384amd64_return_value (struct gdbarch *gdbarch, struct type *type,
385 struct regcache *regcache,
386 void *readbuf, const void *writebuf)
387{
388 enum amd64_reg_class class[2];
389 int len = TYPE_LENGTH (type);
390 static int integer_regnum[] = { X86_64_RAX_REGNUM, X86_64_RDX_REGNUM };
391 static int sse_regnum[] = { X86_64_XMM0_REGNUM, X86_64_XMM1_REGNUM };
392 int integer_reg = 0;
393 int sse_reg = 0;
394 int i;
395
396 gdb_assert (!(readbuf && writebuf));
397
398 /* 1. Classify the return type with the classification algorithm. */
399 amd64_classify (type, class);
400
401 /* 2. If the type has class MEMORY, then the caller provides space
402 for the return value and passes the address of this storage in
403 %rdi as if it were the first argument to the function. In
404 effect, this address becomes a hidden first argument. */
405 if (class[0] == AMD64_MEMORY)
406 return RETURN_VALUE_STRUCT_CONVENTION;
407
408 gdb_assert (class[1] != AMD64_MEMORY);
409 gdb_assert (len <= 16);
410
411 for (i = 0; len > 0; i++, len -= 8)
412 {
413 int regnum = -1;
414 int offset = 0;
415
416 switch (class[i])
417 {
418 case AMD64_INTEGER:
419 /* 3. If the class is INTEGER, the next available register
420 of the sequence %rax, %rdx is used. */
421 regnum = integer_regnum[integer_reg++];
422 break;
423
424 case AMD64_SSE:
425 /* 4. If the class is SSE, the next available SSE register
426 of the sequence %xmm0, %xmm1 is used. */
427 regnum = sse_regnum[sse_reg++];
428 break;
429
430 case AMD64_SSEUP:
431 /* 5. If the class is SSEUP, the eightbyte is passed in the
432 upper half of the last used SSE register. */
433 gdb_assert (sse_reg > 0);
434 regnum = sse_regnum[sse_reg - 1];
435 offset = 8;
436 break;
437
438 case AMD64_X87:
439 /* 6. If the class is X87, the value is returned on the X87
440 stack in %st0 as 80-bit x87 number. */
441 regnum = X86_64_ST0_REGNUM;
442 if (writebuf)
443 i387_return_value (gdbarch, regcache);
444 break;
445
446 case AMD64_X87UP:
447 /* 7. If the class is X87UP, the value is returned together
448 with the previous X87 value in %st0. */
449 gdb_assert (i > 0 && class[0] == AMD64_X87);
450 regnum = X86_64_ST0_REGNUM;
451 offset = 8;
452 len = 2;
453 break;
454
455 case AMD64_NO_CLASS:
456 continue;
457
458 default:
459 gdb_assert (!"Unexpected register class.");
460 }
461
462 gdb_assert (regnum != -1);
463
464 if (readbuf)
465 regcache_raw_read_part (regcache, regnum, offset, min (len, 8),
466 (char *) readbuf + i * 8);
467 if (writebuf)
468 regcache_raw_write_part (regcache, regnum, offset, min (len, 8),
469 (const char *) writebuf + i * 8);
470 }
471
472 return RETURN_VALUE_REGISTER_CONVENTION;
53e95fcf
JS
473}
474\f
475
720aa428
MK
476static CORE_ADDR
477amd64_push_arguments (struct regcache *regcache, int nargs,
478 struct value **args, CORE_ADDR sp)
479{
480 static int integer_regnum[] =
481 {
482 X86_64_RDI_REGNUM, 4, /* %rdi, %rsi */
483 X86_64_RDX_REGNUM, 2, /* %rdx, %rcx */
484 8, 9 /* %r8, %r9 */
485 };
486 static int sse_regnum[] =
487 {
488 /* %xmm0 ... %xmm7 */
489 X86_64_XMM0_REGNUM + 0, X86_64_XMM1_REGNUM,
490 X86_64_XMM0_REGNUM + 2, X86_64_XMM0_REGNUM + 3,
491 X86_64_XMM0_REGNUM + 4, X86_64_XMM0_REGNUM + 5,
492 X86_64_XMM0_REGNUM + 6, X86_64_XMM0_REGNUM + 7,
493 };
494 struct value **stack_args = alloca (nargs * sizeof (struct value *));
495 int num_stack_args = 0;
496 int num_elements = 0;
497 int element = 0;
498 int integer_reg = 0;
499 int sse_reg = 0;
500 int i;
501
502 for (i = 0; i < nargs; i++)
503 {
504 struct type *type = VALUE_TYPE (args[i]);
505 int len = TYPE_LENGTH (type);
506 enum amd64_reg_class class[2];
507 int needed_integer_regs = 0;
508 int needed_sse_regs = 0;
509 int j;
510
511 /* Classify argument. */
512 amd64_classify (type, class);
513
514 /* Calculate the number of integer and SSE registers needed for
515 this argument. */
516 for (j = 0; j < 2; j++)
517 {
518 if (class[j] == AMD64_INTEGER)
519 needed_integer_regs++;
520 else if (class[j] == AMD64_SSE)
521 needed_sse_regs++;
522 }
523
524 /* Check whether enough registers are available, and if the
525 argument should be passed in registers at all. */
526 if (integer_reg + needed_integer_regs > ARRAY_SIZE (integer_regnum)
527 || sse_reg + needed_sse_regs > ARRAY_SIZE (sse_regnum)
528 || (needed_integer_regs == 0 && needed_sse_regs == 0))
529 {
530 /* The argument will be passed on the stack. */
531 num_elements += ((len + 7) / 8);
532 stack_args[num_stack_args++] = args[i];
533 }
534 else
535 {
536 /* The argument will be passed in registers. */
537 char *valbuf = VALUE_CONTENTS (args[i]);
538 char buf[8];
539
540 gdb_assert (len <= 16);
541
542 for (j = 0; len > 0; j++, len -= 8)
543 {
544 int regnum = -1;
545 int offset = 0;
546
547 switch (class[j])
548 {
549 case AMD64_INTEGER:
550 regnum = integer_regnum[integer_reg++];
551 break;
552
553 case AMD64_SSE:
554 regnum = sse_regnum[sse_reg++];
555 break;
556
557 case AMD64_SSEUP:
558 gdb_assert (sse_reg > 0);
559 regnum = sse_regnum[sse_reg - 1];
560 offset = 8;
561 break;
562
563 default:
564 gdb_assert (!"Unexpected register class.");
565 }
566
567 gdb_assert (regnum != -1);
568 memset (buf, 0, sizeof buf);
569 memcpy (buf, valbuf + j * 8, min (len, 8));
570 regcache_raw_write_part (regcache, regnum, offset, 8, buf);
571 }
572 }
573 }
574
575 /* Allocate space for the arguments on the stack. */
576 sp -= num_elements * 8;
577
578 /* The psABI says that "The end of the input argument area shall be
579 aligned on a 16 byte boundary." */
580 sp &= ~0xf;
581
582 /* Write out the arguments to the stack. */
583 for (i = 0; i < num_stack_args; i++)
584 {
585 struct type *type = VALUE_TYPE (stack_args[i]);
586 char *valbuf = VALUE_CONTENTS (stack_args[i]);
587 int len = TYPE_LENGTH (type);
588
589 write_memory (sp + element * 8, valbuf, len);
590 element += ((len + 7) / 8);
591 }
592
593 /* The psABI says that "For calls that may call functions that use
594 varargs or stdargs (prototype-less calls or calls to functions
595 containing ellipsis (...) in the declaration) %al is used as
596 hidden argument to specify the number of SSE registers used. */
597 regcache_raw_write_unsigned (regcache, X86_64_RAX_REGNUM, sse_reg);
598 return sp;
599}
600
c4f35dd8 601static CORE_ADDR
e53bef9f
MK
602amd64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
603 struct regcache *regcache, CORE_ADDR bp_addr,
604 int nargs, struct value **args, CORE_ADDR sp,
605 int struct_return, CORE_ADDR struct_addr)
53e95fcf 606{
c4f35dd8
MK
607 char buf[8];
608
609 /* Pass arguments. */
720aa428 610 sp = amd64_push_arguments (regcache, nargs, args, sp);
c4f35dd8
MK
611
612 /* Pass "hidden" argument". */
613 if (struct_return)
614 {
615 store_unsigned_integer (buf, 8, struct_addr);
616 regcache_cooked_write (regcache, X86_64_RDI_REGNUM, buf);
617 }
618
619 /* Store return address. */
620 sp -= 8;
10f93086 621 store_unsigned_integer (buf, 8, bp_addr);
c4f35dd8
MK
622 write_memory (sp, buf, 8);
623
624 /* Finally, update the stack pointer... */
625 store_unsigned_integer (buf, 8, sp);
626 regcache_cooked_write (regcache, X86_64_RSP_REGNUM, buf);
627
628 /* ...and fake a frame pointer. */
629 regcache_cooked_write (regcache, X86_64_RBP_REGNUM, buf);
630
3e210248 631 return sp + 16;
53e95fcf 632}
c4f35dd8
MK
633\f
634
635/* The maximum number of saved registers. This should include %rip. */
e53bef9f 636#define AMD64_NUM_SAVED_REGS X86_64_NUM_GREGS
c4f35dd8 637
e53bef9f 638struct amd64_frame_cache
c4f35dd8
MK
639{
640 /* Base address. */
641 CORE_ADDR base;
642 CORE_ADDR sp_offset;
643 CORE_ADDR pc;
644
645 /* Saved registers. */
e53bef9f 646 CORE_ADDR saved_regs[AMD64_NUM_SAVED_REGS];
c4f35dd8
MK
647 CORE_ADDR saved_sp;
648
649 /* Do we have a frame? */
650 int frameless_p;
651};
8dda9770 652
c4f35dd8
MK
653/* Allocate and initialize a frame cache. */
654
e53bef9f
MK
655static struct amd64_frame_cache *
656amd64_alloc_frame_cache (void)
8dda9770 657{
e53bef9f 658 struct amd64_frame_cache *cache;
c4f35dd8
MK
659 int i;
660
e53bef9f 661 cache = FRAME_OBSTACK_ZALLOC (struct amd64_frame_cache);
8dda9770 662
c4f35dd8
MK
663 /* Base address. */
664 cache->base = 0;
665 cache->sp_offset = -8;
666 cache->pc = 0;
667
668 /* Saved registers. We initialize these to -1 since zero is a valid
669 offset (that's where %rbp is supposed to be stored). */
e53bef9f 670 for (i = 0; i < AMD64_NUM_SAVED_REGS; i++)
c4f35dd8
MK
671 cache->saved_regs[i] = -1;
672 cache->saved_sp = 0;
673
674 /* Frameless until proven otherwise. */
675 cache->frameless_p = 1;
676
677 return cache;
8dda9770 678}
53e95fcf 679
c4f35dd8
MK
680/* Do a limited analysis of the prologue at PC and update CACHE
681 accordingly. Bail out early if CURRENT_PC is reached. Return the
682 address where the analysis stopped.
683
684 We will handle only functions beginning with:
685
686 pushq %rbp 0x55
687 movq %rsp, %rbp 0x48 0x89 0xe5
688
689 Any function that doesn't start with this sequence will be assumed
690 to have no prologue and thus no valid frame pointer in %rbp. */
691
692static CORE_ADDR
e53bef9f
MK
693amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
694 struct amd64_frame_cache *cache)
53e95fcf 695{
c4f35dd8
MK
696 static unsigned char proto[3] = { 0x48, 0x89, 0xe5 };
697 unsigned char buf[3];
698 unsigned char op;
699
700 if (current_pc <= pc)
701 return current_pc;
702
703 op = read_memory_unsigned_integer (pc, 1);
704
705 if (op == 0x55) /* pushq %rbp */
706 {
707 /* Take into account that we've executed the `pushq %rbp' that
708 starts this instruction sequence. */
709 cache->saved_regs[X86_64_RBP_REGNUM] = 0;
710 cache->sp_offset += 8;
711
712 /* If that's all, return now. */
713 if (current_pc <= pc + 1)
714 return current_pc;
715
716 /* Check for `movq %rsp, %rbp'. */
717 read_memory (pc + 1, buf, 3);
718 if (memcmp (buf, proto, 3) != 0)
719 return pc + 1;
720
721 /* OK, we actually have a frame. */
722 cache->frameless_p = 0;
723 return pc + 4;
724 }
725
726 return pc;
53e95fcf
JS
727}
728
c4f35dd8
MK
729/* Return PC of first real instruction. */
730
731static CORE_ADDR
e53bef9f 732amd64_skip_prologue (CORE_ADDR start_pc)
53e95fcf 733{
e53bef9f 734 struct amd64_frame_cache cache;
c4f35dd8
MK
735 CORE_ADDR pc;
736
e53bef9f 737 pc = amd64_analyze_prologue (start_pc, 0xffffffffffffffff, &cache);
c4f35dd8
MK
738 if (cache.frameless_p)
739 return start_pc;
740
741 return pc;
53e95fcf 742}
c4f35dd8 743\f
53e95fcf 744
c4f35dd8
MK
745/* Normal frames. */
746
e53bef9f
MK
747static struct amd64_frame_cache *
748amd64_frame_cache (struct frame_info *next_frame, void **this_cache)
6d686a84 749{
e53bef9f 750 struct amd64_frame_cache *cache;
c4f35dd8 751 char buf[8];
6d686a84 752 int i;
6d686a84 753
c4f35dd8
MK
754 if (*this_cache)
755 return *this_cache;
6d686a84 756
e53bef9f 757 cache = amd64_alloc_frame_cache ();
c4f35dd8
MK
758 *this_cache = cache;
759
c4f35dd8
MK
760 cache->pc = frame_func_unwind (next_frame);
761 if (cache->pc != 0)
e53bef9f 762 amd64_analyze_prologue (cache->pc, frame_pc_unwind (next_frame), cache);
c4f35dd8
MK
763
764 if (cache->frameless_p)
765 {
766 /* We didn't find a valid frame, which means that CACHE->base
767 currently holds the frame pointer for our calling frame. If
768 we're at the start of a function, or somewhere half-way its
769 prologue, the function's frame probably hasn't been fully
770 setup yet. Try to reconstruct the base address for the stack
771 frame by looking at the stack pointer. For truly "frameless"
772 functions this might work too. */
773
774 frame_unwind_register (next_frame, X86_64_RSP_REGNUM, buf);
775 cache->base = extract_unsigned_integer (buf, 8) + cache->sp_offset;
776 }
35883a3f
MK
777 else
778 {
779 frame_unwind_register (next_frame, X86_64_RBP_REGNUM, buf);
780 cache->base = extract_unsigned_integer (buf, 8);
781 }
c4f35dd8
MK
782
783 /* Now that we have the base address for the stack frame we can
784 calculate the value of %rsp in the calling frame. */
785 cache->saved_sp = cache->base + 16;
786
35883a3f
MK
787 /* For normal frames, %rip is stored at 8(%rbp). If we don't have a
788 frame we find it at the same offset from the reconstructed base
789 address. */
790 cache->saved_regs[X86_64_RIP_REGNUM] = 8;
791
c4f35dd8
MK
792 /* Adjust all the saved registers such that they contain addresses
793 instead of offsets. */
e53bef9f 794 for (i = 0; i < AMD64_NUM_SAVED_REGS; i++)
c4f35dd8
MK
795 if (cache->saved_regs[i] != -1)
796 cache->saved_regs[i] += cache->base;
797
798 return cache;
6d686a84
ML
799}
800
c4f35dd8 801static void
e53bef9f
MK
802amd64_frame_this_id (struct frame_info *next_frame, void **this_cache,
803 struct frame_id *this_id)
c4f35dd8 804{
e53bef9f
MK
805 struct amd64_frame_cache *cache =
806 amd64_frame_cache (next_frame, this_cache);
c4f35dd8
MK
807
808 /* This marks the outermost frame. */
809 if (cache->base == 0)
810 return;
811
812 (*this_id) = frame_id_build (cache->base + 16, cache->pc);
813}
e76e1718 814
c4f35dd8 815static void
e53bef9f
MK
816amd64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
817 int regnum, int *optimizedp,
818 enum lval_type *lvalp, CORE_ADDR *addrp,
819 int *realnump, void *valuep)
53e95fcf 820{
e53bef9f
MK
821 struct amd64_frame_cache *cache =
822 amd64_frame_cache (next_frame, this_cache);
e76e1718 823
c4f35dd8 824 gdb_assert (regnum >= 0);
b1ab997b 825
c4f35dd8
MK
826 if (regnum == SP_REGNUM && cache->saved_sp)
827 {
828 *optimizedp = 0;
829 *lvalp = not_lval;
830 *addrp = 0;
831 *realnump = -1;
832 if (valuep)
833 {
834 /* Store the value. */
835 store_unsigned_integer (valuep, 8, cache->saved_sp);
836 }
837 return;
838 }
e76e1718 839
e53bef9f 840 if (regnum < AMD64_NUM_SAVED_REGS && cache->saved_regs[regnum] != -1)
c4f35dd8
MK
841 {
842 *optimizedp = 0;
843 *lvalp = lval_memory;
844 *addrp = cache->saved_regs[regnum];
845 *realnump = -1;
846 if (valuep)
847 {
848 /* Read the value in from memory. */
849 read_memory (*addrp, valuep,
850 register_size (current_gdbarch, regnum));
851 }
852 return;
853 }
e76e1718 854
c4f35dd8
MK
855 frame_register_unwind (next_frame, regnum,
856 optimizedp, lvalp, addrp, realnump, valuep);
857}
e76e1718 858
e53bef9f 859static const struct frame_unwind amd64_frame_unwind =
c4f35dd8
MK
860{
861 NORMAL_FRAME,
e53bef9f
MK
862 amd64_frame_this_id,
863 amd64_frame_prev_register
c4f35dd8 864};
e76e1718 865
c4f35dd8 866static const struct frame_unwind *
e53bef9f 867amd64_frame_sniffer (struct frame_info *next_frame)
c4f35dd8 868{
e53bef9f 869 return &amd64_frame_unwind;
c4f35dd8
MK
870}
871\f
e76e1718 872
c4f35dd8
MK
873/* Signal trampolines. */
874
875/* FIXME: kettenis/20030419: Perhaps, we can unify the 32-bit and
876 64-bit variants. This would require using identical frame caches
877 on both platforms. */
878
e53bef9f
MK
879static struct amd64_frame_cache *
880amd64_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache)
c4f35dd8 881{
e53bef9f 882 struct amd64_frame_cache *cache;
c4f35dd8
MK
883 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
884 CORE_ADDR addr;
885 char buf[8];
2b5e0749 886 int i;
c4f35dd8
MK
887
888 if (*this_cache)
889 return *this_cache;
890
e53bef9f 891 cache = amd64_alloc_frame_cache ();
c4f35dd8
MK
892
893 frame_unwind_register (next_frame, X86_64_RSP_REGNUM, buf);
894 cache->base = extract_unsigned_integer (buf, 8) - 8;
895
896 addr = tdep->sigcontext_addr (next_frame);
2b5e0749 897 gdb_assert (tdep->sc_reg_offset);
e53bef9f 898 gdb_assert (tdep->sc_num_regs <= AMD64_NUM_SAVED_REGS);
2b5e0749
MK
899 for (i = 0; i < tdep->sc_num_regs; i++)
900 if (tdep->sc_reg_offset[i] != -1)
901 cache->saved_regs[i] = addr + tdep->sc_reg_offset[i];
c4f35dd8
MK
902
903 *this_cache = cache;
904 return cache;
53e95fcf
JS
905}
906
c4f35dd8 907static void
e53bef9f
MK
908amd64_sigtramp_frame_this_id (struct frame_info *next_frame,
909 void **this_cache, struct frame_id *this_id)
c4f35dd8 910{
e53bef9f
MK
911 struct amd64_frame_cache *cache =
912 amd64_sigtramp_frame_cache (next_frame, this_cache);
c4f35dd8
MK
913
914 (*this_id) = frame_id_build (cache->base + 16, frame_pc_unwind (next_frame));
915}
916
917static void
e53bef9f
MK
918amd64_sigtramp_frame_prev_register (struct frame_info *next_frame,
919 void **this_cache,
920 int regnum, int *optimizedp,
921 enum lval_type *lvalp, CORE_ADDR *addrp,
922 int *realnump, void *valuep)
c4f35dd8
MK
923{
924 /* Make sure we've initialized the cache. */
e53bef9f 925 amd64_sigtramp_frame_cache (next_frame, this_cache);
c4f35dd8 926
e53bef9f
MK
927 amd64_frame_prev_register (next_frame, this_cache, regnum,
928 optimizedp, lvalp, addrp, realnump, valuep);
c4f35dd8
MK
929}
930
e53bef9f 931static const struct frame_unwind amd64_sigtramp_frame_unwind =
c4f35dd8
MK
932{
933 SIGTRAMP_FRAME,
e53bef9f
MK
934 amd64_sigtramp_frame_this_id,
935 amd64_sigtramp_frame_prev_register
c4f35dd8
MK
936};
937
938static const struct frame_unwind *
e53bef9f 939amd64_sigtramp_frame_sniffer (struct frame_info *next_frame)
c4f35dd8 940{
336d1bba 941 CORE_ADDR pc = frame_pc_unwind (next_frame);
c4f35dd8
MK
942 char *name;
943
944 find_pc_partial_function (pc, &name, NULL, NULL);
945 if (PC_IN_SIGTRAMP (pc, name))
1c3545ae
MK
946 {
947 gdb_assert (gdbarch_tdep (current_gdbarch)->sigcontext_addr);
948
e53bef9f 949 return &amd64_sigtramp_frame_unwind;
1c3545ae 950 }
c4f35dd8
MK
951
952 return NULL;
953}
954\f
955
956static CORE_ADDR
e53bef9f 957amd64_frame_base_address (struct frame_info *next_frame, void **this_cache)
c4f35dd8 958{
e53bef9f
MK
959 struct amd64_frame_cache *cache =
960 amd64_frame_cache (next_frame, this_cache);
c4f35dd8
MK
961
962 return cache->base;
963}
964
e53bef9f 965static const struct frame_base amd64_frame_base =
c4f35dd8 966{
e53bef9f
MK
967 &amd64_frame_unwind,
968 amd64_frame_base_address,
969 amd64_frame_base_address,
970 amd64_frame_base_address
c4f35dd8
MK
971};
972
166f4c7b 973static struct frame_id
e53bef9f 974amd64_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
166f4c7b 975{
c4f35dd8
MK
976 char buf[8];
977 CORE_ADDR fp;
978
979 frame_unwind_register (next_frame, X86_64_RBP_REGNUM, buf);
980 fp = extract_unsigned_integer (buf, 8);
981
982 return frame_id_build (fp + 16, frame_pc_unwind (next_frame));
166f4c7b
ML
983}
984
8b148df9
AC
985/* 16 byte align the SP per frame requirements. */
986
987static CORE_ADDR
e53bef9f 988amd64_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
8b148df9
AC
989{
990 return sp & -(CORE_ADDR)16;
991}
473f17b0
MK
992\f
993
994/* Supply register REGNUM from the floating-point register set REGSET
995 to register cache REGCACHE. If REGNUM is -1, do this for all
996 registers in REGSET. */
997
998static void
e53bef9f
MK
999amd64_supply_fpregset (const struct regset *regset, struct regcache *regcache,
1000 int regnum, const void *fpregs, size_t len)
473f17b0
MK
1001{
1002 const struct gdbarch_tdep *tdep = regset->descr;
1003
1004 gdb_assert (len == tdep->sizeof_fpregset);
1005 x86_64_supply_fxsave (regcache, regnum, fpregs);
1006}
8b148df9 1007
c6b33596
MK
1008/* Return the appropriate register set for the core section identified
1009 by SECT_NAME and SECT_SIZE. */
1010
1011static const struct regset *
e53bef9f
MK
1012amd64_regset_from_core_section (struct gdbarch *gdbarch,
1013 const char *sect_name, size_t sect_size)
c6b33596
MK
1014{
1015 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1016
1017 if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
1018 {
1019 if (tdep->fpregset == NULL)
1020 {
1021 tdep->fpregset = XMALLOC (struct regset);
1022 tdep->fpregset->descr = tdep;
e53bef9f 1023 tdep->fpregset->supply_regset = amd64_supply_fpregset;
c6b33596
MK
1024 }
1025
1026 return tdep->fpregset;
1027 }
1028
1029 return i386_regset_from_core_section (gdbarch, sect_name, sect_size);
1030}
1031\f
1032
2213a65d 1033void
0c1a73d6 1034x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
53e95fcf 1035{
0c1a73d6 1036 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
53e95fcf 1037
473f17b0
MK
1038 /* AMD64 generally uses `fxsave' instead of `fsave' for saving its
1039 floating-point registers. */
1040 tdep->sizeof_fpregset = I387_SIZEOF_FXSAVE;
1041
5716833c
MK
1042 /* AMD64 has an FPU and 16 SSE registers. */
1043 tdep->st0_regnum = X86_64_ST0_REGNUM;
0c1a73d6 1044 tdep->num_xmm_regs = 16;
53e95fcf 1045
0c1a73d6 1046 /* This is what all the fuss is about. */
53e95fcf
JS
1047 set_gdbarch_long_bit (gdbarch, 64);
1048 set_gdbarch_long_long_bit (gdbarch, 64);
1049 set_gdbarch_ptr_bit (gdbarch, 64);
1050
e53bef9f
MK
1051 /* In contrast to the i386, on AMD64 a `long double' actually takes
1052 up 128 bits, even though it's still based on the i387 extended
1053 floating-point format which has only 80 significant bits. */
b83b026c
MK
1054 set_gdbarch_long_double_bit (gdbarch, 128);
1055
e53bef9f
MK
1056 set_gdbarch_num_regs (gdbarch, AMD64_NUM_REGS);
1057 set_gdbarch_register_name (gdbarch, amd64_register_name);
1058 set_gdbarch_register_type (gdbarch, amd64_register_type);
b83b026c
MK
1059
1060 /* Register numbers of various important registers. */
c4f35dd8
MK
1061 set_gdbarch_sp_regnum (gdbarch, X86_64_RSP_REGNUM); /* %rsp */
1062 set_gdbarch_pc_regnum (gdbarch, X86_64_RIP_REGNUM); /* %rip */
1063 set_gdbarch_ps_regnum (gdbarch, X86_64_EFLAGS_REGNUM); /* %eflags */
1064 set_gdbarch_fp0_regnum (gdbarch, X86_64_ST0_REGNUM); /* %st(0) */
b83b026c 1065
e53bef9f
MK
1066 /* The "default" register numbering scheme for AMD64 is referred to
1067 as the "DWARF Register Number Mapping" in the System V psABI.
1068 The preferred debugging format for all known AMD64 targets is
1069 actually DWARF2, and GCC doesn't seem to support DWARF (that is
1070 DWARF-1), but we provide the same mapping just in case. This
1071 mapping is also used for stabs, which GCC does support. */
1072 set_gdbarch_stab_reg_to_regnum (gdbarch, amd64_dwarf_reg_to_regnum);
1073 set_gdbarch_dwarf_reg_to_regnum (gdbarch, amd64_dwarf_reg_to_regnum);
1074 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, amd64_dwarf_reg_to_regnum);
de220d0f 1075
c4f35dd8 1076 /* We don't override SDB_REG_RO_REGNUM, since COFF doesn't seem to
e53bef9f 1077 be in use on any of the supported AMD64 targets. */
53e95fcf 1078
c4f35dd8 1079 /* Call dummy code. */
e53bef9f
MK
1080 set_gdbarch_push_dummy_call (gdbarch, amd64_push_dummy_call);
1081 set_gdbarch_frame_align (gdbarch, amd64_frame_align);
8b148df9 1082 set_gdbarch_frame_red_zone_size (gdbarch, 128);
53e95fcf 1083
e53bef9f 1084 set_gdbarch_convert_register_p (gdbarch, amd64_convert_register_p);
d532c08f
MK
1085 set_gdbarch_register_to_value (gdbarch, i387_register_to_value);
1086 set_gdbarch_value_to_register (gdbarch, i387_value_to_register);
1087
efb1c01c 1088 set_gdbarch_return_value (gdbarch, amd64_return_value);
e53bef9f 1089 /* Override, since this is handled by amd64_extract_return_value. */
b83b026c 1090 set_gdbarch_extract_struct_value_address (gdbarch, NULL);
53e95fcf 1091
e53bef9f 1092 set_gdbarch_skip_prologue (gdbarch, amd64_skip_prologue);
53e95fcf 1093
c4f35dd8 1094 /* Avoid wiring in the MMX registers for now. */
2213a65d 1095 set_gdbarch_num_pseudo_regs (gdbarch, 0);
5716833c 1096 tdep->mm0_regnum = -1;
2213a65d 1097
e53bef9f 1098 set_gdbarch_unwind_dummy_id (gdbarch, amd64_unwind_dummy_id);
53e95fcf 1099
b83b026c 1100 /* FIXME: kettenis/20021026: This is ELF-specific. Fine for now,
e53bef9f 1101 since all supported AMD64 targets are ELF, but that might change
b83b026c 1102 in the future. */
8a8ab2b9 1103 set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
c4f35dd8 1104
e53bef9f
MK
1105 frame_unwind_append_sniffer (gdbarch, amd64_sigtramp_frame_sniffer);
1106 frame_unwind_append_sniffer (gdbarch, amd64_frame_sniffer);
1107 frame_base_set_default (gdbarch, &amd64_frame_base);
c6b33596
MK
1108
1109 /* If we have a register mapping, enable the generic core file support. */
1110 if (tdep->gregset_reg_offset)
1111 set_gdbarch_regset_from_core_section (gdbarch,
e53bef9f 1112 amd64_regset_from_core_section);
c4f35dd8
MK
1113}
1114\f
1115
5716833c 1116#define I387_ST0_REGNUM X86_64_ST0_REGNUM
c4f35dd8 1117
41d041d6
MK
1118/* The 64-bit FXSAVE format differs from the 32-bit format in the
1119 sense that the instruction pointer and data pointer are simply
1120 64-bit offsets into the code segment and the data segment instead
1121 of a selector offset pair. The functions below store the upper 32
1122 bits of these pointers (instead of just the 16-bits of the segment
1123 selector). */
1124
1125/* Fill register REGNUM in REGCACHE with the appropriate
0485f6ad
MK
1126 floating-point or SSE register value from *FXSAVE. If REGNUM is
1127 -1, do this for all registers. This function masks off any of the
1128 reserved bits in *FXSAVE. */
c4f35dd8
MK
1129
1130void
41d041d6
MK
1131x86_64_supply_fxsave (struct regcache *regcache, int regnum,
1132 const void *fxsave)
c4f35dd8 1133{
41d041d6 1134 i387_supply_fxsave (regcache, regnum, fxsave);
c4f35dd8
MK
1135
1136 if (fxsave)
1137 {
41d041d6
MK
1138 const char *regs = fxsave;
1139
0485f6ad 1140 if (regnum == -1 || regnum == I387_FISEG_REGNUM)
41d041d6 1141 regcache_raw_supply (regcache, I387_FISEG_REGNUM, regs + 12);
0485f6ad 1142 if (regnum == -1 || regnum == I387_FOSEG_REGNUM)
41d041d6 1143 regcache_raw_supply (regcache, I387_FOSEG_REGNUM, regs + 20);
c4f35dd8 1144 }
0c1a73d6
MK
1145}
1146
c4f35dd8 1147/* Fill register REGNUM (if it is a floating-point or SSE register) in
0485f6ad 1148 *FXSAVE with the value in GDB's register cache. If REGNUM is -1, do
c4f35dd8
MK
1149 this for all registers. This function doesn't touch any of the
1150 reserved bits in *FXSAVE. */
1151
53e95fcf 1152void
c4f35dd8 1153x86_64_fill_fxsave (char *fxsave, int regnum)
53e95fcf 1154{
c4f35dd8 1155 i387_fill_fxsave (fxsave, regnum);
53e95fcf 1156
c4f35dd8 1157 if (regnum == -1 || regnum == I387_FISEG_REGNUM)
088ce440 1158 regcache_collect (I387_FISEG_REGNUM, fxsave + 12);
c4f35dd8 1159 if (regnum == -1 || regnum == I387_FOSEG_REGNUM)
088ce440 1160 regcache_collect (I387_FOSEG_REGNUM, fxsave + 20);
53e95fcf 1161}
This page took 0.528231 seconds and 4 git commands to generate.