]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/i386-tdep.c
Initial creation of sourceware repository
[thirdparty/binutils-gdb.git] / gdb / i386-tdep.c
1 /* Intel 386 target-dependent stuff.
2 Copyright (C) 1988, 1989, 1991, 1994, 1995, 1996, 1998
3 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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, Boston, MA 02111-1307, USA. */
20
21 #include "defs.h"
22 #include "gdb_string.h"
23 #include "frame.h"
24 #include "inferior.h"
25 #include "gdbcore.h"
26 #include "target.h"
27 #include "floatformat.h"
28 #include "symtab.h"
29 #include "gdbcmd.h"
30 #include "command.h"
31
32 static long i386_get_frame_setup PARAMS ((CORE_ADDR));
33
34 static void i386_follow_jump PARAMS ((void));
35
36 static void codestream_read PARAMS ((unsigned char *, int));
37
38 static void codestream_seek PARAMS ((CORE_ADDR));
39
40 static unsigned char codestream_fill PARAMS ((int));
41
42 CORE_ADDR skip_trampoline_code PARAMS ((CORE_ADDR, char *));
43
44 static int gdb_print_insn_i386 (bfd_vma, disassemble_info *);
45
46 void _initialize_i386_tdep PARAMS ((void));
47
48 /* This is the variable the is set with "set disassembly-flavor",
49 and its legitimate values. */
50 static char att_flavor[] = "att";
51 static char intel_flavor[] = "intel";
52 static char *valid_flavors[] = {
53 att_flavor,
54 intel_flavor,
55 NULL
56 };
57 static char *disassembly_flavor = att_flavor;
58
59 /* Stdio style buffering was used to minimize calls to ptrace, but this
60 buffering did not take into account that the code section being accessed
61 may not be an even number of buffers long (even if the buffer is only
62 sizeof(int) long). In cases where the code section size happened to
63 be a non-integral number of buffers long, attempting to read the last
64 buffer would fail. Simply using target_read_memory and ignoring errors,
65 rather than read_memory, is not the correct solution, since legitimate
66 access errors would then be totally ignored. To properly handle this
67 situation and continue to use buffering would require that this code
68 be able to determine the minimum code section size granularity (not the
69 alignment of the section itself, since the actual failing case that
70 pointed out this problem had a section alignment of 4 but was not a
71 multiple of 4 bytes long), on a target by target basis, and then
72 adjust it's buffer size accordingly. This is messy, but potentially
73 feasible. It probably needs the bfd library's help and support. For
74 now, the buffer size is set to 1. (FIXME -fnf) */
75
76 #define CODESTREAM_BUFSIZ 1 /* Was sizeof(int), see note above. */
77 static CORE_ADDR codestream_next_addr;
78 static CORE_ADDR codestream_addr;
79 static unsigned char codestream_buf[CODESTREAM_BUFSIZ];
80 static int codestream_off;
81 static int codestream_cnt;
82
83 #define codestream_tell() (codestream_addr + codestream_off)
84 #define codestream_peek() (codestream_cnt == 0 ? \
85 codestream_fill(1): codestream_buf[codestream_off])
86 #define codestream_get() (codestream_cnt-- == 0 ? \
87 codestream_fill(0) : codestream_buf[codestream_off++])
88
89 static unsigned char
90 codestream_fill (peek_flag)
91 int peek_flag;
92 {
93 codestream_addr = codestream_next_addr;
94 codestream_next_addr += CODESTREAM_BUFSIZ;
95 codestream_off = 0;
96 codestream_cnt = CODESTREAM_BUFSIZ;
97 read_memory (codestream_addr, (char *) codestream_buf, CODESTREAM_BUFSIZ);
98
99 if (peek_flag)
100 return (codestream_peek());
101 else
102 return (codestream_get());
103 }
104
105 static void
106 codestream_seek (place)
107 CORE_ADDR place;
108 {
109 codestream_next_addr = place / CODESTREAM_BUFSIZ;
110 codestream_next_addr *= CODESTREAM_BUFSIZ;
111 codestream_cnt = 0;
112 codestream_fill (1);
113 while (codestream_tell() != place)
114 codestream_get ();
115 }
116
117 static void
118 codestream_read (buf, count)
119 unsigned char *buf;
120 int count;
121 {
122 unsigned char *p;
123 int i;
124 p = buf;
125 for (i = 0; i < count; i++)
126 *p++ = codestream_get ();
127 }
128
129 /* next instruction is a jump, move to target */
130
131 static void
132 i386_follow_jump ()
133 {
134 unsigned char buf[4];
135 long delta;
136
137 int data16;
138 CORE_ADDR pos;
139
140 pos = codestream_tell ();
141
142 data16 = 0;
143 if (codestream_peek () == 0x66)
144 {
145 codestream_get ();
146 data16 = 1;
147 }
148
149 switch (codestream_get ())
150 {
151 case 0xe9:
152 /* relative jump: if data16 == 0, disp32, else disp16 */
153 if (data16)
154 {
155 codestream_read (buf, 2);
156 delta = extract_signed_integer (buf, 2);
157
158 /* include size of jmp inst (including the 0x66 prefix). */
159 pos += delta + 4;
160 }
161 else
162 {
163 codestream_read (buf, 4);
164 delta = extract_signed_integer (buf, 4);
165
166 pos += delta + 5;
167 }
168 break;
169 case 0xeb:
170 /* relative jump, disp8 (ignore data16) */
171 codestream_read (buf, 1);
172 /* Sign-extend it. */
173 delta = extract_signed_integer (buf, 1);
174
175 pos += delta + 2;
176 break;
177 }
178 codestream_seek (pos);
179 }
180
181 /*
182 * find & return amound a local space allocated, and advance codestream to
183 * first register push (if any)
184 *
185 * if entry sequence doesn't make sense, return -1, and leave
186 * codestream pointer random
187 */
188
189 static long
190 i386_get_frame_setup (pc)
191 CORE_ADDR pc;
192 {
193 unsigned char op;
194
195 codestream_seek (pc);
196
197 i386_follow_jump ();
198
199 op = codestream_get ();
200
201 if (op == 0x58) /* popl %eax */
202 {
203 /*
204 * this function must start with
205 *
206 * popl %eax 0x58
207 * xchgl %eax, (%esp) 0x87 0x04 0x24
208 * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00
209 *
210 * (the system 5 compiler puts out the second xchg
211 * inst, and the assembler doesn't try to optimize it,
212 * so the 'sib' form gets generated)
213 *
214 * this sequence is used to get the address of the return
215 * buffer for a function that returns a structure
216 */
217 int pos;
218 unsigned char buf[4];
219 static unsigned char proto1[3] = { 0x87,0x04,0x24 };
220 static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 };
221 pos = codestream_tell ();
222 codestream_read (buf, 4);
223 if (memcmp (buf, proto1, 3) == 0)
224 pos += 3;
225 else if (memcmp (buf, proto2, 4) == 0)
226 pos += 4;
227
228 codestream_seek (pos);
229 op = codestream_get (); /* update next opcode */
230 }
231
232 if (op == 0x68 || op == 0x6a)
233 {
234 /*
235 * this function may start with
236 *
237 * pushl constant
238 * call _probe
239 * addl $4, %esp
240 * followed by
241 * pushl %ebp
242 * etc.
243 */
244 int pos;
245 unsigned char buf[8];
246
247 /* Skip past the pushl instruction; it has either a one-byte
248 or a four-byte operand, depending on the opcode. */
249 pos = codestream_tell ();
250 if (op == 0x68)
251 pos += 4;
252 else
253 pos += 1;
254 codestream_seek (pos);
255
256 /* Read the following 8 bytes, which should be "call _probe" (6 bytes)
257 followed by "addl $4,%esp" (2 bytes). */
258 codestream_read (buf, sizeof (buf));
259 if (buf[0] == 0xe8 && buf[6] == 0xc4 && buf[7] == 0x4)
260 pos += sizeof (buf);
261 codestream_seek (pos);
262 op = codestream_get (); /* update next opcode */
263 }
264
265 if (op == 0x55) /* pushl %ebp */
266 {
267 /* check for movl %esp, %ebp - can be written two ways */
268 switch (codestream_get ())
269 {
270 case 0x8b:
271 if (codestream_get () != 0xec)
272 return (-1);
273 break;
274 case 0x89:
275 if (codestream_get () != 0xe5)
276 return (-1);
277 break;
278 default:
279 return (-1);
280 }
281 /* check for stack adjustment
282 *
283 * subl $XXX, %esp
284 *
285 * note: you can't subtract a 16 bit immediate
286 * from a 32 bit reg, so we don't have to worry
287 * about a data16 prefix
288 */
289 op = codestream_peek ();
290 if (op == 0x83)
291 {
292 /* subl with 8 bit immed */
293 codestream_get ();
294 if (codestream_get () != 0xec)
295 /* Some instruction starting with 0x83 other than subl. */
296 {
297 codestream_seek (codestream_tell () - 2);
298 return 0;
299 }
300 /* subl with signed byte immediate
301 * (though it wouldn't make sense to be negative)
302 */
303 return (codestream_get());
304 }
305 else if (op == 0x81)
306 {
307 char buf[4];
308 /* Maybe it is subl with 32 bit immedediate. */
309 codestream_get();
310 if (codestream_get () != 0xec)
311 /* Some instruction starting with 0x81 other than subl. */
312 {
313 codestream_seek (codestream_tell () - 2);
314 return 0;
315 }
316 /* It is subl with 32 bit immediate. */
317 codestream_read ((unsigned char *)buf, 4);
318 return extract_signed_integer (buf, 4);
319 }
320 else
321 {
322 return (0);
323 }
324 }
325 else if (op == 0xc8)
326 {
327 char buf[2];
328 /* enter instruction: arg is 16 bit unsigned immed */
329 codestream_read ((unsigned char *)buf, 2);
330 codestream_get (); /* flush final byte of enter instruction */
331 return extract_unsigned_integer (buf, 2);
332 }
333 return (-1);
334 }
335
336 /* Return number of args passed to a frame.
337 Can return -1, meaning no way to tell. */
338
339 int
340 i386_frame_num_args (fi)
341 struct frame_info *fi;
342 {
343 #if 1
344 return -1;
345 #else
346 /* This loses because not only might the compiler not be popping the
347 args right after the function call, it might be popping args from both
348 this call and a previous one, and we would say there are more args
349 than there really are. */
350
351 int retpc;
352 unsigned char op;
353 struct frame_info *pfi;
354
355 /* on the 386, the instruction following the call could be:
356 popl %ecx - one arg
357 addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits
358 anything else - zero args */
359
360 int frameless;
361
362 FRAMELESS_FUNCTION_INVOCATION (fi, frameless);
363 if (frameless)
364 /* In the absence of a frame pointer, GDB doesn't get correct values
365 for nameless arguments. Return -1, so it doesn't print any
366 nameless arguments. */
367 return -1;
368
369 pfi = get_prev_frame_info (fi);
370 if (pfi == 0)
371 {
372 /* Note: this can happen if we are looking at the frame for
373 main, because FRAME_CHAIN_VALID won't let us go into
374 start. If we have debugging symbols, that's not really
375 a big deal; it just means it will only show as many arguments
376 to main as are declared. */
377 return -1;
378 }
379 else
380 {
381 retpc = pfi->pc;
382 op = read_memory_integer (retpc, 1);
383 if (op == 0x59)
384 /* pop %ecx */
385 return 1;
386 else if (op == 0x83)
387 {
388 op = read_memory_integer (retpc+1, 1);
389 if (op == 0xc4)
390 /* addl $<signed imm 8 bits>, %esp */
391 return (read_memory_integer (retpc+2,1)&0xff)/4;
392 else
393 return 0;
394 }
395 else if (op == 0x81)
396 { /* add with 32 bit immediate */
397 op = read_memory_integer (retpc+1, 1);
398 if (op == 0xc4)
399 /* addl $<imm 32>, %esp */
400 return read_memory_integer (retpc+2, 4) / 4;
401 else
402 return 0;
403 }
404 else
405 {
406 return 0;
407 }
408 }
409 #endif
410 }
411
412 /*
413 * parse the first few instructions of the function to see
414 * what registers were stored.
415 *
416 * We handle these cases:
417 *
418 * The startup sequence can be at the start of the function,
419 * or the function can start with a branch to startup code at the end.
420 *
421 * %ebp can be set up with either the 'enter' instruction, or
422 * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful,
423 * but was once used in the sys5 compiler)
424 *
425 * Local space is allocated just below the saved %ebp by either the
426 * 'enter' instruction, or by 'subl $<size>, %esp'. 'enter' has
427 * a 16 bit unsigned argument for space to allocate, and the
428 * 'addl' instruction could have either a signed byte, or
429 * 32 bit immediate.
430 *
431 * Next, the registers used by this function are pushed. In
432 * the sys5 compiler they will always be in the order: %edi, %esi, %ebx
433 * (and sometimes a harmless bug causes it to also save but not restore %eax);
434 * however, the code below is willing to see the pushes in any order,
435 * and will handle up to 8 of them.
436 *
437 * If the setup sequence is at the end of the function, then the
438 * next instruction will be a branch back to the start.
439 */
440
441 void
442 i386_frame_find_saved_regs (fip, fsrp)
443 struct frame_info *fip;
444 struct frame_saved_regs *fsrp;
445 {
446 long locals = -1;
447 unsigned char op;
448 CORE_ADDR dummy_bottom;
449 CORE_ADDR adr;
450 CORE_ADDR pc;
451 int i;
452
453 memset (fsrp, 0, sizeof *fsrp);
454
455 /* if frame is the end of a dummy, compute where the
456 * beginning would be
457 */
458 dummy_bottom = fip->frame - 4 - REGISTER_BYTES - CALL_DUMMY_LENGTH;
459
460 /* check if the PC is in the stack, in a dummy frame */
461 if (dummy_bottom <= fip->pc && fip->pc <= fip->frame)
462 {
463 /* all regs were saved by push_call_dummy () */
464 adr = fip->frame;
465 for (i = 0; i < NUM_REGS; i++)
466 {
467 adr -= REGISTER_RAW_SIZE (i);
468 fsrp->regs[i] = adr;
469 }
470 return;
471 }
472
473 pc = get_pc_function_start (fip->pc);
474 if (pc != 0)
475 locals = i386_get_frame_setup (pc);
476
477 if (locals >= 0)
478 {
479 adr = fip->frame - 4 - locals;
480 for (i = 0; i < 8; i++)
481 {
482 op = codestream_get ();
483 if (op < 0x50 || op > 0x57)
484 break;
485 #ifdef I386_REGNO_TO_SYMMETRY
486 /* Dynix uses different internal numbering. Ick. */
487 fsrp->regs[I386_REGNO_TO_SYMMETRY(op - 0x50)] = adr;
488 #else
489 fsrp->regs[op - 0x50] = adr;
490 #endif
491 adr -= 4;
492 }
493 }
494
495 fsrp->regs[PC_REGNUM] = fip->frame + 4;
496 fsrp->regs[FP_REGNUM] = fip->frame;
497 }
498
499 /* return pc of first real instruction */
500
501 int
502 i386_skip_prologue (pc)
503 int pc;
504 {
505 unsigned char op;
506 int i;
507 static unsigned char pic_pat[6] = { 0xe8, 0, 0, 0, 0, /* call 0x0 */
508 0x5b, /* popl %ebx */
509 };
510 CORE_ADDR pos;
511
512 if (i386_get_frame_setup (pc) < 0)
513 return (pc);
514
515 /* found valid frame setup - codestream now points to
516 * start of push instructions for saving registers
517 */
518
519 /* skip over register saves */
520 for (i = 0; i < 8; i++)
521 {
522 op = codestream_peek ();
523 /* break if not pushl inst */
524 if (op < 0x50 || op > 0x57)
525 break;
526 codestream_get ();
527 }
528
529 /* The native cc on SVR4 in -K PIC mode inserts the following code to get
530 the address of the global offset table (GOT) into register %ebx.
531 call 0x0
532 popl %ebx
533 movl %ebx,x(%ebp) (optional)
534 addl y,%ebx
535 This code is with the rest of the prologue (at the end of the
536 function), so we have to skip it to get to the first real
537 instruction at the start of the function. */
538
539 pos = codestream_tell ();
540 for (i = 0; i < 6; i++)
541 {
542 op = codestream_get ();
543 if (pic_pat [i] != op)
544 break;
545 }
546 if (i == 6)
547 {
548 unsigned char buf[4];
549 long delta = 6;
550
551 op = codestream_get ();
552 if (op == 0x89) /* movl %ebx, x(%ebp) */
553 {
554 op = codestream_get ();
555 if (op == 0x5d) /* one byte offset from %ebp */
556 {
557 delta += 3;
558 codestream_read (buf, 1);
559 }
560 else if (op == 0x9d) /* four byte offset from %ebp */
561 {
562 delta += 6;
563 codestream_read (buf, 4);
564 }
565 else /* unexpected instruction */
566 delta = -1;
567 op = codestream_get ();
568 }
569 /* addl y,%ebx */
570 if (delta > 0 && op == 0x81 && codestream_get () == 0xc3)
571 {
572 pos += delta + 6;
573 }
574 }
575 codestream_seek (pos);
576
577 i386_follow_jump ();
578
579 return (codestream_tell ());
580 }
581
582 void
583 i386_push_dummy_frame ()
584 {
585 CORE_ADDR sp = read_register (SP_REGNUM);
586 int regnum;
587 char regbuf[MAX_REGISTER_RAW_SIZE];
588
589 sp = push_word (sp, read_register (PC_REGNUM));
590 sp = push_word (sp, read_register (FP_REGNUM));
591 write_register (FP_REGNUM, sp);
592 for (regnum = 0; regnum < NUM_REGS; regnum++)
593 {
594 read_register_gen (regnum, regbuf);
595 sp = push_bytes (sp, regbuf, REGISTER_RAW_SIZE (regnum));
596 }
597 write_register (SP_REGNUM, sp);
598 }
599
600 void
601 i386_pop_frame ()
602 {
603 struct frame_info *frame = get_current_frame ();
604 CORE_ADDR fp;
605 int regnum;
606 struct frame_saved_regs fsr;
607 char regbuf[MAX_REGISTER_RAW_SIZE];
608
609 fp = FRAME_FP (frame);
610 get_frame_saved_regs (frame, &fsr);
611 for (regnum = 0; regnum < NUM_REGS; regnum++)
612 {
613 CORE_ADDR adr;
614 adr = fsr.regs[regnum];
615 if (adr)
616 {
617 read_memory (adr, regbuf, REGISTER_RAW_SIZE (regnum));
618 write_register_bytes (REGISTER_BYTE (regnum), regbuf,
619 REGISTER_RAW_SIZE (regnum));
620 }
621 }
622 write_register (FP_REGNUM, read_memory_integer (fp, 4));
623 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4));
624 write_register (SP_REGNUM, fp + 8);
625 flush_cached_frames ();
626 }
627
628 #ifdef GET_LONGJMP_TARGET
629
630 /* Figure out where the longjmp will land. Slurp the args out of the stack.
631 We expect the first arg to be a pointer to the jmp_buf structure from which
632 we extract the pc (JB_PC) that we will land at. The pc is copied into PC.
633 This routine returns true on success. */
634
635 int
636 get_longjmp_target(pc)
637 CORE_ADDR *pc;
638 {
639 char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT];
640 CORE_ADDR sp, jb_addr;
641
642 sp = read_register (SP_REGNUM);
643
644 if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */
645 buf,
646 TARGET_PTR_BIT / TARGET_CHAR_BIT))
647 return 0;
648
649 jb_addr = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
650
651 if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, buf,
652 TARGET_PTR_BIT / TARGET_CHAR_BIT))
653 return 0;
654
655 *pc = extract_address (buf, TARGET_PTR_BIT / TARGET_CHAR_BIT);
656
657 return 1;
658 }
659
660 #endif /* GET_LONGJMP_TARGET */
661
662 void
663 i386_extract_return_value(type, regbuf, valbuf)
664 struct type *type;
665 char regbuf[REGISTER_BYTES];
666 char *valbuf;
667 {
668 /* On AIX, floating point values are returned in floating point registers. */
669 #ifdef I386_AIX_TARGET
670 if (TYPE_CODE_FLT == TYPE_CODE(type))
671 {
672 double d;
673 /* 387 %st(0), gcc uses this */
674 floatformat_to_double (&floatformat_i387_ext,
675 &regbuf[REGISTER_BYTE(FP0_REGNUM)],
676 &d);
677 store_floating (valbuf, TYPE_LENGTH (type), d);
678 }
679 else
680 #endif /* I386_AIX_TARGET */
681 {
682 memcpy (valbuf, regbuf, TYPE_LENGTH (type));
683 }
684 }
685
686 #ifdef I386V4_SIGTRAMP_SAVED_PC
687 /* Get saved user PC for sigtramp from the pushed ucontext on the stack
688 for all three variants of SVR4 sigtramps. */
689
690 CORE_ADDR
691 i386v4_sigtramp_saved_pc (frame)
692 struct frame_info *frame;
693 {
694 CORE_ADDR saved_pc_offset = 4;
695 char *name = NULL;
696
697 find_pc_partial_function (frame->pc, &name, NULL, NULL);
698 if (name)
699 {
700 if (STREQ (name, "_sigreturn"))
701 saved_pc_offset = 132 + 14 * 4;
702 else if (STREQ (name, "_sigacthandler"))
703 saved_pc_offset = 80 + 14 * 4;
704 else if (STREQ (name, "sigvechandler"))
705 saved_pc_offset = 120 + 14 * 4;
706 }
707
708 if (frame->next)
709 return read_memory_integer (frame->next->frame + saved_pc_offset, 4);
710 return read_memory_integer (read_register (SP_REGNUM) + saved_pc_offset, 4);
711 }
712 #endif /* I386V4_SIGTRAMP_SAVED_PC */
713
714 #ifdef STATIC_TRANSFORM_NAME
715 /* SunPRO encodes the static variables. This is not related to C++ mangling,
716 it is done for C too. */
717
718 char *
719 sunpro_static_transform_name (name)
720 char *name;
721 {
722 char *p;
723 if (IS_STATIC_TRANSFORM_NAME (name))
724 {
725 /* For file-local statics there will be a period, a bunch
726 of junk (the contents of which match a string given in the
727 N_OPT), a period and the name. For function-local statics
728 there will be a bunch of junk (which seems to change the
729 second character from 'A' to 'B'), a period, the name of the
730 function, and the name. So just skip everything before the
731 last period. */
732 p = strrchr (name, '.');
733 if (p != NULL)
734 name = p + 1;
735 }
736 return name;
737 }
738 #endif /* STATIC_TRANSFORM_NAME */
739
740
741
742 /* Stuff for WIN32 PE style DLL's but is pretty generic really. */
743
744 CORE_ADDR
745 skip_trampoline_code (pc, name)
746 CORE_ADDR pc;
747 char *name;
748 {
749 if (pc && read_memory_unsigned_integer (pc, 2) == 0x25ff) /* jmp *(dest) */
750 {
751 unsigned long indirect = read_memory_unsigned_integer (pc+2, 4);
752 struct minimal_symbol *indsym =
753 indirect ? lookup_minimal_symbol_by_pc (indirect) : 0;
754 char *symname = indsym ? SYMBOL_NAME(indsym) : 0;
755
756 if (symname)
757 {
758 if (strncmp (symname,"__imp_", 6) == 0
759 || strncmp (symname,"_imp_", 5) == 0)
760 return name ? 1 : read_memory_unsigned_integer (indirect, 4);
761 }
762 }
763 return 0; /* not a trampoline */
764 }
765
766 static int
767 gdb_print_insn_i386 (memaddr, info)
768 bfd_vma memaddr;
769 disassemble_info * info;
770 {
771 if (disassembly_flavor == att_flavor)
772 return print_insn_i386_att (memaddr, info);
773 else if (disassembly_flavor == intel_flavor)
774 return print_insn_i386_intel (memaddr, info);
775 }
776
777 void
778 _initialize_i386_tdep ()
779 {
780 tm_print_insn = gdb_print_insn_i386;
781 tm_print_insn_info.mach = bfd_lookup_arch (bfd_arch_i386, 0)->mach;
782
783 /* Add the variable that controls the disassembly flavor */
784 add_show_from_set(
785 add_set_enum_cmd ("disassembly-flavor", no_class,
786 valid_flavors,
787 (char *) &disassembly_flavor,
788 "Set the disassembly flavor, the valid values are \"att\" and \"intel\", \
789 and the default value is \"att\".",
790 &setlist),
791 &showlist);
792
793
794 }