1 /* Intel 386 target-dependent stuff.
2 Copyright (C) 1988, 1989, 1991, 1994, 1995, 1996, 1998
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "gdb_string.h"
28 #include "floatformat.h"
32 #include "arch-utils.h"
34 static long i386_get_frame_setup (CORE_ADDR
);
36 static void i386_follow_jump (void);
38 static void codestream_read (unsigned char *, int);
40 static void codestream_seek (CORE_ADDR
);
42 static unsigned char codestream_fill (int);
44 CORE_ADDR
skip_trampoline_code (CORE_ADDR
, char *);
46 static int gdb_print_insn_i386 (bfd_vma
, disassemble_info
*);
48 void _initialize_i386_tdep (void);
50 /* i386_register_byte[i] is the offset into the register file of the
51 start of register number i. We initialize this from
52 i386_register_raw_size. */
53 int i386_register_byte
[MAX_NUM_REGS
];
55 /* i386_register_raw_size[i] is the number of bytes of storage in
56 GDB's register array occupied by register i. */
57 int i386_register_raw_size
[MAX_NUM_REGS
] = {
71 /* i386_register_virtual_size[i] is the size in bytes of the virtual
72 type of register i. */
73 int i386_register_virtual_size
[MAX_NUM_REGS
];
76 /* This is the variable the is set with "set disassembly-flavor",
77 and its legitimate values. */
78 static const char att_flavor
[] = "att";
79 static const char intel_flavor
[] = "intel";
80 static const char *valid_flavors
[] =
86 static const char *disassembly_flavor
= att_flavor
;
88 static void i386_print_register (char *, int, int);
90 /* This is used to keep the bfd arch_info in sync with the disassembly flavor. */
91 static void set_disassembly_flavor_sfunc (char *, int,
92 struct cmd_list_element
*);
93 static void set_disassembly_flavor (void);
95 /* Stdio style buffering was used to minimize calls to ptrace, but this
96 buffering did not take into account that the code section being accessed
97 may not be an even number of buffers long (even if the buffer is only
98 sizeof(int) long). In cases where the code section size happened to
99 be a non-integral number of buffers long, attempting to read the last
100 buffer would fail. Simply using target_read_memory and ignoring errors,
101 rather than read_memory, is not the correct solution, since legitimate
102 access errors would then be totally ignored. To properly handle this
103 situation and continue to use buffering would require that this code
104 be able to determine the minimum code section size granularity (not the
105 alignment of the section itself, since the actual failing case that
106 pointed out this problem had a section alignment of 4 but was not a
107 multiple of 4 bytes long), on a target by target basis, and then
108 adjust it's buffer size accordingly. This is messy, but potentially
109 feasible. It probably needs the bfd library's help and support. For
110 now, the buffer size is set to 1. (FIXME -fnf) */
112 #define CODESTREAM_BUFSIZ 1 /* Was sizeof(int), see note above. */
113 static CORE_ADDR codestream_next_addr
;
114 static CORE_ADDR codestream_addr
;
115 static unsigned char codestream_buf
[CODESTREAM_BUFSIZ
];
116 static int codestream_off
;
117 static int codestream_cnt
;
119 #define codestream_tell() (codestream_addr + codestream_off)
120 #define codestream_peek() (codestream_cnt == 0 ? \
121 codestream_fill(1): codestream_buf[codestream_off])
122 #define codestream_get() (codestream_cnt-- == 0 ? \
123 codestream_fill(0) : codestream_buf[codestream_off++])
126 codestream_fill (int peek_flag
)
128 codestream_addr
= codestream_next_addr
;
129 codestream_next_addr
+= CODESTREAM_BUFSIZ
;
131 codestream_cnt
= CODESTREAM_BUFSIZ
;
132 read_memory (codestream_addr
, (char *) codestream_buf
, CODESTREAM_BUFSIZ
);
135 return (codestream_peek ());
137 return (codestream_get ());
141 codestream_seek (CORE_ADDR place
)
143 codestream_next_addr
= place
/ CODESTREAM_BUFSIZ
;
144 codestream_next_addr
*= CODESTREAM_BUFSIZ
;
147 while (codestream_tell () != place
)
152 codestream_read (unsigned char *buf
, int count
)
157 for (i
= 0; i
< count
; i
++)
158 *p
++ = codestream_get ();
161 /* next instruction is a jump, move to target */
164 i386_follow_jump (void)
166 unsigned char buf
[4];
172 pos
= codestream_tell ();
175 if (codestream_peek () == 0x66)
181 switch (codestream_get ())
184 /* relative jump: if data16 == 0, disp32, else disp16 */
187 codestream_read (buf
, 2);
188 delta
= extract_signed_integer (buf
, 2);
190 /* include size of jmp inst (including the 0x66 prefix). */
195 codestream_read (buf
, 4);
196 delta
= extract_signed_integer (buf
, 4);
202 /* relative jump, disp8 (ignore data16) */
203 codestream_read (buf
, 1);
204 /* Sign-extend it. */
205 delta
= extract_signed_integer (buf
, 1);
210 codestream_seek (pos
);
214 * find & return amound a local space allocated, and advance codestream to
215 * first register push (if any)
217 * if entry sequence doesn't make sense, return -1, and leave
218 * codestream pointer random
222 i386_get_frame_setup (CORE_ADDR pc
)
226 codestream_seek (pc
);
230 op
= codestream_get ();
232 if (op
== 0x58) /* popl %eax */
235 * this function must start with
238 * xchgl %eax, (%esp) 0x87 0x04 0x24
239 * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00
241 * (the system 5 compiler puts out the second xchg
242 * inst, and the assembler doesn't try to optimize it,
243 * so the 'sib' form gets generated)
245 * this sequence is used to get the address of the return
246 * buffer for a function that returns a structure
249 unsigned char buf
[4];
250 static unsigned char proto1
[3] =
252 static unsigned char proto2
[4] =
253 {0x87, 0x44, 0x24, 0x00};
254 pos
= codestream_tell ();
255 codestream_read (buf
, 4);
256 if (memcmp (buf
, proto1
, 3) == 0)
258 else if (memcmp (buf
, proto2
, 4) == 0)
261 codestream_seek (pos
);
262 op
= codestream_get (); /* update next opcode */
265 if (op
== 0x68 || op
== 0x6a)
268 * this function may start with
278 unsigned char buf
[8];
280 /* Skip past the pushl instruction; it has either a one-byte
281 or a four-byte operand, depending on the opcode. */
282 pos
= codestream_tell ();
287 codestream_seek (pos
);
289 /* Read the following 8 bytes, which should be "call _probe" (6 bytes)
290 followed by "addl $4,%esp" (2 bytes). */
291 codestream_read (buf
, sizeof (buf
));
292 if (buf
[0] == 0xe8 && buf
[6] == 0xc4 && buf
[7] == 0x4)
294 codestream_seek (pos
);
295 op
= codestream_get (); /* update next opcode */
298 if (op
== 0x55) /* pushl %ebp */
300 /* check for movl %esp, %ebp - can be written two ways */
301 switch (codestream_get ())
304 if (codestream_get () != 0xec)
308 if (codestream_get () != 0xe5)
314 /* check for stack adjustment
318 * note: you can't subtract a 16 bit immediate
319 * from a 32 bit reg, so we don't have to worry
320 * about a data16 prefix
322 op
= codestream_peek ();
325 /* subl with 8 bit immed */
327 if (codestream_get () != 0xec)
328 /* Some instruction starting with 0x83 other than subl. */
330 codestream_seek (codestream_tell () - 2);
333 /* subl with signed byte immediate
334 * (though it wouldn't make sense to be negative)
336 return (codestream_get ());
341 /* Maybe it is subl with 32 bit immedediate. */
343 if (codestream_get () != 0xec)
344 /* Some instruction starting with 0x81 other than subl. */
346 codestream_seek (codestream_tell () - 2);
349 /* It is subl with 32 bit immediate. */
350 codestream_read ((unsigned char *) buf
, 4);
351 return extract_signed_integer (buf
, 4);
361 /* enter instruction: arg is 16 bit unsigned immed */
362 codestream_read ((unsigned char *) buf
, 2);
363 codestream_get (); /* flush final byte of enter instruction */
364 return extract_unsigned_integer (buf
, 2);
369 /* Return number of args passed to a frame.
370 Can return -1, meaning no way to tell. */
373 i386_frame_num_args (struct frame_info
*fi
)
378 /* This loses because not only might the compiler not be popping the
379 args right after the function call, it might be popping args from both
380 this call and a previous one, and we would say there are more args
381 than there really are. */
385 struct frame_info
*pfi
;
387 /* on the 386, the instruction following the call could be:
389 addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits
390 anything else - zero args */
394 frameless
= FRAMELESS_FUNCTION_INVOCATION (fi
);
396 /* In the absence of a frame pointer, GDB doesn't get correct values
397 for nameless arguments. Return -1, so it doesn't print any
398 nameless arguments. */
401 pfi
= get_prev_frame (fi
);
404 /* Note: this can happen if we are looking at the frame for
405 main, because FRAME_CHAIN_VALID won't let us go into
406 start. If we have debugging symbols, that's not really
407 a big deal; it just means it will only show as many arguments
408 to main as are declared. */
414 op
= read_memory_integer (retpc
, 1);
420 op
= read_memory_integer (retpc
+ 1, 1);
422 /* addl $<signed imm 8 bits>, %esp */
423 return (read_memory_integer (retpc
+ 2, 1) & 0xff) / 4;
428 { /* add with 32 bit immediate */
429 op
= read_memory_integer (retpc
+ 1, 1);
431 /* addl $<imm 32>, %esp */
432 return read_memory_integer (retpc
+ 2, 4) / 4;
445 * parse the first few instructions of the function to see
446 * what registers were stored.
448 * We handle these cases:
450 * The startup sequence can be at the start of the function,
451 * or the function can start with a branch to startup code at the end.
453 * %ebp can be set up with either the 'enter' instruction, or
454 * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful,
455 * but was once used in the sys5 compiler)
457 * Local space is allocated just below the saved %ebp by either the
458 * 'enter' instruction, or by 'subl $<size>, %esp'. 'enter' has
459 * a 16 bit unsigned argument for space to allocate, and the
460 * 'addl' instruction could have either a signed byte, or
463 * Next, the registers used by this function are pushed. In
464 * the sys5 compiler they will always be in the order: %edi, %esi, %ebx
465 * (and sometimes a harmless bug causes it to also save but not restore %eax);
466 * however, the code below is willing to see the pushes in any order,
467 * and will handle up to 8 of them.
469 * If the setup sequence is at the end of the function, then the
470 * next instruction will be a branch back to the start.
474 i386_frame_init_saved_regs (struct frame_info
*fip
)
478 CORE_ADDR dummy_bottom
;
486 frame_saved_regs_zalloc (fip
);
488 /* if frame is the end of a dummy, compute where the
491 dummy_bottom
= fip
->frame
- 4 - REGISTER_BYTES
- CALL_DUMMY_LENGTH
;
493 /* check if the PC is in the stack, in a dummy frame */
494 if (dummy_bottom
<= fip
->pc
&& fip
->pc
<= fip
->frame
)
496 /* all regs were saved by push_call_dummy () */
498 for (i
= 0; i
< NUM_REGS
; i
++)
500 adr
-= REGISTER_RAW_SIZE (i
);
501 fip
->saved_regs
[i
] = adr
;
506 pc
= get_pc_function_start (fip
->pc
);
508 locals
= i386_get_frame_setup (pc
);
512 adr
= fip
->frame
- 4 - locals
;
513 for (i
= 0; i
< 8; i
++)
515 op
= codestream_get ();
516 if (op
< 0x50 || op
> 0x57)
518 #ifdef I386_REGNO_TO_SYMMETRY
519 /* Dynix uses different internal numbering. Ick. */
520 fip
->saved_regs
[I386_REGNO_TO_SYMMETRY (op
- 0x50)] = adr
;
522 fip
->saved_regs
[op
- 0x50] = adr
;
528 fip
->saved_regs
[PC_REGNUM
] = fip
->frame
+ 4;
529 fip
->saved_regs
[FP_REGNUM
] = fip
->frame
;
532 /* return pc of first real instruction */
535 i386_skip_prologue (int pc
)
539 static unsigned char pic_pat
[6] =
540 {0xe8, 0, 0, 0, 0, /* call 0x0 */
541 0x5b, /* popl %ebx */
545 if (i386_get_frame_setup (pc
) < 0)
548 /* found valid frame setup - codestream now points to
549 * start of push instructions for saving registers
552 /* skip over register saves */
553 for (i
= 0; i
< 8; i
++)
555 op
= codestream_peek ();
556 /* break if not pushl inst */
557 if (op
< 0x50 || op
> 0x57)
562 /* The native cc on SVR4 in -K PIC mode inserts the following code to get
563 the address of the global offset table (GOT) into register %ebx.
566 movl %ebx,x(%ebp) (optional)
568 This code is with the rest of the prologue (at the end of the
569 function), so we have to skip it to get to the first real
570 instruction at the start of the function. */
572 pos
= codestream_tell ();
573 for (i
= 0; i
< 6; i
++)
575 op
= codestream_get ();
576 if (pic_pat
[i
] != op
)
581 unsigned char buf
[4];
584 op
= codestream_get ();
585 if (op
== 0x89) /* movl %ebx, x(%ebp) */
587 op
= codestream_get ();
588 if (op
== 0x5d) /* one byte offset from %ebp */
591 codestream_read (buf
, 1);
593 else if (op
== 0x9d) /* four byte offset from %ebp */
596 codestream_read (buf
, 4);
598 else /* unexpected instruction */
600 op
= codestream_get ();
603 if (delta
> 0 && op
== 0x81 && codestream_get () == 0xc3)
608 codestream_seek (pos
);
612 return (codestream_tell ());
616 i386_push_dummy_frame (void)
618 CORE_ADDR sp
= read_register (SP_REGNUM
);
620 char regbuf
[MAX_REGISTER_RAW_SIZE
];
622 sp
= push_word (sp
, read_register (PC_REGNUM
));
623 sp
= push_word (sp
, read_register (FP_REGNUM
));
624 write_register (FP_REGNUM
, sp
);
625 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
627 read_register_gen (regnum
, regbuf
);
628 sp
= push_bytes (sp
, regbuf
, REGISTER_RAW_SIZE (regnum
));
630 write_register (SP_REGNUM
, sp
);
633 /* Insert the (relative) function address into the call sequence
637 i386_fix_call_dummy (char *dummy
, CORE_ADDR pc
, CORE_ADDR fun
, int nargs
,
638 value_ptr
*args
, struct type
*type
, int gcc_p
)
640 int from
, to
, delta
, loc
;
642 loc
= (int)(read_register (SP_REGNUM
) - CALL_DUMMY_LENGTH
);
647 *((char *)(dummy
) + 1) = (delta
& 0xff);
648 *((char *)(dummy
) + 2) = ((delta
>> 8) & 0xff);
649 *((char *)(dummy
) + 3) = ((delta
>> 16) & 0xff);
650 *((char *)(dummy
) + 4) = ((delta
>> 24) & 0xff);
654 i386_pop_frame (void)
656 struct frame_info
*frame
= get_current_frame ();
659 char regbuf
[MAX_REGISTER_RAW_SIZE
];
661 fp
= FRAME_FP (frame
);
662 i386_frame_init_saved_regs (frame
);
664 for (regnum
= 0; regnum
< NUM_REGS
; regnum
++)
667 adr
= frame
->saved_regs
[regnum
];
670 read_memory (adr
, regbuf
, REGISTER_RAW_SIZE (regnum
));
671 write_register_bytes (REGISTER_BYTE (regnum
), regbuf
,
672 REGISTER_RAW_SIZE (regnum
));
675 write_register (FP_REGNUM
, read_memory_integer (fp
, 4));
676 write_register (PC_REGNUM
, read_memory_integer (fp
+ 4, 4));
677 write_register (SP_REGNUM
, fp
+ 8);
678 flush_cached_frames ();
681 #ifdef GET_LONGJMP_TARGET
683 /* Figure out where the longjmp will land. Slurp the args out of the stack.
684 We expect the first arg to be a pointer to the jmp_buf structure from which
685 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
686 This routine returns true on success. */
689 get_longjmp_target (CORE_ADDR
*pc
)
691 char buf
[TARGET_PTR_BIT
/ TARGET_CHAR_BIT
];
692 CORE_ADDR sp
, jb_addr
;
694 sp
= read_register (SP_REGNUM
);
696 if (target_read_memory (sp
+ SP_ARG0
, /* Offset of first arg on stack */
698 TARGET_PTR_BIT
/ TARGET_CHAR_BIT
))
701 jb_addr
= extract_address (buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
703 if (target_read_memory (jb_addr
+ JB_PC
* JB_ELEMENT_SIZE
, buf
,
704 TARGET_PTR_BIT
/ TARGET_CHAR_BIT
))
707 *pc
= extract_address (buf
, TARGET_PTR_BIT
/ TARGET_CHAR_BIT
);
712 #endif /* GET_LONGJMP_TARGET */
714 /* These registers are used for returning integers (and on some
715 targets also for returning `struct' and `union' values when their
716 size and alignment match an integer type. */
717 #define LOW_RETURN_REGNUM 0 /* %eax */
718 #define HIGH_RETURN_REGNUM 2 /* %edx */
720 /* Extract from an array REGBUF containing the (raw) register state, a
721 function return value of TYPE, and copy that, in virtual format,
725 i386_extract_return_value (struct type
*type
, char *regbuf
, char *valbuf
)
727 int len
= TYPE_LENGTH (type
);
729 if (TYPE_CODE_FLT
== TYPE_CODE (type
))
733 warning ("Cannot find floating-point return value.");
734 memset (valbuf
, 0, len
);
737 /* Floating-point return values can be found in %st(0). */
738 if (len
== TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
739 && TARGET_LONG_DOUBLE_FORMAT
== &floatformat_i387_ext
)
741 /* Copy straight over, but take care of the padding. */
742 memcpy (valbuf
, ®buf
[REGISTER_BYTE (FP0_REGNUM
)],
744 memset (valbuf
+ FPU_REG_RAW_SIZE
, 0, len
- FPU_REG_RAW_SIZE
);
748 /* Convert the extended floating-point number found in
749 %st(0) to the desired type. This is probably not exactly
750 how it would happen on the target itself, but it is the
753 floatformat_to_doublest (&floatformat_i387_ext
,
754 ®buf
[REGISTER_BYTE (FP0_REGNUM
)], &val
);
755 store_floating (valbuf
, TYPE_LENGTH (type
), val
);
760 int low_size
= REGISTER_RAW_SIZE (LOW_RETURN_REGNUM
);
761 int high_size
= REGISTER_RAW_SIZE (HIGH_RETURN_REGNUM
);
764 memcpy (valbuf
, ®buf
[REGISTER_BYTE (LOW_RETURN_REGNUM
)], len
);
765 else if (len
<= (low_size
+ high_size
))
768 ®buf
[REGISTER_BYTE (LOW_RETURN_REGNUM
)], low_size
);
769 memcpy (valbuf
+ low_size
,
770 ®buf
[REGISTER_BYTE (HIGH_RETURN_REGNUM
)], len
- low_size
);
773 internal_error ("Cannot extract return value of %d bytes long.", len
);
777 /* Convert data from raw format for register REGNUM in buffer FROM to
778 virtual format with type TYPE in buffer TO. In principle both
779 formats are identical except that the virtual format has two extra
780 bytes appended that aren't used. We set these to zero. */
783 i386_register_convert_to_virtual (int regnum
, struct type
*type
,
784 char *from
, char *to
)
786 /* Copy straight over, but take care of the padding. */
787 memcpy (to
, from
, FPU_REG_RAW_SIZE
);
788 memset (to
+ FPU_REG_RAW_SIZE
, 0, TYPE_LENGTH (type
) - FPU_REG_RAW_SIZE
);
791 /* Convert data from virtual format with type TYPE in buffer FROM to
792 raw format for register REGNUM in buffer TO. Simply omit the two
796 i386_register_convert_to_raw (struct type
*type
, int regnum
,
797 char *from
, char *to
)
799 memcpy (to
, from
, FPU_REG_RAW_SIZE
);
803 #ifdef I386V4_SIGTRAMP_SAVED_PC
804 /* Get saved user PC for sigtramp from the pushed ucontext on the stack
805 for all three variants of SVR4 sigtramps. */
808 i386v4_sigtramp_saved_pc (struct frame_info
*frame
)
810 CORE_ADDR saved_pc_offset
= 4;
813 find_pc_partial_function (frame
->pc
, &name
, NULL
, NULL
);
816 if (STREQ (name
, "_sigreturn"))
817 saved_pc_offset
= 132 + 14 * 4;
818 else if (STREQ (name
, "_sigacthandler"))
819 saved_pc_offset
= 80 + 14 * 4;
820 else if (STREQ (name
, "sigvechandler"))
821 saved_pc_offset
= 120 + 14 * 4;
825 return read_memory_integer (frame
->next
->frame
+ saved_pc_offset
, 4);
826 return read_memory_integer (read_register (SP_REGNUM
) + saved_pc_offset
, 4);
828 #endif /* I386V4_SIGTRAMP_SAVED_PC */
831 #ifdef STATIC_TRANSFORM_NAME
832 /* SunPRO encodes the static variables. This is not related to C++ mangling,
833 it is done for C too. */
836 sunpro_static_transform_name (char *name
)
839 if (IS_STATIC_TRANSFORM_NAME (name
))
841 /* For file-local statics there will be a period, a bunch
842 of junk (the contents of which match a string given in the
843 N_OPT), a period and the name. For function-local statics
844 there will be a bunch of junk (which seems to change the
845 second character from 'A' to 'B'), a period, the name of the
846 function, and the name. So just skip everything before the
848 p
= strrchr (name
, '.');
854 #endif /* STATIC_TRANSFORM_NAME */
858 /* Stuff for WIN32 PE style DLL's but is pretty generic really. */
861 skip_trampoline_code (CORE_ADDR pc
, char *name
)
863 if (pc
&& read_memory_unsigned_integer (pc
, 2) == 0x25ff) /* jmp *(dest) */
865 unsigned long indirect
= read_memory_unsigned_integer (pc
+ 2, 4);
866 struct minimal_symbol
*indsym
=
867 indirect
? lookup_minimal_symbol_by_pc (indirect
) : 0;
868 char *symname
= indsym
? SYMBOL_NAME (indsym
) : 0;
872 if (strncmp (symname
, "__imp_", 6) == 0
873 || strncmp (symname
, "_imp_", 5) == 0)
874 return name
? 1 : read_memory_unsigned_integer (indirect
, 4);
877 return 0; /* not a trampoline */
881 gdb_print_insn_i386 (bfd_vma memaddr
, disassemble_info
*info
)
883 if (disassembly_flavor
== att_flavor
)
884 return print_insn_i386_att (memaddr
, info
);
885 else if (disassembly_flavor
== intel_flavor
)
886 return print_insn_i386_intel (memaddr
, info
);
887 /* Never reached - disassembly_flavour is always either att_flavor
892 /* If the disassembly mode is intel, we have to also switch the
893 bfd mach_type. This function is run in the set disassembly_flavor
894 command, and does that. */
897 set_disassembly_flavor_sfunc (char *args
, int from_tty
,
898 struct cmd_list_element
*c
)
900 set_disassembly_flavor ();
904 set_disassembly_flavor (void)
906 if (disassembly_flavor
== att_flavor
)
907 set_architecture_from_arch_mach (bfd_arch_i386
, bfd_mach_i386_i386
);
908 else if (disassembly_flavor
== intel_flavor
)
909 set_architecture_from_arch_mach (bfd_arch_i386
, bfd_mach_i386_i386_intel_syntax
);
914 _initialize_i386_tdep (void)
916 /* Initialize the table saying where each register starts in the
922 for (i
= 0; i
< MAX_NUM_REGS
; i
++)
924 i386_register_byte
[i
] = offset
;
925 offset
+= i386_register_raw_size
[i
];
929 /* Initialize the table of virtual register sizes. */
933 for (i
= 0; i
< MAX_NUM_REGS
; i
++)
934 i386_register_virtual_size
[i
] = TYPE_LENGTH (REGISTER_VIRTUAL_TYPE (i
));
937 tm_print_insn
= gdb_print_insn_i386
;
938 tm_print_insn_info
.mach
= bfd_lookup_arch (bfd_arch_i386
, 0)->mach
;
940 /* Add the variable that controls the disassembly flavor */
942 struct cmd_list_element
*new_cmd
;
944 new_cmd
= add_set_enum_cmd ("disassembly-flavor", no_class
,
947 "Set the disassembly flavor, the valid values are \"att\" and \"intel\", \
948 and the default value is \"att\".",
950 new_cmd
->function
.sfunc
= set_disassembly_flavor_sfunc
;
951 add_show_from_set (new_cmd
, &showlist
);
954 /* Finally, initialize the disassembly flavor to the default given
955 in the disassembly_flavor variable */
957 set_disassembly_flavor ();