From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25836 invoked by alias); 15 Sep 2002 14:02:11 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 25827 invoked from network); 15 Sep 2002 14:02:09 -0000 Received: from unknown (HELO walton.kettenis.dyndns.org) (62.163.169.250) by sources.redhat.com with SMTP; 15 Sep 2002 14:02:09 -0000 Received: from elgar.kettenis.dyndns.org (elgar.kettenis.dyndns.org [192.168.0.2]) by walton.kettenis.dyndns.org (8.12.5/8.12.5) with ESMTP id g8FE23up001538 for ; Sun, 15 Sep 2002 16:02:03 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: from elgar.kettenis.dyndns.org (localhost [127.0.0.1]) by elgar.kettenis.dyndns.org (8.12.5/8.12.5) with ESMTP id g8FE23pE007405 for ; Sun, 15 Sep 2002 16:02:03 +0200 (CEST) (envelope-from kettenis@elgar.kettenis.dyndns.org) Received: (from kettenis@localhost) by elgar.kettenis.dyndns.org (8.12.5/8.12.5/Submit) id g8FE22B7007402; Sun, 15 Sep 2002 16:02:02 +0200 (CEST) Date: Sun, 15 Sep 2002 07:02:00 -0000 Message-Id: <200209151402.g8FE22B7007402@elgar.kettenis.dyndns.org> From: Mark Kettenis To: gdb-patches@sources.redhat.com Subject: [PATCH] Multi-arch i386 instruction printing X-SW-Source: 2002-09/txt/msg00301.txt.bz2 This patch multi-arch's i386 instruction printing. In doing so I took a somewhat different approach than what's done for other targets, by always overriding the disassemble_info fields that the i386 instruction printer cares about. Seems to work fine, and should also be able to handle x86_64. Checked in. Index: ChangeLog from Mark Kettenis * i386-tdep.c (gdb_print_insn_i386): Removed. (i386_print_insn): New function. (i386_gdbarch_init): Set print_insn to i386_print_insns. (_initialize_i386_tdep): Don't initialize tm_print_insn and tm_print_insn_info. Index: i386-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/i386-tdep.c,v retrieving revision 1.86 diff -u -p -r1.86 i386-tdep.c --- i386-tdep.c 6 Sep 2002 21:28:18 -0000 1.86 +++ i386-tdep.c 15 Sep 2002 13:47:53 -0000 @@ -1288,15 +1288,17 @@ i386_pc_in_sigtramp (CORE_ADDR pc, char deals with switching between those. */ static int -gdb_print_insn_i386 (bfd_vma memaddr, disassemble_info *info) +i386_print_insn (bfd_vma pc, disassemble_info *info) { - if (disassembly_flavor == att_flavor) - return print_insn_i386_att (memaddr, info); - else if (disassembly_flavor == intel_flavor) - return print_insn_i386_intel (memaddr, info); - /* Never reached -- disassembly_flavour is always either att_flavor - or intel_flavor. */ - internal_error (__FILE__, __LINE__, "failed internal consistency check"); + gdb_assert (disassembly_flavor == att_flavor + || disassembly_flavor == intel_flavor); + + /* FIXME: kettenis/20020915: Until disassembler_options is properly + constified, cast to prevent a compiler warning. */ + info->disassembler_options = (char *) disassembly_flavor; + info->mach = gdbarch_bfd_arch_info (current_gdbarch)->mach; + + return print_insn_i386 (pc, info); } @@ -1569,6 +1571,8 @@ i386_gdbarch_init (struct gdbarch_info i set_gdbarch_pseudo_register_read (gdbarch, i386_pseudo_register_read); set_gdbarch_pseudo_register_write (gdbarch, i386_pseudo_register_write); + set_gdbarch_print_insn (gdbarch, i386_print_insn); + /* Hook in ABI-specific overrides, if they have been registered. */ gdbarch_init_osabi (info, gdbarch, osabi); @@ -1600,9 +1604,6 @@ _initialize_i386_tdep (void) { register_gdbarch_init (bfd_arch_i386, i386_gdbarch_init); - tm_print_insn = gdb_print_insn_i386; - tm_print_insn_info.mach = bfd_lookup_arch (bfd_arch_i386, 0)->mach; - /* Add the variable that controls the disassembly flavor. */ { struct cmd_list_element *new_cmd; @@ -1623,7 +1624,7 @@ and the default value is \"att\".", struct cmd_list_element *new_cmd; new_cmd = add_set_enum_cmd ("struct-convention", no_class, - valid_conventions, + valid_conventions, &struct_convention, "\ Set the convention for returning small structs, valid values \ are \"default\", \"pcc\" and \"reg\", and the default value is \"default\".",