From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25888 invoked by alias); 24 Jun 2004 20:37:45 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 25877 invoked from network); 24 Jun 2004 20:37:44 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 24 Jun 2004 20:37:44 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i5OKbie1000958 for ; Thu, 24 Jun 2004 16:37:44 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i5OKbi026783 for ; Thu, 24 Jun 2004 16:37:44 -0400 Received: from redhat.com (IDENT:PtrdCeA1aIYfbvDWa/vXboc6HBCH5W3V@topaz.toronto.redhat.com [172.16.14.227]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id i5OKbhtn017457 for ; Thu, 24 Jun 2004 16:37:43 -0400 Message-ID: <40DB3B97.9040606@redhat.com> Date: Thu, 24 Jun 2004 20:37:00 -0000 From: Dave Brolley Organization: Red Hat Canada, Ltd User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch][rfa] Support multiple bfd machines in cgen-cpu disassembly Content-Type: multipart/mixed; boundary="------------060505030309030800020500" X-SW-Source: 2004-q2/txt/msg00049.txt.bz2 This is a multi-part message in MIME format. --------------060505030309030800020500 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 934 Hi, Currently the 'mach' file of the disassemble_info struct initialized by cgen_disassemble is left with the default value of 0, which indicates to use the default bfd machine. This patch allows the specification of a bfd machine number, so that targets with multiple cgen MACHs can filter the insn set correctly when disassembling. The machine number is an optional argument to cgen_bi_endian_cpu::disassemble with a default value of zero, to preserve the current behaviour in ports which don't use this feature. The machine number is then passed to cgen_disassemble which stores it in the disassemble_info for use by the disassembler. The machine number is also stored in the bfd_arch_hack struct by register_name and is compared against the requested machine number in bfd_lookup_arch. This has been tested against an internal port which uses this feature and against xstormy16 which does not. ok to commit? Dave --------------060505030309030800020500 Content-Type: text/plain; name="tracedis-mach.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tracedis-mach.patch.txt" Content-length: 8695 Index: sid/component/cgen-cpu/cgen-cpu.h =================================================================== RCS file: /cvs/src/src/sid/component/cgen-cpu/cgen-cpu.h,v retrieving revision 1.9 diff -c -p -r1.9 cgen-cpu.h *** sid/component/cgen-cpu/cgen-cpu.h 15 Jan 2003 20:04:57 -0000 1.9 --- sid/component/cgen-cpu/cgen-cpu.h 24 Jun 2004 20:13:52 -0000 *************** *** 1,6 **** // cgen-cpu.h -*- C++ -*- ! // Copyright (C) 2000, 2001, 2002, 2003 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,6 ---- // cgen-cpu.h -*- C++ -*- ! // Copyright (C) 2000, 2001, 2002, 2003, 2004 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** public: *** 68,74 **** // Disassembly tracing support void disassemble (PCADDR pc, disassembler_ftype printfn, enum bfd_flavour flavour, enum bfd_architecture arch, ! enum bfd_endian endian, const char *name, unsigned long isa_mask = 0); struct disassemble_info info; protected: static int cgen_read_memory (bfd_vma memaddr, bfd_byte *myaddr, --- 68,74 ---- // Disassembly tracing support void disassemble (PCADDR pc, disassembler_ftype printfn, enum bfd_flavour flavour, enum bfd_architecture arch, ! enum bfd_endian endian, const char *name, unsigned long isa_mask = 0, int machine = 0); struct disassemble_info info; protected: static int cgen_read_memory (bfd_vma memaddr, bfd_byte *myaddr, Index: sid/component/cgen-cpu/compCGEN.cxx =================================================================== RCS file: /cvs/src/src/sid/component/cgen-cpu/compCGEN.cxx,v retrieving revision 1.12 diff -c -p -r1.12 compCGEN.cxx *** sid/component/cgen-cpu/compCGEN.cxx 29 Aug 2003 19:26:22 -0000 1.12 --- sid/component/cgen-cpu/compCGEN.cxx 24 Jun 2004 20:13:52 -0000 *************** *** 1,6 **** // compCGEN.cxx - CPU components. -*- C++ -*- ! // Copyright (C) 1999, 2000, 2001, 2002, 2003 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,6 ---- // compCGEN.cxx - CPU components. -*- C++ -*- ! // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** cgen::cgen_bi_endian_cpu::disassemble (P *** 155,161 **** enum bfd_architecture arch, enum bfd_endian endian, const char *name, ! unsigned long isa_mask) { cgen_disassemble((bfd_vma)pc, &this->info, this, & cgen_bi_endian_cpu::cgen_read_memory, --- 155,162 ---- enum bfd_architecture arch, enum bfd_endian endian, const char *name, ! unsigned long isa_mask, ! int machine) { cgen_disassemble((bfd_vma)pc, &this->info, this, & cgen_bi_endian_cpu::cgen_read_memory, *************** cgen::cgen_bi_endian_cpu::disassemble (P *** 165,170 **** --- 166,172 ---- printfn, flavour, arch, + machine, endian, name, isa_mask); Index: sid/component/cgen-cpu/tracedis.cxx =================================================================== RCS file: /cvs/src/src/sid/component/cgen-cpu/tracedis.cxx,v retrieving revision 1.3 diff -c -p -r1.3 tracedis.cxx *** sid/component/cgen-cpu/tracedis.cxx 26 Mar 2004 20:23:40 -0000 1.3 --- sid/component/cgen-cpu/tracedis.cxx 24 Jun 2004 20:13:52 -0000 *************** *** 1,6 **** // tracedis.cxx - disassembly tracing support. -*- C++ -*- ! // Copyright (C) 2001, 2002 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. --- 1,6 ---- // tracedis.cxx - disassembly tracing support. -*- C++ -*- ! // Copyright (C) 2001-2004 Red Hat. // This file is part of SID and is licensed under the GPL. // See the file COPYING.SID for conditions for redistribution. *************** *** 12,18 **** #include "sidcomputil.h" #include "sidcpuutil.h" ! void register_name(enum bfd_architecture, const char *); // XXX: for compatibility with older libraries static --- 12,18 ---- #include "sidcomputil.h" #include "sidcpuutil.h" ! void register_name(enum bfd_architecture, const char *, int); // XXX: for compatibility with older libraries static *************** cgen_disassemble(bfd_vma pc, *** 41,56 **** disassembler_ftype fp, enum bfd_flavour flavour, enum bfd_architecture arch, enum bfd_endian endian, const char *name, unsigned long isa_mask) { ! register_name(arch, name); INIT_DISASSEMBLE_INFO(*info, this_ptr, trace_printf); info->application_data = this_ptr; info->flavour = flavour; info->insn_sets = isa_mask; /* may be 0 */ info->arch = arch; info->endian = endian; info->read_memory_func = read_mem_func; info->memory_error_func = memory_error_func; --- 41,58 ---- disassembler_ftype fp, enum bfd_flavour flavour, enum bfd_architecture arch, + int machine, enum bfd_endian endian, const char *name, unsigned long isa_mask) { ! register_name(arch, name, machine); INIT_DISASSEMBLE_INFO(*info, this_ptr, trace_printf); info->application_data = this_ptr; info->flavour = flavour; info->insn_sets = isa_mask; /* may be 0 */ info->arch = arch; + info->mach = machine; info->endian = endian; info->read_memory_func = read_mem_func; info->memory_error_func = memory_error_func; *************** bfd_get_bits (const void* addr, int bits *** 174,186 **** struct bfd_arch_hack { struct bfd_arch_hack *next; enum bfd_architecture arch; const char *name; }; struct bfd_arch_hack *hack_list; void ! register_name(enum bfd_architecture arch, const char *name) { struct bfd_arch_hack *p; --- 176,189 ---- struct bfd_arch_hack { struct bfd_arch_hack *next; enum bfd_architecture arch; + int machine; const char *name; }; struct bfd_arch_hack *hack_list; void ! register_name(enum bfd_architecture arch, const char *name, int machine) { struct bfd_arch_hack *p; *************** register_name(enum bfd_architecture arch *** 189,194 **** --- 192,198 ---- hack_list = (struct bfd_arch_hack *)xmalloc(sizeof *hack_list); hack_list->next = NULL; hack_list->arch = arch; + hack_list->machine = machine; hack_list->name = name; return; } *************** register_name(enum bfd_architecture arch *** 197,207 **** --- 201,213 ---- if (strcmp(p->name, name) == 0) { p->arch = arch; + p->machine = machine; return; } p = (struct bfd_arch_hack *)xmalloc(sizeof *hack_list); p->next = hack_list; p->arch = arch; + p->machine = machine; p->name = name; } *************** bfd_lookup_arch (enum bfd_architecture a *** 213,219 **** for (b = hack_list; b->name; b++) { ! if (b->arch == arch) { info.printable_name = b->name; return &info; --- 219,225 ---- for (b = hack_list; b->name; b++) { ! if (b->arch == arch && b->machine == machine) { info.printable_name = b->name; return &info; Index: sid/component/cgen-cpu/tracedis.h =================================================================== RCS file: /cvs/src/src/sid/component/cgen-cpu/tracedis.h,v retrieving revision 1.2 diff -c -p -r1.2 tracedis.h *** sid/component/cgen-cpu/tracedis.h 7 Feb 2002 17:32:28 -0000 1.2 --- sid/component/cgen-cpu/tracedis.h 24 Jun 2004 20:13:52 -0000 *************** typedef void (*MEMERR)(int status, bfd_v *** 9,12 **** typedef void (*PRINTADDR)(bfd_vma addr, struct disassemble_info *info); typedef int (*SYMATADDR)(bfd_vma addr, struct disassemble_info * info); ! void cgen_disassemble(bfd_vma, disassemble_info *, void *, READMEM, MEMERR, PRINTADDR, SYMATADDR, disassembler_ftype, enum bfd_flavour, enum bfd_architecture, enum bfd_endian, const char *, unsigned long isa_mask); --- 9,12 ---- typedef void (*PRINTADDR)(bfd_vma addr, struct disassemble_info *info); typedef int (*SYMATADDR)(bfd_vma addr, struct disassemble_info * info); ! void cgen_disassemble(bfd_vma, disassemble_info *, void *, READMEM, MEMERR, PRINTADDR, SYMATADDR, disassembler_ftype, enum bfd_flavour, enum bfd_architecture, int machine, enum bfd_endian, const char *, unsigned long isa_mask); --------------060505030309030800020500 Content-Type: text/plain; name="tracedis-mach.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tracedis-mach.ChangeLog" Content-length: 576 2004-06-21 Dave Brolley * tracedis.cxx (register_name): Add parameter for the cgen MACH. Save it in hack_list->machine or p->machine. (cgen_disassemble): Add parameter for the cgen MACH. Pass it to register_name. Use it to set info->mach. (arch_hack): New field 'machine'. (bfd_lookup_arch): Make sure the machines match. * cgen-cpu.h (disassemble): Add parameter for the cgen MACH. * compCGEN.cxx (disassemble): Add parameter for the cgen MACH. Pass it to cgen_disassemble. * tracedis.h (cgen_disassemble): Add parameter for the cgen MACH. --------------060505030309030800020500--