* i386-tdep.h: Put opaque declarations in alphabetical
[deliverable/binutils-gdb.git] / gdb / x86-64-tdep.c
1 /* Target-dependent code for the x86-64 for GDB, the GNU debugger.
2
3 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
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"
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"
30 #include "inferior.h"
31 #include "gdbcmd.h"
32 #include "gdbcore.h"
33 #include "objfiles.h"
34 #include "regcache.h"
35 #include "symfile.h"
36
37 #include "gdb_assert.h"
38
39 #include "x86-64-tdep.h"
40 #include "i387-tdep.h"
41
42 /* Register information. */
43
44 struct x86_64_register_info
45 {
46 char *name;
47 struct type **type;
48 };
49
50 static struct x86_64_register_info x86_64_register_info[] =
51 {
52 { "rax", &builtin_type_int64 },
53 { "rbx", &builtin_type_int64 },
54 { "rcx", &builtin_type_int64 },
55 { "rdx", &builtin_type_int64 },
56 { "rsi", &builtin_type_int64 },
57 { "rdi", &builtin_type_int64 },
58 { "rbp", &builtin_type_void_data_ptr },
59 { "rsp", &builtin_type_void_data_ptr },
60
61 /* %r8 is indeed register number 8. */
62 { "r8", &builtin_type_int64 },
63 { "r9", &builtin_type_int64 },
64 { "r10", &builtin_type_int64 },
65 { "r11", &builtin_type_int64 },
66 { "r12", &builtin_type_int64 },
67 { "r13", &builtin_type_int64 },
68 { "r14", &builtin_type_int64 },
69 { "r15", &builtin_type_int64 },
70 { "rip", &builtin_type_void_func_ptr },
71 { "eflags", &builtin_type_int32 },
72 { "ds", &builtin_type_int32 },
73 { "es", &builtin_type_int32 },
74 { "fs", &builtin_type_int32 },
75 { "gs", &builtin_type_int32 },
76
77 /* %st0 is register number 22. */
78 { "st0", &builtin_type_i387_ext },
79 { "st1", &builtin_type_i387_ext },
80 { "st2", &builtin_type_i387_ext },
81 { "st3", &builtin_type_i387_ext },
82 { "st4", &builtin_type_i387_ext },
83 { "st5", &builtin_type_i387_ext },
84 { "st6", &builtin_type_i387_ext },
85 { "st7", &builtin_type_i387_ext },
86 { "fctrl", &builtin_type_int32 },
87 { "fstat", &builtin_type_int32 },
88 { "ftag", &builtin_type_int32 },
89 { "fiseg", &builtin_type_int32 },
90 { "fioff", &builtin_type_int32 },
91 { "foseg", &builtin_type_int32 },
92 { "fooff", &builtin_type_int32 },
93 { "fop", &builtin_type_int32 },
94
95 /* %xmm0 is register number 38. */
96 { "xmm0", &builtin_type_v4sf },
97 { "xmm1", &builtin_type_v4sf },
98 { "xmm2", &builtin_type_v4sf },
99 { "xmm3", &builtin_type_v4sf },
100 { "xmm4", &builtin_type_v4sf },
101 { "xmm5", &builtin_type_v4sf },
102 { "xmm6", &builtin_type_v4sf },
103 { "xmm7", &builtin_type_v4sf },
104 { "xmm8", &builtin_type_v4sf },
105 { "xmm9", &builtin_type_v4sf },
106 { "xmm10", &builtin_type_v4sf },
107 { "xmm11", &builtin_type_v4sf },
108 { "xmm12", &builtin_type_v4sf },
109 { "xmm13", &builtin_type_v4sf },
110 { "xmm14", &builtin_type_v4sf },
111 { "xmm15", &builtin_type_v4sf },
112 { "mxcsr", &builtin_type_int32 }
113 };
114
115 /* Total number of registers. */
116 #define X86_64_NUM_REGS \
117 (sizeof (x86_64_register_info) / sizeof (x86_64_register_info[0]))
118
119 /* Return the name of register REGNUM. */
120
121 static const char *
122 x86_64_register_name (int regnum)
123 {
124 if (regnum >= 0 && regnum < X86_64_NUM_REGS)
125 return x86_64_register_info[regnum].name;
126
127 return NULL;
128 }
129
130 /* Return the GDB type object for the "standard" data type of data in
131 register REGNUM. */
132
133 static struct type *
134 x86_64_register_type (struct gdbarch *gdbarch, int regnum)
135 {
136 gdb_assert (regnum >= 0 && regnum < X86_64_NUM_REGS);
137
138 return *x86_64_register_info[regnum].type;
139 }
140
141 /* DWARF Register Number Mapping as defined in the System V psABI,
142 section 3.6. */
143
144 static int x86_64_dwarf_regmap[] =
145 {
146 /* General Purpose Registers RAX, RDX, RCX, RBX, RSI, RDI. */
147 X86_64_RAX_REGNUM, X86_64_RDX_REGNUM, 2, 1,
148 4, X86_64_RDI_REGNUM,
149
150 /* Frame Pointer Register RBP. */
151 X86_64_RBP_REGNUM,
152
153 /* Stack Pointer Register RSP. */
154 X86_64_RSP_REGNUM,
155
156 /* Extended Integer Registers 8 - 15. */
157 8, 9, 10, 11, 12, 13, 14, 15,
158
159 /* Return Address RA. Not mapped. */
160 -1,
161
162 /* SSE Registers 0 - 7. */
163 X86_64_XMM0_REGNUM + 0, X86_64_XMM1_REGNUM,
164 X86_64_XMM0_REGNUM + 2, X86_64_XMM0_REGNUM + 3,
165 X86_64_XMM0_REGNUM + 4, X86_64_XMM0_REGNUM + 5,
166 X86_64_XMM0_REGNUM + 6, X86_64_XMM0_REGNUM + 7,
167
168 /* Extended SSE Registers 8 - 15. */
169 X86_64_XMM0_REGNUM + 8, X86_64_XMM0_REGNUM + 9,
170 X86_64_XMM0_REGNUM + 10, X86_64_XMM0_REGNUM + 11,
171 X86_64_XMM0_REGNUM + 12, X86_64_XMM0_REGNUM + 13,
172 X86_64_XMM0_REGNUM + 14, X86_64_XMM0_REGNUM + 15,
173
174 /* Floating Point Registers 0-7. */
175 X86_64_ST0_REGNUM + 0, X86_64_ST0_REGNUM + 1,
176 X86_64_ST0_REGNUM + 2, X86_64_ST0_REGNUM + 3,
177 X86_64_ST0_REGNUM + 4, X86_64_ST0_REGNUM + 5,
178 X86_64_ST0_REGNUM + 6, X86_64_ST0_REGNUM + 7
179 };
180
181 static const int x86_64_dwarf_regmap_len =
182 (sizeof (x86_64_dwarf_regmap) / sizeof (x86_64_dwarf_regmap[0]));
183
184 /* Convert DWARF register number REG to the appropriate register
185 number used by GDB. */
186
187 static int
188 x86_64_dwarf_reg_to_regnum (int reg)
189 {
190 int regnum = -1;
191
192 if (reg >= 0 || reg < x86_64_dwarf_regmap_len)
193 regnum = x86_64_dwarf_regmap[reg];
194
195 if (regnum == -1)
196 warning ("Unmapped DWARF Register #%d encountered\n", reg);
197
198 return regnum;
199 }
200
201 /* Return nonzero if a value of type TYPE stored in register REGNUM
202 needs any special handling. */
203
204 static int
205 x86_64_convert_register_p (int regnum, struct type *type)
206 {
207 return i386_fp_regnum_p (regnum);
208 }
209 \f
210
211 /* The returning of values is done according to the special algorithm.
212 Some types are returned in registers an some (big structures) in
213 memory. See the System V psABI for details. */
214
215 #define MAX_CLASSES 4
216
217 enum x86_64_reg_class
218 {
219 X86_64_NO_CLASS,
220 X86_64_INTEGER_CLASS,
221 X86_64_INTEGERSI_CLASS,
222 X86_64_SSE_CLASS,
223 X86_64_SSESF_CLASS,
224 X86_64_SSEDF_CLASS,
225 X86_64_SSEUP_CLASS,
226 X86_64_X87_CLASS,
227 X86_64_X87UP_CLASS,
228 X86_64_MEMORY_CLASS
229 };
230
231 /* Return the union class of CLASS1 and CLASS2.
232 See the System V psABI for details. */
233
234 static enum x86_64_reg_class
235 merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
236 {
237 /* Rule (a): If both classes are equal, this is the resulting class. */
238 if (class1 == class2)
239 return class1;
240
241 /* Rule (b): If one of the classes is NO_CLASS, the resulting class
242 is the other class. */
243 if (class1 == X86_64_NO_CLASS)
244 return class2;
245 if (class2 == X86_64_NO_CLASS)
246 return class1;
247
248 /* Rule (c): If one of the classes is MEMORY, the result is MEMORY. */
249 if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
250 return X86_64_MEMORY_CLASS;
251
252 /* Rule (d): If one of the classes is INTEGER, the result is INTEGER. */
253 if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
254 || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
255 return X86_64_INTEGERSI_CLASS;
256 if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
257 || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
258 return X86_64_INTEGER_CLASS;
259
260 /* Rule (e): If one of the classes is X87 or X87UP class, MEMORY is
261 used as class. */
262 if (class1 == X86_64_X87_CLASS || class1 == X86_64_X87UP_CLASS
263 || class2 == X86_64_X87_CLASS || class2 == X86_64_X87UP_CLASS)
264 return X86_64_MEMORY_CLASS;
265
266 /* Rule (f): Otherwise class SSE is used. */
267 return X86_64_SSE_CLASS;
268 }
269
270 /* Classify the argument type. CLASSES will be filled by the register
271 class used to pass each word of the operand. The number of words
272 is returned. In case the parameter should be passed in memory, 0
273 is returned. As a special case for zero sized containers,
274 classes[0] will be NO_CLASS and 1 is returned.
275
276 See the System V psABI for details. */
277
278 static int
279 classify_argument (struct type *type,
280 enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
281 {
282 int bytes = TYPE_LENGTH (type);
283 int words = (bytes + 8 - 1) / 8;
284
285 switch (TYPE_CODE (type))
286 {
287 case TYPE_CODE_ARRAY:
288 case TYPE_CODE_STRUCT:
289 case TYPE_CODE_UNION:
290 {
291 int i;
292 enum x86_64_reg_class subclasses[MAX_CLASSES];
293
294 /* On x86-64 we pass structures larger than 16 bytes on the stack. */
295 if (bytes > 16)
296 return 0;
297
298 for (i = 0; i < words; i++)
299 classes[i] = X86_64_NO_CLASS;
300
301 /* Zero sized arrays or structures are NO_CLASS. We return 0
302 to signalize memory class, so handle it as special case. */
303 if (!words)
304 {
305 classes[0] = X86_64_NO_CLASS;
306 return 1;
307 }
308 switch (TYPE_CODE (type))
309 {
310 case TYPE_CODE_STRUCT:
311 {
312 int j;
313 for (j = 0; j < TYPE_NFIELDS (type); ++j)
314 {
315 int num = classify_argument (TYPE_FIELDS (type)[j].type,
316 subclasses,
317 (TYPE_FIELDS (type)[j].loc.
318 bitpos + bit_offset) % 256);
319 if (!num)
320 return 0;
321 for (i = 0; i < num; i++)
322 {
323 int pos =
324 (TYPE_FIELDS (type)[j].loc.bitpos +
325 bit_offset) / 8 / 8;
326 classes[i + pos] =
327 merge_classes (subclasses[i], classes[i + pos]);
328 }
329 }
330 }
331 break;
332 case TYPE_CODE_ARRAY:
333 {
334 int num;
335
336 num = classify_argument (TYPE_TARGET_TYPE (type),
337 subclasses, bit_offset);
338 if (!num)
339 return 0;
340
341 /* The partial classes are now full classes. */
342 if (subclasses[0] == X86_64_SSESF_CLASS && bytes != 4)
343 subclasses[0] = X86_64_SSE_CLASS;
344 if (subclasses[0] == X86_64_INTEGERSI_CLASS && bytes != 4)
345 subclasses[0] = X86_64_INTEGER_CLASS;
346
347 for (i = 0; i < words; i++)
348 classes[i] = subclasses[i % num];
349 }
350 break;
351 case TYPE_CODE_UNION:
352 {
353 int j;
354 {
355 for (j = 0; j < TYPE_NFIELDS (type); ++j)
356 {
357 int num;
358 num = classify_argument (TYPE_FIELDS (type)[j].type,
359 subclasses, bit_offset);
360 if (!num)
361 return 0;
362 for (i = 0; i < num; i++)
363 classes[i] = merge_classes (subclasses[i], classes[i]);
364 }
365 }
366 }
367 break;
368 default:
369 break;
370 }
371 /* Final merger cleanup. */
372 for (i = 0; i < words; i++)
373 {
374 /* If one class is MEMORY, everything should be passed in
375 memory. */
376 if (classes[i] == X86_64_MEMORY_CLASS)
377 return 0;
378
379 /* The X86_64_SSEUP_CLASS should be always preceeded by
380 X86_64_SSE_CLASS. */
381 if (classes[i] == X86_64_SSEUP_CLASS
382 && (i == 0 || classes[i - 1] != X86_64_SSE_CLASS))
383 classes[i] = X86_64_SSE_CLASS;
384
385 /* X86_64_X87UP_CLASS should be preceeded by X86_64_X87_CLASS. */
386 if (classes[i] == X86_64_X87UP_CLASS
387 && (i == 0 || classes[i - 1] != X86_64_X87_CLASS))
388 classes[i] = X86_64_SSE_CLASS;
389 }
390 return words;
391 }
392 break;
393 case TYPE_CODE_FLT:
394 switch (bytes)
395 {
396 case 4:
397 if (!(bit_offset % 64))
398 classes[0] = X86_64_SSESF_CLASS;
399 else
400 classes[0] = X86_64_SSE_CLASS;
401 return 1;
402 case 8:
403 classes[0] = X86_64_SSEDF_CLASS;
404 return 1;
405 case 16:
406 classes[0] = X86_64_X87_CLASS;
407 classes[1] = X86_64_X87UP_CLASS;
408 return 2;
409 }
410 break;
411 case TYPE_CODE_ENUM:
412 case TYPE_CODE_REF:
413 case TYPE_CODE_INT:
414 case TYPE_CODE_PTR:
415 switch (bytes)
416 {
417 case 1:
418 case 2:
419 case 4:
420 case 8:
421 if (bytes * 8 + bit_offset <= 32)
422 classes[0] = X86_64_INTEGERSI_CLASS;
423 else
424 classes[0] = X86_64_INTEGER_CLASS;
425 return 1;
426 case 16:
427 classes[0] = classes[1] = X86_64_INTEGER_CLASS;
428 return 2;
429 default:
430 break;
431 }
432 case TYPE_CODE_VOID:
433 return 0;
434 default: /* Avoid warning. */
435 break;
436 }
437 internal_error (__FILE__, __LINE__,
438 "classify_argument: unknown argument type");
439 }
440
441 /* Examine the argument and set *INT_NREGS and *SSE_NREGS to the
442 number of registers required based on the information passed in
443 CLASSES. Return 0 if parameter should be passed in memory. */
444
445 static int
446 examine_argument (enum x86_64_reg_class classes[MAX_CLASSES],
447 int n, int *int_nregs, int *sse_nregs)
448 {
449 *int_nregs = 0;
450 *sse_nregs = 0;
451 if (!n)
452 return 0;
453 for (n--; n >= 0; n--)
454 switch (classes[n])
455 {
456 case X86_64_INTEGER_CLASS:
457 case X86_64_INTEGERSI_CLASS:
458 (*int_nregs)++;
459 break;
460 case X86_64_SSE_CLASS:
461 case X86_64_SSESF_CLASS:
462 case X86_64_SSEDF_CLASS:
463 (*sse_nregs)++;
464 break;
465 case X86_64_NO_CLASS:
466 case X86_64_SSEUP_CLASS:
467 case X86_64_X87_CLASS:
468 case X86_64_X87UP_CLASS:
469 break;
470 case X86_64_MEMORY_CLASS:
471 internal_error (__FILE__, __LINE__,
472 "examine_argument: unexpected memory class");
473 }
474 return 1;
475 }
476
477 #define RET_INT_REGS 2
478 #define RET_SSE_REGS 2
479
480 /* Check if the structure in value_type is returned in registers or in
481 memory. If this function returns 1, GDB will call
482 STORE_STRUCT_RETURN and EXTRACT_STRUCT_VALUE_ADDRESS else
483 STORE_RETURN_VALUE and EXTRACT_RETURN_VALUE will be used. */
484
485 static int
486 x86_64_use_struct_convention (int gcc_p, struct type *value_type)
487 {
488 enum x86_64_reg_class class[MAX_CLASSES];
489 int n = classify_argument (value_type, class, 0);
490 int needed_intregs;
491 int needed_sseregs;
492
493 return (!n ||
494 !examine_argument (class, n, &needed_intregs, &needed_sseregs) ||
495 needed_intregs > RET_INT_REGS || needed_sseregs > RET_SSE_REGS);
496 }
497
498 /* Extract from an array REGBUF containing the (raw) register state, a
499 function return value of TYPE, and copy that, in virtual format,
500 into VALBUF. */
501
502 static void
503 x86_64_extract_return_value (struct type *type, struct regcache *regcache,
504 void *valbuf)
505 {
506 enum x86_64_reg_class class[MAX_CLASSES];
507 int n = classify_argument (type, class, 0);
508 int needed_intregs;
509 int needed_sseregs;
510 int intreg = 0;
511 int ssereg = 0;
512 int offset = 0;
513 int ret_int_r[RET_INT_REGS] = { X86_64_RAX_REGNUM, X86_64_RDX_REGNUM };
514 int ret_sse_r[RET_SSE_REGS] = { X86_64_XMM0_REGNUM, X86_64_XMM1_REGNUM };
515
516 if (!n ||
517 !examine_argument (class, n, &needed_intregs, &needed_sseregs) ||
518 needed_intregs > RET_INT_REGS || needed_sseregs > RET_SSE_REGS)
519 { /* memory class */
520 CORE_ADDR addr;
521 regcache_cooked_read (regcache, X86_64_RAX_REGNUM, &addr);
522 read_memory (addr, valbuf, TYPE_LENGTH (type));
523 return;
524 }
525 else
526 {
527 int i;
528 for (i = 0; i < n; i++)
529 {
530 switch (class[i])
531 {
532 case X86_64_NO_CLASS:
533 break;
534 case X86_64_INTEGER_CLASS:
535 regcache_cooked_read (regcache, ret_int_r[(intreg + 1) / 2],
536 (char *) valbuf + offset);
537 offset += 8;
538 intreg += 2;
539 break;
540 case X86_64_INTEGERSI_CLASS:
541 regcache_cooked_read_part (regcache, ret_int_r[intreg / 2],
542 0, 4, (char *) valbuf + offset);
543 offset += 8;
544 intreg++;
545 break;
546 case X86_64_SSEDF_CLASS:
547 case X86_64_SSESF_CLASS:
548 case X86_64_SSE_CLASS:
549 regcache_cooked_read_part (regcache,
550 ret_sse_r[(ssereg + 1) / 2], 0, 8,
551 (char *) valbuf + offset);
552 offset += 8;
553 ssereg += 2;
554 break;
555 case X86_64_SSEUP_CLASS:
556 regcache_cooked_read_part (regcache, ret_sse_r[ssereg / 2],
557 0, 8, (char *) valbuf + offset);
558 offset += 8;
559 ssereg++;
560 break;
561 case X86_64_X87_CLASS:
562 regcache_cooked_read_part (regcache, X86_64_ST0_REGNUM,
563 0, 8, (char *) valbuf + offset);
564 offset += 8;
565 break;
566 case X86_64_X87UP_CLASS:
567 regcache_cooked_read_part (regcache, X86_64_ST0_REGNUM,
568 8, 2, (char *) valbuf + offset);
569 offset += 8;
570 break;
571 case X86_64_MEMORY_CLASS:
572 default:
573 internal_error (__FILE__, __LINE__,
574 "Unexpected argument class");
575 }
576 }
577 }
578 }
579
580 #define INT_REGS 6
581 #define SSE_REGS 8
582
583 static CORE_ADDR
584 x86_64_push_arguments (struct regcache *regcache, int nargs,
585 struct value **args, CORE_ADDR sp)
586 {
587 int intreg = 0;
588 int ssereg = 0;
589 /* For varargs functions we have to pass the total number of SSE
590 registers used in %rax. So, let's count this number. */
591 int total_sse_args = 0;
592 /* Once an SSE/int argument is passed on the stack, all subsequent
593 arguments are passed there. */
594 int sse_stack = 0;
595 int int_stack = 0;
596 unsigned total_sp;
597 int i;
598 char buf[8];
599 static int int_parameter_registers[INT_REGS] =
600 {
601 X86_64_RDI_REGNUM, 4, /* %rdi, %rsi */
602 X86_64_RDX_REGNUM, 2, /* %rdx, %rcx */
603 8, 9 /* %r8, %r9 */
604 };
605 /* %xmm0 - %xmm7 */
606 static int sse_parameter_registers[SSE_REGS] =
607 {
608 X86_64_XMM0_REGNUM + 0, X86_64_XMM1_REGNUM,
609 X86_64_XMM0_REGNUM + 2, X86_64_XMM0_REGNUM + 3,
610 X86_64_XMM0_REGNUM + 4, X86_64_XMM0_REGNUM + 5,
611 X86_64_XMM0_REGNUM + 6, X86_64_XMM0_REGNUM + 7,
612 };
613 int stack_values_count = 0;
614 int *stack_values;
615 stack_values = alloca (nargs * sizeof (int));
616
617 for (i = 0; i < nargs; i++)
618 {
619 enum x86_64_reg_class class[MAX_CLASSES];
620 int n = classify_argument (args[i]->type, class, 0);
621 int needed_intregs;
622 int needed_sseregs;
623
624 if (!n ||
625 !examine_argument (class, n, &needed_intregs, &needed_sseregs))
626 { /* memory class */
627 stack_values[stack_values_count++] = i;
628 }
629 else
630 {
631 int j;
632 int offset = 0;
633
634 if (intreg / 2 + needed_intregs > INT_REGS)
635 int_stack = 1;
636 if (ssereg / 2 + needed_sseregs > SSE_REGS)
637 sse_stack = 1;
638 if (!sse_stack)
639 total_sse_args += needed_sseregs;
640
641 for (j = 0; j < n; j++)
642 {
643 switch (class[j])
644 {
645 case X86_64_NO_CLASS:
646 break;
647 case X86_64_INTEGER_CLASS:
648 if (int_stack)
649 stack_values[stack_values_count++] = i;
650 else
651 {
652 regcache_cooked_write
653 (regcache, int_parameter_registers[(intreg + 1) / 2],
654 VALUE_CONTENTS_ALL (args[i]) + offset);
655 offset += 8;
656 intreg += 2;
657 }
658 break;
659 case X86_64_INTEGERSI_CLASS:
660 if (int_stack)
661 stack_values[stack_values_count++] = i;
662 else
663 {
664 LONGEST val = extract_signed_integer
665 (VALUE_CONTENTS_ALL (args[i]) + offset, 4);
666 regcache_cooked_write_signed
667 (regcache, int_parameter_registers[intreg / 2], val);
668
669 offset += 8;
670 intreg++;
671 }
672 break;
673 case X86_64_SSEDF_CLASS:
674 case X86_64_SSESF_CLASS:
675 case X86_64_SSE_CLASS:
676 if (sse_stack)
677 stack_values[stack_values_count++] = i;
678 else
679 {
680 regcache_cooked_write
681 (regcache, sse_parameter_registers[(ssereg + 1) / 2],
682 VALUE_CONTENTS_ALL (args[i]) + offset);
683 offset += 8;
684 ssereg += 2;
685 }
686 break;
687 case X86_64_SSEUP_CLASS:
688 if (sse_stack)
689 stack_values[stack_values_count++] = i;
690 else
691 {
692 regcache_cooked_write
693 (regcache, sse_parameter_registers[ssereg / 2],
694 VALUE_CONTENTS_ALL (args[i]) + offset);
695 offset += 8;
696 ssereg++;
697 }
698 break;
699 case X86_64_X87_CLASS:
700 case X86_64_MEMORY_CLASS:
701 stack_values[stack_values_count++] = i;
702 break;
703 case X86_64_X87UP_CLASS:
704 break;
705 default:
706 internal_error (__FILE__, __LINE__,
707 "Unexpected argument class");
708 }
709 intreg += intreg % 2;
710 ssereg += ssereg % 2;
711 }
712 }
713 }
714
715 /* We have to make sure that the stack is 16-byte aligned after the
716 setup. Let's calculate size of arguments first, align stack and
717 then fill in the arguments. */
718 total_sp = 0;
719 for (i = 0; i < stack_values_count; i++)
720 {
721 struct value *arg = args[stack_values[i]];
722 int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
723 total_sp += (len + 7) & ~7;
724 }
725 /* total_sp is now a multiple of 8, if it is not a multiple of 16,
726 change the stack pointer so that it will be afterwards correctly
727 aligned. */
728 if (total_sp & 15)
729 sp -= 8;
730
731 /* Push any remaining arguments onto the stack. */
732 while (--stack_values_count >= 0)
733 {
734 struct value *arg = args[stack_values[stack_values_count]];
735 int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
736
737 /* Make sure the stack is 8-byte-aligned. */
738 sp -= (len + 7) & ~7;
739 write_memory (sp, VALUE_CONTENTS_ALL (arg), len);
740 }
741
742 /* Write number of SSE type arguments to RAX to take care of varargs
743 functions. */
744 store_unsigned_integer (buf, 8, total_sse_args);
745 regcache_cooked_write (regcache, X86_64_RAX_REGNUM, buf);
746
747 return sp;
748 }
749
750 /* Write into the appropriate registers a function return value stored
751 in VALBUF of type TYPE, given in virtual format. */
752
753 static void
754 x86_64_store_return_value (struct type *type, struct regcache *regcache,
755 const void *valbuf)
756 {
757 int len = TYPE_LENGTH (type);
758
759 /* First handle long doubles. */
760 if (TYPE_CODE_FLT == TYPE_CODE (type) && len == 16)
761 {
762 ULONGEST fstat;
763 char buf[FPU_REG_RAW_SIZE];
764
765 /* Returning floating-point values is a bit tricky. Apart from
766 storing the return value in %st(0), we have to simulate the
767 state of the FPU at function return point. */
768
769 /* Convert the value found in VALBUF to the extended
770 floating-point format used by the FPU. This is probably
771 not exactly how it would happen on the target itself, but
772 it is the best we can do. */
773 convert_typed_floating (valbuf, type, buf, builtin_type_i387_ext);
774 regcache_raw_write (regcache, X86_64_ST0_REGNUM, buf);
775
776 /* Set the top of the floating-point register stack to 7. The
777 actual value doesn't really matter, but 7 is what a normal
778 function return would end up with if the program started out
779 with a freshly initialized FPU. */
780 regcache_raw_read_unsigned (regcache, FSTAT_REGNUM, &fstat);
781 fstat |= (7 << 11);
782 regcache_raw_write_unsigned (regcache, FSTAT_REGNUM, fstat);
783
784 /* Mark %st(1) through %st(7) as empty. Since we set the top of
785 the floating-point register stack to 7, the appropriate value
786 for the tag word is 0x3fff. */
787 regcache_raw_write_unsigned (regcache, FTAG_REGNUM, 0x3fff);
788 }
789 else if (TYPE_CODE_FLT == TYPE_CODE (type))
790 {
791 /* Handle double and float variables. */
792 regcache_cooked_write_part (regcache, X86_64_XMM0_REGNUM,
793 0, len, valbuf);
794 }
795 /* XXX: What about complex floating point types? */
796 else
797 {
798 int low_size = REGISTER_RAW_SIZE (0);
799 int high_size = REGISTER_RAW_SIZE (1);
800
801 if (len <= low_size)
802 regcache_cooked_write_part (regcache, 0, 0, len, valbuf);
803 else if (len <= (low_size + high_size))
804 {
805 regcache_cooked_write_part (regcache, 0, 0, low_size, valbuf);
806 regcache_cooked_write_part (regcache, 1, 0,
807 len - low_size,
808 (const char *) valbuf + low_size);
809 }
810 else
811 internal_error (__FILE__, __LINE__,
812 "Cannot store return value of %d bytes long.", len);
813 }
814 }
815 \f
816
817 static CORE_ADDR
818 x86_64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
819 struct regcache *regcache, CORE_ADDR bp_addr,
820 int nargs, struct value **args, CORE_ADDR sp,
821 int struct_return, CORE_ADDR struct_addr)
822 {
823 char buf[8];
824
825 /* Pass arguments. */
826 sp = x86_64_push_arguments (regcache, nargs, args, sp);
827
828 /* Pass "hidden" argument". */
829 if (struct_return)
830 {
831 store_unsigned_integer (buf, 8, struct_addr);
832 regcache_cooked_write (regcache, X86_64_RDI_REGNUM, buf);
833 }
834
835 /* Store return address. */
836 sp -= 8;
837 store_unsigned_integer (buf, 8, bp_addr);
838 write_memory (sp, buf, 8);
839
840 /* Finally, update the stack pointer... */
841 store_unsigned_integer (buf, 8, sp);
842 regcache_cooked_write (regcache, X86_64_RSP_REGNUM, buf);
843
844 /* ...and fake a frame pointer. */
845 regcache_cooked_write (regcache, X86_64_RBP_REGNUM, buf);
846
847 return sp + 16;
848 }
849 \f
850
851 /* The maximum number of saved registers. This should include %rip. */
852 #define X86_64_NUM_SAVED_REGS X86_64_NUM_GREGS
853
854 struct x86_64_frame_cache
855 {
856 /* Base address. */
857 CORE_ADDR base;
858 CORE_ADDR sp_offset;
859 CORE_ADDR pc;
860
861 /* Saved registers. */
862 CORE_ADDR saved_regs[X86_64_NUM_SAVED_REGS];
863 CORE_ADDR saved_sp;
864
865 /* Do we have a frame? */
866 int frameless_p;
867 };
868
869 /* Allocate and initialize a frame cache. */
870
871 static struct x86_64_frame_cache *
872 x86_64_alloc_frame_cache (void)
873 {
874 struct x86_64_frame_cache *cache;
875 int i;
876
877 cache = FRAME_OBSTACK_ZALLOC (struct x86_64_frame_cache);
878
879 /* Base address. */
880 cache->base = 0;
881 cache->sp_offset = -8;
882 cache->pc = 0;
883
884 /* Saved registers. We initialize these to -1 since zero is a valid
885 offset (that's where %rbp is supposed to be stored). */
886 for (i = 0; i < X86_64_NUM_SAVED_REGS; i++)
887 cache->saved_regs[i] = -1;
888 cache->saved_sp = 0;
889
890 /* Frameless until proven otherwise. */
891 cache->frameless_p = 1;
892
893 return cache;
894 }
895
896 /* Do a limited analysis of the prologue at PC and update CACHE
897 accordingly. Bail out early if CURRENT_PC is reached. Return the
898 address where the analysis stopped.
899
900 We will handle only functions beginning with:
901
902 pushq %rbp 0x55
903 movq %rsp, %rbp 0x48 0x89 0xe5
904
905 Any function that doesn't start with this sequence will be assumed
906 to have no prologue and thus no valid frame pointer in %rbp. */
907
908 static CORE_ADDR
909 x86_64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
910 struct x86_64_frame_cache *cache)
911 {
912 static unsigned char proto[3] = { 0x48, 0x89, 0xe5 };
913 unsigned char buf[3];
914 unsigned char op;
915
916 if (current_pc <= pc)
917 return current_pc;
918
919 op = read_memory_unsigned_integer (pc, 1);
920
921 if (op == 0x55) /* pushq %rbp */
922 {
923 /* Take into account that we've executed the `pushq %rbp' that
924 starts this instruction sequence. */
925 cache->saved_regs[X86_64_RBP_REGNUM] = 0;
926 cache->sp_offset += 8;
927
928 /* If that's all, return now. */
929 if (current_pc <= pc + 1)
930 return current_pc;
931
932 /* Check for `movq %rsp, %rbp'. */
933 read_memory (pc + 1, buf, 3);
934 if (memcmp (buf, proto, 3) != 0)
935 return pc + 1;
936
937 /* OK, we actually have a frame. */
938 cache->frameless_p = 0;
939 return pc + 4;
940 }
941
942 return pc;
943 }
944
945 /* Return PC of first real instruction. */
946
947 static CORE_ADDR
948 x86_64_skip_prologue (CORE_ADDR start_pc)
949 {
950 struct x86_64_frame_cache cache;
951 CORE_ADDR pc;
952
953 pc = x86_64_analyze_prologue (start_pc, 0xffffffffffffffff, &cache);
954 if (cache.frameless_p)
955 return start_pc;
956
957 return pc;
958 }
959 \f
960
961 /* Normal frames. */
962
963 static struct x86_64_frame_cache *
964 x86_64_frame_cache (struct frame_info *next_frame, void **this_cache)
965 {
966 struct x86_64_frame_cache *cache;
967 char buf[8];
968 int i;
969
970 if (*this_cache)
971 return *this_cache;
972
973 cache = x86_64_alloc_frame_cache ();
974 *this_cache = cache;
975
976 frame_unwind_register (next_frame, X86_64_RBP_REGNUM, buf);
977 cache->base = extract_unsigned_integer (buf, 8);
978 if (cache->base == 0)
979 return cache;
980
981 /* For normal frames, %rip is stored at 8(%rbp). */
982 cache->saved_regs[X86_64_RIP_REGNUM] = 8;
983
984 cache->pc = frame_func_unwind (next_frame);
985 if (cache->pc != 0)
986 x86_64_analyze_prologue (cache->pc, frame_pc_unwind (next_frame), cache);
987
988 if (cache->frameless_p)
989 {
990 /* We didn't find a valid frame, which means that CACHE->base
991 currently holds the frame pointer for our calling frame. If
992 we're at the start of a function, or somewhere half-way its
993 prologue, the function's frame probably hasn't been fully
994 setup yet. Try to reconstruct the base address for the stack
995 frame by looking at the stack pointer. For truly "frameless"
996 functions this might work too. */
997
998 frame_unwind_register (next_frame, X86_64_RSP_REGNUM, buf);
999 cache->base = extract_unsigned_integer (buf, 8) + cache->sp_offset;
1000 }
1001
1002 /* Now that we have the base address for the stack frame we can
1003 calculate the value of %rsp in the calling frame. */
1004 cache->saved_sp = cache->base + 16;
1005
1006 /* Adjust all the saved registers such that they contain addresses
1007 instead of offsets. */
1008 for (i = 0; i < X86_64_NUM_SAVED_REGS; i++)
1009 if (cache->saved_regs[i] != -1)
1010 cache->saved_regs[i] += cache->base;
1011
1012 return cache;
1013 }
1014
1015 static void
1016 x86_64_frame_this_id (struct frame_info *next_frame, void **this_cache,
1017 struct frame_id *this_id)
1018 {
1019 struct x86_64_frame_cache *cache =
1020 x86_64_frame_cache (next_frame, this_cache);
1021
1022 /* This marks the outermost frame. */
1023 if (cache->base == 0)
1024 return;
1025
1026 (*this_id) = frame_id_build (cache->base + 16, cache->pc);
1027 }
1028
1029 static void
1030 x86_64_frame_prev_register (struct frame_info *next_frame, void **this_cache,
1031 int regnum, int *optimizedp,
1032 enum lval_type *lvalp, CORE_ADDR *addrp,
1033 int *realnump, void *valuep)
1034 {
1035 struct x86_64_frame_cache *cache =
1036 x86_64_frame_cache (next_frame, this_cache);
1037
1038 gdb_assert (regnum >= 0);
1039
1040 if (regnum == SP_REGNUM && cache->saved_sp)
1041 {
1042 *optimizedp = 0;
1043 *lvalp = not_lval;
1044 *addrp = 0;
1045 *realnump = -1;
1046 if (valuep)
1047 {
1048 /* Store the value. */
1049 store_unsigned_integer (valuep, 8, cache->saved_sp);
1050 }
1051 return;
1052 }
1053
1054 if (regnum < X86_64_NUM_SAVED_REGS && cache->saved_regs[regnum] != -1)
1055 {
1056 *optimizedp = 0;
1057 *lvalp = lval_memory;
1058 *addrp = cache->saved_regs[regnum];
1059 *realnump = -1;
1060 if (valuep)
1061 {
1062 /* Read the value in from memory. */
1063 read_memory (*addrp, valuep,
1064 register_size (current_gdbarch, regnum));
1065 }
1066 return;
1067 }
1068
1069 frame_register_unwind (next_frame, regnum,
1070 optimizedp, lvalp, addrp, realnump, valuep);
1071 }
1072
1073 static const struct frame_unwind x86_64_frame_unwind =
1074 {
1075 NORMAL_FRAME,
1076 x86_64_frame_this_id,
1077 x86_64_frame_prev_register
1078 };
1079
1080 static const struct frame_unwind *
1081 x86_64_frame_sniffer (struct frame_info *next_frame)
1082 {
1083 return &x86_64_frame_unwind;
1084 }
1085 \f
1086
1087 /* Signal trampolines. */
1088
1089 /* FIXME: kettenis/20030419: Perhaps, we can unify the 32-bit and
1090 64-bit variants. This would require using identical frame caches
1091 on both platforms. */
1092
1093 static struct x86_64_frame_cache *
1094 x86_64_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache)
1095 {
1096 struct x86_64_frame_cache *cache;
1097 struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
1098 CORE_ADDR addr;
1099 char buf[8];
1100 int i;
1101
1102 if (*this_cache)
1103 return *this_cache;
1104
1105 cache = x86_64_alloc_frame_cache ();
1106
1107 frame_unwind_register (next_frame, X86_64_RSP_REGNUM, buf);
1108 cache->base = extract_unsigned_integer (buf, 8) - 8;
1109
1110 addr = tdep->sigcontext_addr (next_frame);
1111 gdb_assert (tdep->sc_reg_offset);
1112 gdb_assert (tdep->sc_num_regs <= X86_64_NUM_SAVED_REGS);
1113 for (i = 0; i < tdep->sc_num_regs; i++)
1114 if (tdep->sc_reg_offset[i] != -1)
1115 cache->saved_regs[i] = addr + tdep->sc_reg_offset[i];
1116
1117 *this_cache = cache;
1118 return cache;
1119 }
1120
1121 static void
1122 x86_64_sigtramp_frame_this_id (struct frame_info *next_frame,
1123 void **this_cache, struct frame_id *this_id)
1124 {
1125 struct x86_64_frame_cache *cache =
1126 x86_64_sigtramp_frame_cache (next_frame, this_cache);
1127
1128 (*this_id) = frame_id_build (cache->base + 16, frame_pc_unwind (next_frame));
1129 }
1130
1131 static void
1132 x86_64_sigtramp_frame_prev_register (struct frame_info *next_frame,
1133 void **this_cache,
1134 int regnum, int *optimizedp,
1135 enum lval_type *lvalp, CORE_ADDR *addrp,
1136 int *realnump, void *valuep)
1137 {
1138 /* Make sure we've initialized the cache. */
1139 x86_64_sigtramp_frame_cache (next_frame, this_cache);
1140
1141 x86_64_frame_prev_register (next_frame, this_cache, regnum,
1142 optimizedp, lvalp, addrp, realnump, valuep);
1143 }
1144
1145 static const struct frame_unwind x86_64_sigtramp_frame_unwind =
1146 {
1147 SIGTRAMP_FRAME,
1148 x86_64_sigtramp_frame_this_id,
1149 x86_64_sigtramp_frame_prev_register
1150 };
1151
1152 static const struct frame_unwind *
1153 x86_64_sigtramp_frame_sniffer (struct frame_info *next_frame)
1154 {
1155 CORE_ADDR pc = frame_pc_unwind (next_frame);
1156 char *name;
1157
1158 find_pc_partial_function (pc, &name, NULL, NULL);
1159 if (PC_IN_SIGTRAMP (pc, name))
1160 {
1161 gdb_assert (gdbarch_tdep (current_gdbarch)->sigcontext_addr);
1162
1163 return &x86_64_sigtramp_frame_unwind;
1164 }
1165
1166 return NULL;
1167 }
1168 \f
1169
1170 static CORE_ADDR
1171 x86_64_frame_base_address (struct frame_info *next_frame, void **this_cache)
1172 {
1173 struct x86_64_frame_cache *cache =
1174 x86_64_frame_cache (next_frame, this_cache);
1175
1176 return cache->base;
1177 }
1178
1179 static const struct frame_base x86_64_frame_base =
1180 {
1181 &x86_64_frame_unwind,
1182 x86_64_frame_base_address,
1183 x86_64_frame_base_address,
1184 x86_64_frame_base_address
1185 };
1186
1187 static struct frame_id
1188 x86_64_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
1189 {
1190 char buf[8];
1191 CORE_ADDR fp;
1192
1193 frame_unwind_register (next_frame, X86_64_RBP_REGNUM, buf);
1194 fp = extract_unsigned_integer (buf, 8);
1195
1196 return frame_id_build (fp + 16, frame_pc_unwind (next_frame));
1197 }
1198
1199 /* 16 byte align the SP per frame requirements. */
1200
1201 static CORE_ADDR
1202 x86_64_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
1203 {
1204 return sp & -(CORE_ADDR)16;
1205 }
1206
1207 void
1208 x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
1209 {
1210 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
1211
1212 /* AMD64 has an FPU and 16 SSE registers. */
1213 tdep->st0_regnum = X86_64_ST0_REGNUM;
1214 tdep->num_xmm_regs = 16;
1215
1216 /* This is what all the fuss is about. */
1217 set_gdbarch_long_bit (gdbarch, 64);
1218 set_gdbarch_long_long_bit (gdbarch, 64);
1219 set_gdbarch_ptr_bit (gdbarch, 64);
1220
1221 /* In contrast to the i386, on the x86-64 a `long double' actually
1222 takes up 128 bits, even though it's still based on the i387
1223 extended floating-point format which has only 80 significant bits. */
1224 set_gdbarch_long_double_bit (gdbarch, 128);
1225
1226 set_gdbarch_num_regs (gdbarch, X86_64_NUM_REGS);
1227 set_gdbarch_register_name (gdbarch, x86_64_register_name);
1228 set_gdbarch_register_type (gdbarch, x86_64_register_type);
1229
1230 /* Register numbers of various important registers. */
1231 set_gdbarch_sp_regnum (gdbarch, X86_64_RSP_REGNUM); /* %rsp */
1232 set_gdbarch_pc_regnum (gdbarch, X86_64_RIP_REGNUM); /* %rip */
1233 set_gdbarch_ps_regnum (gdbarch, X86_64_EFLAGS_REGNUM); /* %eflags */
1234 set_gdbarch_fp0_regnum (gdbarch, X86_64_ST0_REGNUM); /* %st(0) */
1235
1236 /* The "default" register numbering scheme for the x86-64 is
1237 referred to as the "DWARF Register Number Mapping" in the System
1238 V psABI. The preferred debugging format for all known x86-64
1239 targets is actually DWARF2, and GCC doesn't seem to support DWARF
1240 (that is DWARF-1), but we provide the same mapping just in case.
1241 This mapping is also used for stabs, which GCC does support. */
1242 set_gdbarch_stab_reg_to_regnum (gdbarch, x86_64_dwarf_reg_to_regnum);
1243 set_gdbarch_dwarf_reg_to_regnum (gdbarch, x86_64_dwarf_reg_to_regnum);
1244 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, x86_64_dwarf_reg_to_regnum);
1245
1246 /* We don't override SDB_REG_RO_REGNUM, since COFF doesn't seem to
1247 be in use on any of the supported x86-64 targets. */
1248
1249 /* Call dummy code. */
1250 set_gdbarch_push_dummy_call (gdbarch, x86_64_push_dummy_call);
1251 set_gdbarch_frame_align (gdbarch, x86_64_frame_align);
1252 set_gdbarch_frame_red_zone_size (gdbarch, 128);
1253
1254 set_gdbarch_convert_register_p (gdbarch, x86_64_convert_register_p);
1255 set_gdbarch_register_to_value (gdbarch, i387_register_to_value);
1256 set_gdbarch_value_to_register (gdbarch, i387_value_to_register);
1257
1258 set_gdbarch_extract_return_value (gdbarch, x86_64_extract_return_value);
1259 set_gdbarch_store_return_value (gdbarch, x86_64_store_return_value);
1260 /* Override, since this is handled by x86_64_extract_return_value. */
1261 set_gdbarch_extract_struct_value_address (gdbarch, NULL);
1262 set_gdbarch_use_struct_convention (gdbarch, x86_64_use_struct_convention);
1263
1264 set_gdbarch_skip_prologue (gdbarch, x86_64_skip_prologue);
1265
1266 /* Avoid wiring in the MMX registers for now. */
1267 set_gdbarch_num_pseudo_regs (gdbarch, 0);
1268 tdep->mm0_regnum = -1;
1269
1270 set_gdbarch_unwind_dummy_id (gdbarch, x86_64_unwind_dummy_id);
1271
1272 /* FIXME: kettenis/20021026: This is ELF-specific. Fine for now,
1273 since all supported x86-64 targets are ELF, but that might change
1274 in the future. */
1275 set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
1276
1277 frame_unwind_append_sniffer (gdbarch, x86_64_sigtramp_frame_sniffer);
1278 frame_unwind_append_sniffer (gdbarch, x86_64_frame_sniffer);
1279 frame_base_set_default (gdbarch, &x86_64_frame_base);
1280 }
1281 \f
1282
1283 #define I387_ST0_REGNUM X86_64_ST0_REGNUM
1284
1285 /* The 64-bit FXSAVE format differs from the 32-bit format in the
1286 sense that the instruction pointer and data pointer are simply
1287 64-bit offsets into the code segment and the data segment instead
1288 of a selector offset pair. The functions below store the upper 32
1289 bits of these pointers (instead of just the 16-bits of the segment
1290 selector). */
1291
1292 /* Fill register REGNUM in GDB's register cache with the appropriate
1293 floating-point or SSE register value from *FXSAVE. If REGNUM is
1294 -1, do this for all registers. This function masks off any of the
1295 reserved bits in *FXSAVE. */
1296
1297 void
1298 x86_64_supply_fxsave (const char *fxsave, int regnum)
1299 {
1300 i387_supply_fxsave (fxsave, regnum);
1301
1302 if (fxsave)
1303 {
1304 if (regnum == -1 || regnum == I387_FISEG_REGNUM)
1305 supply_register (I387_FISEG_REGNUM, fxsave + 12);
1306 if (regnum == -1 || regnum == I387_FOSEG_REGNUM)
1307 supply_register (I387_FOSEG_REGNUM, fxsave + 20);
1308 }
1309 }
1310
1311 /* Fill register REGNUM (if it is a floating-point or SSE register) in
1312 *FXSAVE with the value in GDB's register cache. If REGNUM is -1, do
1313 this for all registers. This function doesn't touch any of the
1314 reserved bits in *FXSAVE. */
1315
1316 void
1317 x86_64_fill_fxsave (char *fxsave, int regnum)
1318 {
1319 i387_fill_fxsave (fxsave, regnum);
1320
1321 if (regnum == -1 || regnum == I387_FISEG_REGNUM)
1322 regcache_collect (I387_FISEG_REGNUM, fxsave + 12);
1323 if (regnum == -1 || regnum == I387_FOSEG_REGNUM)
1324 regcache_collect (I387_FOSEG_REGNUM, fxsave + 20);
1325 }
This page took 0.058412 seconds and 4 git commands to generate.