* Makefile.am: Added tic4x dependecy
[deliverable/binutils-gdb.git] / gdb / x86-64-tdep.c
CommitLineData
53e95fcf 1/* Target-dependent code for the x86-64 for GDB, the GNU debugger.
ce0eebec
AC
2
3 Copyright 2001, 2002 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"
24#include "inferior.h"
25#include "gdbcore.h"
26#include "gdbcmd.h"
27#include "arch-utils.h"
28#include "regcache.h"
29#include "symfile.h"
8a8ab2b9 30#include "objfiles.h"
53e95fcf
JS
31#include "x86-64-tdep.h"
32#include "dwarf2cfi.h"
82dbc5f7 33#include "gdb_assert.h"
53e95fcf 34
53e95fcf
JS
35/* Register numbers of various important registers. */
36#define RAX_REGNUM 0
de220d0f 37#define RDX_REGNUM 3
53e95fcf
JS
38#define RDI_REGNUM 5
39#define EFLAGS_REGNUM 17
0e04a514 40#define ST0_REGNUM 22
de220d0f
ML
41#define XMM1_REGNUM 39
42
43struct register_info
44{
45 int size;
46 char *name;
47 struct type **type;
48};
53e95fcf
JS
49
50/* x86_64_register_raw_size_table[i] is the number of bytes of storage in
51 GDB's register array occupied by register i. */
de220d0f 52static struct register_info x86_64_register_info_table[] = {
91fd20f7
ML
53 /* 0 */ {8, "rax", &builtin_type_int64},
54 /* 1 */ {8, "rbx", &builtin_type_int64},
55 /* 2 */ {8, "rcx", &builtin_type_int64},
56 /* 3 */ {8, "rdx", &builtin_type_int64},
57 /* 4 */ {8, "rsi", &builtin_type_int64},
58 /* 5 */ {8, "rdi", &builtin_type_int64},
59 /* 6 */ {8, "rbp", &builtin_type_void_func_ptr},
60 /* 7 */ {8, "rsp", &builtin_type_void_func_ptr},
61 /* 8 */ {8, "r8", &builtin_type_int64},
62 /* 9 */ {8, "r9", &builtin_type_int64},
63 /* 10 */ {8, "r10", &builtin_type_int64},
64 /* 11 */ {8, "r11", &builtin_type_int64},
65 /* 12 */ {8, "r12", &builtin_type_int64},
66 /* 13 */ {8, "r13", &builtin_type_int64},
67 /* 14 */ {8, "r14", &builtin_type_int64},
68 /* 15 */ {8, "r15", &builtin_type_int64},
69 /* 16 */ {8, "rip", &builtin_type_void_func_ptr},
70 /* 17 */ {4, "eflags", &builtin_type_int32},
71 /* 18 */ {4, "ds", &builtin_type_int32},
72 /* 19 */ {4, "es", &builtin_type_int32},
73 /* 20 */ {4, "fs", &builtin_type_int32},
74 /* 21 */ {4, "gs", &builtin_type_int32},
75 /* 22 */ {10, "st0", &builtin_type_i387_ext},
76 /* 23 */ {10, "st1", &builtin_type_i387_ext},
77 /* 24 */ {10, "st2", &builtin_type_i387_ext},
78 /* 25 */ {10, "st3", &builtin_type_i387_ext},
79 /* 26 */ {10, "st4", &builtin_type_i387_ext},
80 /* 27 */ {10, "st5", &builtin_type_i387_ext},
81 /* 28 */ {10, "st6", &builtin_type_i387_ext},
82 /* 29 */ {10, "st7", &builtin_type_i387_ext},
83 /* 30 */ {4, "fctrl", &builtin_type_int32},
84 /* 31 */ {4, "fstat", &builtin_type_int32},
85 /* 32 */ {4, "ftag", &builtin_type_int32},
86 /* 33 */ {4, "fiseg", &builtin_type_int32},
87 /* 34 */ {4, "fioff", &builtin_type_int32},
88 /* 35 */ {4, "foseg", &builtin_type_int32},
89 /* 36 */ {4, "fooff", &builtin_type_int32},
90 /* 37 */ {4, "fop", &builtin_type_int32},
91 /* 38 */ {16, "xmm0", &builtin_type_v4sf},
92 /* 39 */ {16, "xmm1", &builtin_type_v4sf},
93 /* 40 */ {16, "xmm2", &builtin_type_v4sf},
94 /* 41 */ {16, "xmm3", &builtin_type_v4sf},
95 /* 42 */ {16, "xmm4", &builtin_type_v4sf},
96 /* 43 */ {16, "xmm5", &builtin_type_v4sf},
97 /* 44 */ {16, "xmm6", &builtin_type_v4sf},
98 /* 45 */ {16, "xmm7", &builtin_type_v4sf},
99 /* 46 */ {16, "xmm8", &builtin_type_v4sf},
100 /* 47 */ {16, "xmm9", &builtin_type_v4sf},
101 /* 48 */ {16, "xmm10", &builtin_type_v4sf},
102 /* 49 */ {16, "xmm11", &builtin_type_v4sf},
103 /* 50 */ {16, "xmm12", &builtin_type_v4sf},
104 /* 51 */ {16, "xmm13", &builtin_type_v4sf},
105 /* 52 */ {16, "xmm14", &builtin_type_v4sf},
106 /* 53 */ {16, "xmm15", &builtin_type_v4sf},
107 /* 54 */ {4, "mxcsr", &builtin_type_int32}
53e95fcf
JS
108};
109
0e04a514
ML
110/* This array is a mapping from Dwarf-2 register
111 numbering to GDB's one. Dwarf-2 numbering is
112 defined in x86-64 ABI, section 3.6. */
113static int x86_64_dwarf2gdb_regno_map[] = {
114 0, 1, 2, 3, /* RAX - RDX */
115 4, 5, 6, 7, /* RSI, RDI, RBP, RSP */
116 8, 9, 10, 11, /* R8 - R11 */
117 12, 13, 14, 15, /* R12 - R15 */
118 -1, /* RA - not mapped */
119 XMM1_REGNUM - 1, XMM1_REGNUM, /* XMM0 ... */
120 XMM1_REGNUM + 1, XMM1_REGNUM + 2,
121 XMM1_REGNUM + 3, XMM1_REGNUM + 4,
122 XMM1_REGNUM + 5, XMM1_REGNUM + 6,
123 XMM1_REGNUM + 7, XMM1_REGNUM + 8,
124 XMM1_REGNUM + 9, XMM1_REGNUM + 10,
125 XMM1_REGNUM + 11, XMM1_REGNUM + 12,
126 XMM1_REGNUM + 13, XMM1_REGNUM + 14, /* ... XMM15 */
127 ST0_REGNUM + 0, ST0_REGNUM + 1, /* ST0 ... */
128 ST0_REGNUM + 2, ST0_REGNUM + 3,
129 ST0_REGNUM + 4, ST0_REGNUM + 5,
130 ST0_REGNUM + 6, ST0_REGNUM + 7 /* ... ST7 */
131};
132
133static int x86_64_dwarf2gdb_regno_map_length =
134 sizeof (x86_64_dwarf2gdb_regno_map) /
135 sizeof (x86_64_dwarf2gdb_regno_map[0]);
136
de220d0f
ML
137/* Number of all registers */
138#define X86_64_NUM_REGS (sizeof (x86_64_register_info_table) / \
139 sizeof (x86_64_register_info_table[0]))
140
141/* Number of general registers. */
142#define X86_64_NUM_GREGS (22)
143
144int x86_64_num_regs = X86_64_NUM_REGS;
145int x86_64_num_gregs = X86_64_NUM_GREGS;
146
b6779aa2
AC
147/* Did we already print a note about frame pointer? */
148int omit_fp_note_printed = 0;
149
53e95fcf
JS
150/* Number of bytes of storage in the actual machine representation for
151 register REGNO. */
152int
153x86_64_register_raw_size (int regno)
154{
de220d0f 155 return x86_64_register_info_table[regno].size;
53e95fcf
JS
156}
157
158/* x86_64_register_byte_table[i] is the offset into the register file of the
159 start of register number i. We initialize this from
de220d0f 160 x86_64_register_info_table. */
53e95fcf
JS
161int x86_64_register_byte_table[X86_64_NUM_REGS];
162
163/* Index within `registers' of the first byte of the space for register REGNO. */
164int
165x86_64_register_byte (int regno)
166{
167 return x86_64_register_byte_table[regno];
168}
169
170/* Return the GDB type object for the "standard" data type of data in
171 register N. */
172static struct type *
173x86_64_register_virtual_type (int regno)
174{
de220d0f 175 return *x86_64_register_info_table[regno].type;
53e95fcf
JS
176}
177
53e95fcf
JS
178/* x86_64_register_convertible is true if register N's virtual format is
179 different from its raw format. Note that this definition assumes
180 that the host supports IEEE 32-bit floats, since it doesn't say
181 that SSE registers need conversion. Even if we can't find a
182 counterexample, this is still sloppy. */
183int
184x86_64_register_convertible (int regno)
185{
186 return IS_FP_REGNUM (regno);
187}
188
189/* Convert data from raw format for register REGNUM in buffer FROM to
190 virtual format with type TYPE in buffer TO. In principle both
191 formats are identical except that the virtual format has two extra
192 bytes appended that aren't used. We set these to zero. */
193void
194x86_64_register_convert_to_virtual (int regnum, struct type *type,
195 char *from, char *to)
196{
82dbc5f7 197 char buf[12];
4657573b 198
82dbc5f7
AC
199 /* We only support floating-point values. */
200 if (TYPE_CODE (type) != TYPE_CODE_FLT)
201 {
202 warning ("Cannot convert floating-point register value "
203 "to non-floating-point type.");
204 memset (to, 0, TYPE_LENGTH (type));
205 return;
206 }
207 /* First add the necessary padding. */
208 memcpy (buf, from, FPU_REG_RAW_SIZE);
209 memset (buf + FPU_REG_RAW_SIZE, 0, sizeof buf - FPU_REG_RAW_SIZE);
210 /* Convert to TYPE. This should be a no-op, if TYPE is equivalent
211 to the extended floating-point format used by the FPU. */
ce0eebec
AC
212 convert_typed_floating (to, type, buf,
213 x86_64_register_virtual_type (regnum));
53e95fcf
JS
214}
215
216/* Convert data from virtual format with type TYPE in buffer FROM to
217 raw format for register REGNUM in buffer TO. Simply omit the two
218 unused bytes. */
219
220void
221x86_64_register_convert_to_raw (struct type *type, int regnum,
222 char *from, char *to)
223{
ce0eebec 224 gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12);
82dbc5f7 225 /* Simply omit the two unused bytes. */
53e95fcf
JS
226 memcpy (to, from, FPU_REG_RAW_SIZE);
227}
53e95fcf 228
0e04a514
ML
229/* Dwarf-2 <-> GDB register numbers mapping. */
230int
231x86_64_dwarf2_reg_to_regnum (int dw_reg)
232{
233 if (dw_reg < 0 || dw_reg > x86_64_dwarf2gdb_regno_map_length)
234 {
235 warning ("Dwarf-2 uses unmapped register #%d\n", dw_reg);
236 return dw_reg;
237 }
238
239 return x86_64_dwarf2gdb_regno_map[dw_reg];
240}
241
53e95fcf
JS
242/* This is the variable that is set with "set disassembly-flavour", and
243 its legitimate values. */
244static const char att_flavour[] = "att";
245static const char intel_flavour[] = "intel";
246static const char *valid_flavours[] = {
247 att_flavour,
248 intel_flavour,
249 NULL
250};
251static const char *disassembly_flavour = att_flavour;
252
26abbdc4
MK
253/* Push the return address (pointing to the call dummy) onto the stack
254 and return the new value for the stack pointer. */
255
53e95fcf
JS
256static CORE_ADDR
257x86_64_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
258{
259 char buf[8];
260
261 store_unsigned_integer (buf, 8, CALL_DUMMY_ADDRESS ());
53e95fcf
JS
262 write_memory (sp - 8, buf, 8);
263 return sp - 8;
264}
265
26abbdc4 266static void
53e95fcf
JS
267x86_64_pop_frame (void)
268{
269 generic_pop_current_frame (cfi_pop_frame);
270}
271\f
272
273/* The returning of values is done according to the special algorithm.
274 Some types are returned in registers an some (big structures) in memory.
275 See ABI for details.
276 */
277
278#define MAX_CLASSES 4
279
280enum x86_64_reg_class
281{
282 X86_64_NO_CLASS,
283 X86_64_INTEGER_CLASS,
284 X86_64_INTEGERSI_CLASS,
285 X86_64_SSE_CLASS,
286 X86_64_SSESF_CLASS,
287 X86_64_SSEDF_CLASS,
288 X86_64_SSEUP_CLASS,
289 X86_64_X87_CLASS,
290 X86_64_X87UP_CLASS,
291 X86_64_MEMORY_CLASS
292};
293
294/* Return the union class of CLASS1 and CLASS2.
295 See the x86-64 ABI for details. */
296
297static enum x86_64_reg_class
298merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
299{
300 /* Rule #1: If both classes are equal, this is the resulting class. */
301 if (class1 == class2)
302 return class1;
303
26abbdc4
MK
304 /* Rule #2: If one of the classes is NO_CLASS, the resulting class
305 is the other class. */
53e95fcf
JS
306 if (class1 == X86_64_NO_CLASS)
307 return class2;
308 if (class2 == X86_64_NO_CLASS)
309 return class1;
310
311 /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */
312 if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
313 return X86_64_MEMORY_CLASS;
314
315 /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */
316 if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
317 || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
318 return X86_64_INTEGERSI_CLASS;
319 if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
320 || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
321 return X86_64_INTEGER_CLASS;
322
323 /* Rule #5: If one of the classes is X87 or X87UP class, MEMORY is used. */
324 if (class1 == X86_64_X87_CLASS || class1 == X86_64_X87UP_CLASS
325 || class2 == X86_64_X87_CLASS || class2 == X86_64_X87UP_CLASS)
326 return X86_64_MEMORY_CLASS;
327
328 /* Rule #6: Otherwise class SSE is used. */
329 return X86_64_SSE_CLASS;
330}
331
26abbdc4
MK
332/* Classify the argument type. CLASSES will be filled by the register
333 class used to pass each word of the operand. The number of words
334 is returned. In case the parameter should be passed in memory, 0
335 is returned. As a special case for zero sized containers,
336 classes[0] will be NO_CLASS and 1 is returned.
53e95fcf 337
26abbdc4 338 See the x86-64 psABI for details. */
53e95fcf
JS
339
340static int
341classify_argument (struct type *type,
342 enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset)
343{
344 int bytes = TYPE_LENGTH (type);
345 int words = (bytes + 8 - 1) / 8;
346
347 switch (TYPE_CODE (type))
348 {
349 case TYPE_CODE_ARRAY:
350 case TYPE_CODE_STRUCT:
351 case TYPE_CODE_UNION:
352 {
353 int i;
354 enum x86_64_reg_class subclasses[MAX_CLASSES];
355
356 /* On x86-64 we pass structures larger than 16 bytes on the stack. */
357 if (bytes > 16)
358 return 0;
359
360 for (i = 0; i < words; i++)
361 classes[i] = X86_64_NO_CLASS;
362
26abbdc4
MK
363 /* Zero sized arrays or structures are NO_CLASS. We return 0
364 to signalize memory class, so handle it as special case. */
53e95fcf
JS
365 if (!words)
366 {
367 classes[0] = X86_64_NO_CLASS;
368 return 1;
369 }
370 switch (TYPE_CODE (type))
371 {
372 case TYPE_CODE_STRUCT:
373 {
374 int j;
0004e5a2 375 for (j = 0; j < TYPE_NFIELDS (type); ++j)
53e95fcf 376 {
0004e5a2 377 int num = classify_argument (TYPE_FIELDS (type)[j].type,
53e95fcf 378 subclasses,
8dda9770
ML
379 (TYPE_FIELDS (type)[j].loc.
380 bitpos + bit_offset) % 256);
53e95fcf
JS
381 if (!num)
382 return 0;
383 for (i = 0; i < num; i++)
384 {
385 int pos =
8dda9770
ML
386 (TYPE_FIELDS (type)[j].loc.bitpos +
387 bit_offset) / 8 / 8;
53e95fcf
JS
388 classes[i + pos] =
389 merge_classes (subclasses[i], classes[i + pos]);
390 }
391 }
392 }
393 break;
394 case TYPE_CODE_ARRAY:
395 {
396 int num;
397
0004e5a2 398 num = classify_argument (TYPE_TARGET_TYPE (type),
53e95fcf
JS
399 subclasses, bit_offset);
400 if (!num)
401 return 0;
402
403 /* The partial classes are now full classes. */
404 if (subclasses[0] == X86_64_SSESF_CLASS && bytes != 4)
405 subclasses[0] = X86_64_SSE_CLASS;
406 if (subclasses[0] == X86_64_INTEGERSI_CLASS && bytes != 4)
407 subclasses[0] = X86_64_INTEGER_CLASS;
408
409 for (i = 0; i < words; i++)
410 classes[i] = subclasses[i % num];
411 }
412 break;
413 case TYPE_CODE_UNION:
414 {
415 int j;
416 {
0004e5a2 417 for (j = 0; j < TYPE_NFIELDS (type); ++j)
53e95fcf
JS
418 {
419 int num;
0004e5a2 420 num = classify_argument (TYPE_FIELDS (type)[j].type,
53e95fcf
JS
421 subclasses, bit_offset);
422 if (!num)
423 return 0;
424 for (i = 0; i < num; i++)
425 classes[i] = merge_classes (subclasses[i], classes[i]);
426 }
427 }
428 }
429 break;
4657573b
ML
430 default:
431 break;
53e95fcf
JS
432 }
433 /* Final merger cleanup. */
434 for (i = 0; i < words; i++)
435 {
436 /* If one class is MEMORY, everything should be passed in
437 memory. */
438 if (classes[i] == X86_64_MEMORY_CLASS)
439 return 0;
440
441 /* The X86_64_SSEUP_CLASS should be always preceeded by
442 X86_64_SSE_CLASS. */
443 if (classes[i] == X86_64_SSEUP_CLASS
444 && (i == 0 || classes[i - 1] != X86_64_SSE_CLASS))
445 classes[i] = X86_64_SSE_CLASS;
446
26abbdc4 447 /* X86_64_X87UP_CLASS should be preceeded by X86_64_X87_CLASS. */
53e95fcf
JS
448 if (classes[i] == X86_64_X87UP_CLASS
449 && (i == 0 || classes[i - 1] != X86_64_X87_CLASS))
450 classes[i] = X86_64_SSE_CLASS;
451 }
452 return words;
453 }
454 break;
455 case TYPE_CODE_FLT:
456 switch (bytes)
457 {
458 case 4:
459 if (!(bit_offset % 64))
460 classes[0] = X86_64_SSESF_CLASS;
461 else
462 classes[0] = X86_64_SSE_CLASS;
463 return 1;
464 case 8:
465 classes[0] = X86_64_SSEDF_CLASS;
466 return 1;
467 case 16:
468 classes[0] = X86_64_X87_CLASS;
469 classes[1] = X86_64_X87UP_CLASS;
470 return 2;
471 }
472 break;
473 case TYPE_CODE_INT:
474 case TYPE_CODE_PTR:
475 switch (bytes)
476 {
477 case 1:
478 case 2:
479 case 4:
480 case 8:
481 if (bytes * 8 + bit_offset <= 32)
482 classes[0] = X86_64_INTEGERSI_CLASS;
483 else
484 classes[0] = X86_64_INTEGER_CLASS;
485 return 1;
486 case 16:
487 classes[0] = classes[1] = X86_64_INTEGER_CLASS;
488 return 2;
489 default:
490 break;
491 }
492 case TYPE_CODE_VOID:
493 return 0;
8dda9770 494 default: /* Avoid warning. */
4657573b 495 break;
53e95fcf 496 }
ce0eebec
AC
497 internal_error (__FILE__, __LINE__,
498 "classify_argument: unknown argument type");
53e95fcf
JS
499}
500
26abbdc4
MK
501/* Examine the argument and set *INT_NREGS and *SSE_NREGS to the
502 number of registers required based on the information passed in
503 CLASSES. Return 0 if parameter should be passed in memory. */
53e95fcf
JS
504
505static int
506examine_argument (enum x86_64_reg_class classes[MAX_CLASSES],
507 int n, int *int_nregs, int *sse_nregs)
508{
509 *int_nregs = 0;
510 *sse_nregs = 0;
511 if (!n)
512 return 0;
513 for (n--; n >= 0; n--)
514 switch (classes[n])
515 {
516 case X86_64_INTEGER_CLASS:
517 case X86_64_INTEGERSI_CLASS:
518 (*int_nregs)++;
519 break;
520 case X86_64_SSE_CLASS:
521 case X86_64_SSESF_CLASS:
522 case X86_64_SSEDF_CLASS:
523 (*sse_nregs)++;
524 break;
525 case X86_64_NO_CLASS:
526 case X86_64_SSEUP_CLASS:
527 case X86_64_X87_CLASS:
528 case X86_64_X87UP_CLASS:
529 break;
530 case X86_64_MEMORY_CLASS:
ce0eebec
AC
531 internal_error (__FILE__, __LINE__,
532 "examine_argument: unexpected memory class");
53e95fcf
JS
533 }
534 return 1;
535}
536
537#define RET_INT_REGS 2
538#define RET_SSE_REGS 2
539
540/* Check if the structure in value_type is returned in registers or in
26abbdc4
MK
541 memory. If this function returns 1, GDB will call
542 STORE_STRUCT_RETURN and EXTRACT_STRUCT_VALUE_ADDRESS else
543 STORE_RETURN_VALUE and EXTRACT_RETURN_VALUE will be used. */
53e95fcf
JS
544int
545x86_64_use_struct_convention (int gcc_p, struct type *value_type)
546{
547 enum x86_64_reg_class class[MAX_CLASSES];
548 int n = classify_argument (value_type, class, 0);
549 int needed_intregs;
550 int needed_sseregs;
551
552 return (!n ||
553 !examine_argument (class, n, &needed_intregs, &needed_sseregs) ||
554 needed_intregs > RET_INT_REGS || needed_sseregs > RET_SSE_REGS);
555}
556
53e95fcf
JS
557/* Extract from an array REGBUF containing the (raw) register state, a
558 function return value of TYPE, and copy that, in virtual format,
559 into VALBUF. */
560
561void
562x86_64_extract_return_value (struct type *type, char *regbuf, char *valbuf)
563{
564 enum x86_64_reg_class class[MAX_CLASSES];
565 int n = classify_argument (type, class, 0);
566 int needed_intregs;
567 int needed_sseregs;
568 int intreg = 0;
569 int ssereg = 0;
570 int offset = 0;
571 int ret_int_r[RET_INT_REGS] = { RAX_REGNUM, RDX_REGNUM };
572 int ret_sse_r[RET_SSE_REGS] = { XMM0_REGNUM, XMM1_REGNUM };
573
574 if (!n ||
575 !examine_argument (class, n, &needed_intregs, &needed_sseregs) ||
576 needed_intregs > RET_INT_REGS || needed_sseregs > RET_SSE_REGS)
577 { /* memory class */
578 CORE_ADDR addr;
579 memcpy (&addr, regbuf, REGISTER_RAW_SIZE (RAX_REGNUM));
580 read_memory (addr, valbuf, TYPE_LENGTH (type));
581 return;
582 }
583 else
584 {
585 int i;
586 for (i = 0; i < n; i++)
587 {
588 switch (class[i])
589 {
590 case X86_64_NO_CLASS:
591 break;
592 case X86_64_INTEGER_CLASS:
593 memcpy (valbuf + offset,
594 regbuf + REGISTER_BYTE (ret_int_r[(intreg + 1) / 2]),
595 8);
596 offset += 8;
597 intreg += 2;
598 break;
599 case X86_64_INTEGERSI_CLASS:
600 memcpy (valbuf + offset,
601 regbuf + REGISTER_BYTE (ret_int_r[intreg / 2]), 4);
602 offset += 8;
603 intreg++;
604 break;
605 case X86_64_SSEDF_CLASS:
606 case X86_64_SSESF_CLASS:
607 case X86_64_SSE_CLASS:
608 memcpy (valbuf + offset,
609 regbuf + REGISTER_BYTE (ret_sse_r[(ssereg + 1) / 2]),
610 8);
611 offset += 8;
612 ssereg += 2;
613 break;
614 case X86_64_SSEUP_CLASS:
615 memcpy (valbuf + offset + 8,
616 regbuf + REGISTER_BYTE (ret_sse_r[ssereg / 2]), 8);
617 offset += 8;
618 ssereg++;
619 break;
620 case X86_64_X87_CLASS:
621 memcpy (valbuf + offset, regbuf + REGISTER_BYTE (FP0_REGNUM),
622 8);
623 offset += 8;
624 break;
625 case X86_64_X87UP_CLASS:
626 memcpy (valbuf + offset,
627 regbuf + REGISTER_BYTE (FP0_REGNUM) + 8, 8);
628 offset += 8;
629 break;
630 case X86_64_MEMORY_CLASS:
631 default:
632 internal_error (__FILE__, __LINE__,
633 "Unexpected argument class");
634 }
635 }
636 }
637}
638
53e95fcf
JS
639static void
640x86_64_frame_init_saved_regs (struct frame_info *fi)
641{
26abbdc4 642 /* Do nothing. Everything is handled by the stack unwinding code. */
53e95fcf
JS
643}
644
645#define INT_REGS 6
646#define SSE_REGS 16
647
53e95fcf 648CORE_ADDR
d45fc520 649x86_64_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
53e95fcf
JS
650 int struct_return, CORE_ADDR struct_addr)
651{
652 int intreg = 0;
653 int ssereg = 0;
654 int i;
ce0eebec 655 static int int_parameter_registers[INT_REGS] = {
de220d0f
ML
656 5 /* RDI */ , 4 /* RSI */ ,
657 3 /* RDX */ , 2 /* RCX */ ,
91fd20f7 658 8 /* R8 */ , 9 /* R9 */
ce0eebec 659 };
53e95fcf 660 /* XMM0 - XMM15 */
ce0eebec 661 static int sse_parameter_registers[SSE_REGS] = {
de220d0f
ML
662 XMM1_REGNUM - 1, XMM1_REGNUM, XMM1_REGNUM + 1, XMM1_REGNUM + 2,
663 XMM1_REGNUM + 3, XMM1_REGNUM + 4, XMM1_REGNUM + 5, XMM1_REGNUM + 6,
664 XMM1_REGNUM + 7, XMM1_REGNUM + 8, XMM1_REGNUM + 9, XMM1_REGNUM + 10,
665 XMM1_REGNUM + 11, XMM1_REGNUM + 12, XMM1_REGNUM + 13, XMM1_REGNUM + 14
ce0eebec
AC
666 };
667 int stack_values_count = 0;
82dbc5f7 668 int *stack_values;
e9f30c21 669 stack_values = alloca (nargs * sizeof (int));
53e95fcf
JS
670 for (i = 0; i < nargs; i++)
671 {
672 enum x86_64_reg_class class[MAX_CLASSES];
673 int n = classify_argument (args[i]->type, class, 0);
674 int needed_intregs;
675 int needed_sseregs;
676
677 if (!n ||
678 !examine_argument (class, n, &needed_intregs, &needed_sseregs)
82dbc5f7
AC
679 || intreg / 2 + needed_intregs > INT_REGS
680 || ssereg / 2 + needed_sseregs > SSE_REGS)
ce0eebec
AC
681 { /* memory class */
682 stack_values[stack_values_count++] = i;
53e95fcf
JS
683 }
684 else
685 {
686 int j;
687 for (j = 0; j < n; j++)
688 {
689 int offset = 0;
690 switch (class[j])
691 {
692 case X86_64_NO_CLASS:
693 break;
694 case X86_64_INTEGER_CLASS:
4caf0990
AC
695 deprecated_write_register_gen (int_parameter_registers
696 [(intreg + 1) / 2],
697 VALUE_CONTENTS_ALL (args[i]) + offset);
53e95fcf
JS
698 offset += 8;
699 intreg += 2;
700 break;
701 case X86_64_INTEGERSI_CLASS:
4caf0990
AC
702 deprecated_write_register_gen (int_parameter_registers[intreg / 2],
703 VALUE_CONTENTS_ALL (args[i]) + offset);
53e95fcf
JS
704 offset += 8;
705 intreg++;
706 break;
707 case X86_64_SSEDF_CLASS:
708 case X86_64_SSESF_CLASS:
709 case X86_64_SSE_CLASS:
4caf0990
AC
710 deprecated_write_register_gen (sse_parameter_registers
711 [(ssereg + 1) / 2],
712 VALUE_CONTENTS_ALL (args[i]) + offset);
53e95fcf
JS
713 offset += 8;
714 ssereg += 2;
715 break;
716 case X86_64_SSEUP_CLASS:
4caf0990
AC
717 deprecated_write_register_gen (sse_parameter_registers[ssereg / 2],
718 VALUE_CONTENTS_ALL (args[i]) + offset);
53e95fcf
JS
719 offset += 8;
720 ssereg++;
721 break;
722 case X86_64_X87_CLASS:
53e95fcf 723 case X86_64_MEMORY_CLASS:
ce0eebec 724 stack_values[stack_values_count++] = i;
82dbc5f7
AC
725 break;
726 case X86_64_X87UP_CLASS:
53e95fcf
JS
727 break;
728 default:
729 internal_error (__FILE__, __LINE__,
730 "Unexpected argument class");
731 }
732 intreg += intreg % 2;
733 ssereg += ssereg % 2;
734 }
735 }
736 }
82dbc5f7
AC
737 while (--stack_values_count >= 0)
738 {
e9f30c21 739 struct value *arg = args[stack_values[stack_values_count]];
82dbc5f7
AC
740 int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
741 len += 7;
742 len -= len % 8;
743 sp -= len;
744 write_memory (sp, VALUE_CONTENTS_ALL (arg), len);
745 }
53e95fcf
JS
746 return sp;
747}
748
749/* Write into the appropriate registers a function return value stored
750 in VALBUF of type TYPE, given in virtual format. */
751void
752x86_64_store_return_value (struct type *type, char *valbuf)
753{
754 int len = TYPE_LENGTH (type);
755
756 if (TYPE_CODE_FLT == TYPE_CODE (type))
757 {
758 /* Floating-point return values can be found in %st(0). */
759 if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT
760 && TARGET_LONG_DOUBLE_FORMAT == &floatformat_i387_ext)
761 {
762 /* Copy straight over. */
763 write_register_bytes (REGISTER_BYTE (FP0_REGNUM), valbuf,
764 FPU_REG_RAW_SIZE);
765 }
766 else
767 {
768 char buf[FPU_REG_RAW_SIZE];
769 DOUBLEST val;
770
771 /* Convert the value found in VALBUF to the extended
772 floating point format used by the FPU. This is probably
773 not exactly how it would happen on the target itself, but
774 it is the best we can do. */
775 val = extract_floating (valbuf, TYPE_LENGTH (type));
776 floatformat_from_doublest (&floatformat_i387_ext, &val, buf);
777 write_register_bytes (REGISTER_BYTE (FP0_REGNUM), buf,
778 FPU_REG_RAW_SIZE);
779 }
780 }
781 else
782 {
783 int low_size = REGISTER_RAW_SIZE (0);
784 int high_size = REGISTER_RAW_SIZE (1);
785
786 if (len <= low_size)
787 write_register_bytes (REGISTER_BYTE (0), valbuf, len);
788 else if (len <= (low_size + high_size))
789 {
790 write_register_bytes (REGISTER_BYTE (0), valbuf, low_size);
791 write_register_bytes (REGISTER_BYTE (1),
792 valbuf + low_size, len - low_size);
793 }
794 else
795 internal_error (__FILE__, __LINE__,
796 "Cannot store return value of %d bytes long.", len);
797 }
798}
799\f
800
1cf877ad
ML
801const char *
802x86_64_register_name (int reg_nr)
53e95fcf 803{
de220d0f 804 if (reg_nr < 0 || reg_nr >= X86_64_NUM_REGS)
53e95fcf 805 return NULL;
de220d0f 806 return x86_64_register_info_table[reg_nr].name;
53e95fcf 807}
8dda9770
ML
808
809int
1cf877ad 810x86_64_register_number (const char *name)
8dda9770
ML
811{
812 int reg_nr;
813
814 for (reg_nr = 0; reg_nr < X86_64_NUM_REGS; reg_nr++)
815 if (strcmp (name, x86_64_register_info_table[reg_nr].name) == 0)
816 return reg_nr;
817 return -1;
818}
53e95fcf
JS
819\f
820
821
822/* We have two flavours of disassembly. The machinery on this page
823 deals with switching between those. */
824
825static int
826gdb_print_insn_x86_64 (bfd_vma memaddr, disassemble_info * info)
827{
828 if (disassembly_flavour == att_flavour)
829 return print_insn_i386_att (memaddr, info);
830 else if (disassembly_flavour == intel_flavour)
831 return print_insn_i386_intel (memaddr, info);
832 /* Never reached -- disassembly_flavour is always either att_flavour
833 or intel_flavour. */
834 internal_error (__FILE__, __LINE__, "failed internal consistency check");
835}
836\f
837
838/* Store the address of the place in which to copy the structure the
839 subroutine will return. This is called from call_function. */
840void
841x86_64_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
842{
843 write_register (RDI_REGNUM, addr);
844}
845
846int
847x86_64_frameless_function_invocation (struct frame_info *frame)
848{
849 return 0;
850}
851
e76e1718
ML
852/* If a function with debugging information and known beginning
853 is detected, we will return pc of the next line in the source
854 code. With this approach we effectively skip the prolog. */
855
856#define PROLOG_BUFSIZE 4
53e95fcf
JS
857CORE_ADDR
858x86_64_skip_prologue (CORE_ADDR pc)
859{
482a4d06 860 int i;
e76e1718
ML
861 struct symtab_and_line v_sal;
862 struct symbol *v_function;
482a4d06 863 CORE_ADDR endaddr;
26abbdc4 864 unsigned char prolog_buf[PROLOG_BUFSIZE];
e76e1718 865
26abbdc4
MK
866 /* We will handle only functions starting with: */
867 static unsigned char prolog_expect[PROLOG_BUFSIZE] =
868 {
869 0x55, /* pushq %rbp */
870 0x48, 0x89, 0xe5 /* movq %rsp, %rbp */
871 };
e76e1718
ML
872
873 read_memory (pc, (char *) prolog_buf, PROLOG_BUFSIZE);
874
26abbdc4 875 /* First check, whether pc points to pushq %rbp, movq %rsp, %rbp. */
b1ab997b 876 for (i = 0; i < PROLOG_BUFSIZE; i++)
b6779aa2 877 if (prolog_expect[i] != prolog_buf[i])
26abbdc4 878 return pc; /* ... no, it doesn't. Nothing to skip. */
b1ab997b 879
26abbdc4 880 /* OK, we have found the prologue and want PC of the first
b1ab997b
ML
881 non-prologue instruction. */
882 pc += PROLOG_BUFSIZE;
e76e1718
ML
883
884 v_function = find_pc_function (pc);
885 v_sal = find_pc_line (pc, 0);
886
26abbdc4
MK
887 /* If pc doesn't point to a function with debuginfo, some of the
888 following may be NULL. */
e76e1718
ML
889 if (!v_function || !v_function->ginfo.value.block || !v_sal.symtab)
890 return pc;
891
8da065d5 892 endaddr = BLOCK_END (SYMBOL_BLOCK_VALUE (v_function));
e76e1718
ML
893
894 for (i = 0; i < v_sal.symtab->linetable->nitems; i++)
482a4d06 895 if (v_sal.symtab->linetable->item[i].pc >= pc
e76e1718
ML
896 && v_sal.symtab->linetable->item[i].pc < endaddr)
897 {
898 pc = v_sal.symtab->linetable->item[i].pc;
e76e1718
ML
899 break;
900 }
901
53e95fcf
JS
902 return pc;
903}
904
905/* Sequence of bytes for breakpoint instruction. */
ab91194c 906static const unsigned char *
b64bbf8c 907x86_64_breakpoint_from_pc (CORE_ADDR *pc, int *lenptr)
53e95fcf
JS
908{
909 static unsigned char breakpoint[] = { 0xcc };
910 *lenptr = 1;
911 return breakpoint;
912}
913
0c1a73d6
MK
914static void
915x86_64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
53e95fcf 916{
0c1a73d6 917 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
de220d0f 918 int i, sum;
53e95fcf 919
b83b026c 920 /* The x86-64 has 16 SSE registers. */
0c1a73d6 921 tdep->num_xmm_regs = 16;
53e95fcf 922
0c1a73d6 923 /* This is what all the fuss is about. */
53e95fcf
JS
924 set_gdbarch_long_bit (gdbarch, 64);
925 set_gdbarch_long_long_bit (gdbarch, 64);
926 set_gdbarch_ptr_bit (gdbarch, 64);
927
b83b026c
MK
928 /* In contrast to the i386, on the x86-64 a `long double' actually
929 takes up 128 bits, even though it's still based on the i387
930 extended floating-point format which has only 80 significant bits. */
931 set_gdbarch_long_double_bit (gdbarch, 128);
932
53e95fcf 933 set_gdbarch_num_regs (gdbarch, X86_64_NUM_REGS);
b83b026c
MK
934
935 /* Register numbers of various important registers. */
936 set_gdbarch_sp_regnum (gdbarch, 7); /* %rsp */
937 set_gdbarch_fp_regnum (gdbarch, 6); /* %rbp */
938 set_gdbarch_pc_regnum (gdbarch, 16); /* %rip */
939 set_gdbarch_ps_regnum (gdbarch, 17); /* %eflags */
940 set_gdbarch_fp0_regnum (gdbarch, X86_64_NUM_GREGS); /* %st(0) */
941
942 /* The "default" register numbering scheme for the x86-64 is
943 referred to as the "DWARF register number mapping" in the psABI.
944 The preferred debugging format for all known x86-64 targets is
945 actually DWARF2, and GCC doesn't seem to support DWARF (that is
946 DWARF-1), but we provide the same mapping just in case. This
947 mapping is also used for stabs, which GCC does support. */
948 set_gdbarch_stab_reg_to_regnum (gdbarch, x86_64_dwarf2_reg_to_regnum);
949 set_gdbarch_dwarf_reg_to_regnum (gdbarch, x86_64_dwarf2_reg_to_regnum);
950 set_gdbarch_dwarf2_reg_to_regnum (gdbarch, x86_64_dwarf2_reg_to_regnum);
951
952 /* We don't override SDB_REG_RO_REGNUM, sice COFF doesn't seem to be
953 in use on any of the supported x86-64 targets. */
954
1cf877ad 955 set_gdbarch_register_name (gdbarch, x86_64_register_name);
53e95fcf 956 set_gdbarch_register_size (gdbarch, 8);
de220d0f 957
0c1a73d6
MK
958 /* Total amount of space needed to store our copies of the machine's
959 register (SIZEOF_GREGS + SIZEOF_FPU_REGS + SIZEOF_FPU_CTRL_REGS +
960 SIZEOF_SSE_REGS) */
de220d0f
ML
961 for (i = 0, sum = 0; i < X86_64_NUM_REGS; i++)
962 sum += x86_64_register_info_table[i].size;
963 set_gdbarch_register_bytes (gdbarch, sum);
53e95fcf 964
b83b026c
MK
965 set_gdbarch_register_raw_size (gdbarch, x86_64_register_raw_size);
966 set_gdbarch_register_byte (gdbarch, x86_64_register_byte);
53e95fcf
JS
967 set_gdbarch_register_virtual_type (gdbarch, x86_64_register_virtual_type);
968
b83b026c
MK
969 /* FIXME: kettenis/20021026: As long as we don't support longjmp,
970 that is, as long as we have `tdep->jb_pc_offset == -1', using
971 i386_get_longjmp_target is fine. */
972
53e95fcf
JS
973 set_gdbarch_register_convertible (gdbarch, x86_64_register_convertible);
974 set_gdbarch_register_convert_to_virtual (gdbarch,
975 x86_64_register_convert_to_virtual);
976 set_gdbarch_register_convert_to_raw (gdbarch,
977 x86_64_register_convert_to_raw);
978
b83b026c
MK
979 /* Getting saved registers is handled by unwind information. */
980 set_gdbarch_get_saved_register (gdbarch, cfi_get_saved_register);
53e95fcf 981
b83b026c 982 /* FIXME: kettenis/20021026: Should we set parm_boundary to 64 here? */
53e95fcf 983 set_gdbarch_read_fp (gdbarch, cfi_read_fp);
53e95fcf 984
b83b026c
MK
985 /* FIXME: kettenis/20021026: Should be undeprecated. */
986 set_gdbarch_extract_return_value (gdbarch, NULL);
987 set_gdbarch_deprecated_extract_return_value (gdbarch,
988 x86_64_extract_return_value);
989 set_gdbarch_push_arguments (gdbarch, x86_64_push_arguments);
990 set_gdbarch_push_return_address (gdbarch, x86_64_push_return_address);
53e95fcf 991 set_gdbarch_pop_frame (gdbarch, x86_64_pop_frame);
b83b026c
MK
992 set_gdbarch_store_struct_return (gdbarch, x86_64_store_struct_return);
993 /* FIXME: kettenis/20021026: Should be undeprecated. */
994 set_gdbarch_store_return_value (gdbarch, NULL);
995 set_gdbarch_deprecated_store_return_value (gdbarch,
996 x86_64_store_return_value);
997 /* Override, since this is handled by x86_64_extract_return_value. */
998 set_gdbarch_extract_struct_value_address (gdbarch, NULL);
999 set_gdbarch_use_struct_convention (gdbarch, x86_64_use_struct_convention);
53e95fcf
JS
1000
1001 set_gdbarch_frame_init_saved_regs (gdbarch, x86_64_frame_init_saved_regs);
b83b026c 1002 set_gdbarch_skip_prologue (gdbarch, x86_64_skip_prologue);
53e95fcf 1003
b83b026c
MK
1004 set_gdbarch_frame_chain (gdbarch, x86_64_linux_frame_chain);
1005 set_gdbarch_frameless_function_invocation (gdbarch,
1006 x86_64_frameless_function_invocation);
ab91194c
MK
1007 /* FIXME: kettenis/20021025: Shouldn't this be set to
1008 generic_file_frame_chain_valid? */
baed091b 1009 set_gdbarch_frame_chain_valid (gdbarch, file_frame_chain_valid);
b83b026c
MK
1010 /* FIXME: kettenis/20021026: These two are GNU/Linux-specific and
1011 should be moved elsewhere. */
1012 set_gdbarch_frame_saved_pc (gdbarch, x86_64_linux_frame_saved_pc);
1013 set_gdbarch_saved_pc_after_call (gdbarch, x86_64_linux_saved_pc_after_call);
53e95fcf 1014 set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
b83b026c
MK
1015 /* FIXME: kettenis/20021026: This one is GNU/Linux-specific too. */
1016 set_gdbarch_pc_in_sigtramp (gdbarch, x86_64_linux_in_sigtramp);
53e95fcf 1017
b83b026c
MK
1018 /* Build call frame information (CFI) from DWARF2 frame debug info. */
1019 set_gdbarch_dwarf2_build_frame_info (gdbarch, dwarf2_build_frame_info);
53e95fcf 1020
b83b026c 1021 /* Initialization of per-frame CFI. */
e3033f15 1022 set_gdbarch_init_extra_frame_info (gdbarch, cfi_init_extra_frame_info);
53e95fcf 1023
b83b026c
MK
1024 /* Frame PC initialization is handled by using CFI. */
1025 set_gdbarch_init_frame_pc (gdbarch, x86_64_init_frame_pc);
53e95fcf 1026
b83b026c
MK
1027 /* Cons up virtual frame pointer for trace. */
1028 set_gdbarch_virtual_frame_pointer (gdbarch, cfi_virtual_frame_pointer);
53e95fcf 1029
b83b026c
MK
1030 /* FIXME: kettenis/20021026: This is ELF-specific. Fine for now,
1031 since all supported x86-64 targets are ELF, but that might change
1032 in the future. */
8a8ab2b9 1033 set_gdbarch_in_solib_call_trampoline (gdbarch, in_plt_section);
0c1a73d6
MK
1034}
1035
1036static struct gdbarch *
1037x86_64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
1038{
1039 struct gdbarch_tdep *tdep;
1040 struct gdbarch *gdbarch;
1041 enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;
1042
1043 /* Try to determine the OS ABI of the object we're loading. */
1044 if (info.abfd != NULL)
1045 osabi = gdbarch_lookup_osabi (info.abfd);
1046
1047 /* Find a candidate among extant architectures. */
1048 for (arches = gdbarch_list_lookup_by_info (arches, &info);
1049 arches != NULL;
1050 arches = gdbarch_list_lookup_by_info (arches->next, &info))
1051 {
1052 /* Make sure the OS ABI selection matches. */
1053 tdep = gdbarch_tdep (arches->gdbarch);
1054 if (tdep && tdep->osabi == osabi)
1055 return arches->gdbarch;
1056 }
1057
1058 /* Allocate space for the new architecture. */
1059 tdep = XMALLOC (struct gdbarch_tdep);
1060 gdbarch = gdbarch_alloc (&info, tdep);
1061
1062 tdep->osabi = osabi;
1063
ab91194c
MK
1064 /* FIXME: kettenis/20021025: The following calls are going to
1065 disappear when we integrate the x86_64 target into the i386
1066 target. */
1067
1068 set_gdbarch_long_double_format (gdbarch, &floatformat_i387_ext);
1069
1070 set_gdbarch_max_register_raw_size (gdbarch, 16);
1071 set_gdbarch_max_register_virtual_size (gdbarch, 16);
1072
1073 set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
1074
1075 set_gdbarch_breakpoint_from_pc (gdbarch, x86_64_breakpoint_from_pc);
1076 set_gdbarch_decr_pc_after_break (gdbarch, 1);
1077 set_gdbarch_function_start_offset (gdbarch, 0);
1078
1079 set_gdbarch_frame_args_skip (gdbarch, 8);
1080 set_gdbarch_frame_args_address (gdbarch, default_frame_address);
1081 set_gdbarch_frame_locals_address (gdbarch, default_frame_address);
1082
1083 set_gdbarch_use_generic_dummy_frames (gdbarch, 1);
1084
1085 set_gdbarch_call_dummy_location (gdbarch, AT_ENTRY_POINT);
1086 set_gdbarch_call_dummy_address (gdbarch, entry_point_address);
1087 set_gdbarch_call_dummy_start_offset (gdbarch, 0);
1088 set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0);
1089 set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1);
1090 set_gdbarch_call_dummy_length (gdbarch, 0);
1091 set_gdbarch_call_dummy_p (gdbarch, 1);
1092 set_gdbarch_call_dummy_words (gdbarch, NULL);
1093 set_gdbarch_sizeof_call_dummy_words (gdbarch, 0);
1094 set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy);
1095 set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
1096
1097 set_gdbarch_pc_in_call_dummy (gdbarch, pc_in_call_dummy_at_entry_point);
1098
1099 set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
1100
1101 /* FIXME: kettenis/20021025: These already are the default. */
1102
1103 set_gdbarch_register_virtual_size (gdbarch, generic_register_size);
1104 set_gdbarch_deprecated_extract_struct_value_address (gdbarch, 0);
1105
0c1a73d6 1106 x86_64_init_abi (info, gdbarch);
baed091b 1107
53e95fcf
JS
1108 return gdbarch;
1109}
1110
1111void
1112_initialize_x86_64_tdep (void)
1113{
0e04a514 1114 register_gdbarch_init (bfd_arch_i386, x86_64_gdbarch_init);
53e95fcf
JS
1115
1116 /* Initialize the table saying where each register starts in the
1117 register file. */
1118 {
1119 int i, offset;
1120
1121 offset = 0;
1122 for (i = 0; i < X86_64_NUM_REGS; i++)
1123 {
1124 x86_64_register_byte_table[i] = offset;
de220d0f 1125 offset += x86_64_register_info_table[i].size;
53e95fcf
JS
1126 }
1127 }
1128
1129 tm_print_insn = gdb_print_insn_x86_64;
ecd1107e 1130 tm_print_insn_info.mach = bfd_mach_x86_64;
53e95fcf
JS
1131
1132 /* Add the variable that controls the disassembly flavour. */
1133 {
1134 struct cmd_list_element *new_cmd;
1135
1136 new_cmd = add_set_enum_cmd ("disassembly-flavour", no_class,
1137 valid_flavours, &disassembly_flavour, "\
1138Set the disassembly flavour, the valid values are \"att\" and \"intel\", \
1139and the default value is \"att\".", &setlist);
1140 add_show_from_set (new_cmd, &showlist);
1141 }
1142}
This page took 0.311805 seconds and 4 git commands to generate.