From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1760 invoked by alias); 27 Jul 2006 08:48:07 -0000 Received: (qmail 1750 invoked by uid 22791); 27 Jul 2006 08:48:07 -0000 X-Spam-Check-By: sourceware.org Received: from mailrelay1.uni-rostock.de (HELO antivirus.uni-rostock.de) (139.30.8.201) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 27 Jul 2006 08:48:04 +0000 Received: from antivirus.exch.rz.uni-rostock.de ([127.0.0.1]) by antivirus.uni-rostock.de with Microsoft SMTPSVC(6.0.3790.1830); Thu, 27 Jul 2006 10:48:02 +0200 Received: from antivirus.uni-rostock.de (unverified) by antivirus.exch.rz.uni-rostock.de (Content Technologies SMTPRS 4.3.20) with ESMTP id for ; Thu, 27 Jul 2006 10:48:02 +0200 Received: from mail pickup service by antivirus.uni-rostock.de with Microsoft SMTPSVC; Thu, 27 Jul 2006 10:48:02 +0200 X-SCL: 3 58.9% Received: from mail.uni-rostock.de ([139.30.8.11]) by antivirus.uni-rostock.de with Microsoft SMTPSVC(6.0.3790.1830); Thu, 27 Jul 2006 10:47:56 +0200 Received: from conversion-daemon.mail2.uni-rostock.de by mail2.uni-rostock.de (iPlanet Messaging Server 5.2 HotFix 2.09 (built Nov 18 2005)) id <0J3100C01ZYG1Y@mail.uni-rostock.de> (original mail from ronald.hecht@uni-rostock.de) for cgen@sourceware.org; Thu, 27 Jul 2006 10:47:56 +0200 (MEST) Received: from [139.30.201.25] (pike.e-technik.uni-rostock.de [139.30.201.25]) by mail2.uni-rostock.de (iPlanet Messaging Server 5.2 HotFix 2.09 (built Nov 18 2005)) with ESMTPS id <0J3200J970FUSV@mail.uni-rostock.de> for cgen@sourceware.org; Thu, 27 Jul 2006 10:47:54 +0200 (MEST) Date: Thu, 27 Jul 2006 08:48:00 -0000 From: Ronald Hecht Subject: Again: Disassembly with variable instruction size To: cgen@sourceware.org Message-id: <44C87E54.4050600@uni-rostock.de> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7BIT User-Agent: Mozilla Thunderbird 1.0.8-1.1.fc4 (X11/20060501) X-IsSubscribed: yes Mailing-List: contact cgen-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sourceware.org X-SW-Source: 2006-q3/txt/msg00009.txt.bz2 Hello, the problem seems to be in -dis.c. The generated function my_print_instruction looks wrong. It looks like this* #undef CGEN_PRINT_INSN #define CGEN_PRINT_INSN my_print_insn static int my_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) { bfd_byte buffer[CGEN_MAX_INSN_SIZE]; bfd_byte *buf = buffer; int status; int buflen = (pc & 3) == 0 ? 4 : 2; int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG; bfd_byte *x; /* Read the base part of the insn. */ status = (*info->read_memory_func) (pc - ((!big_p && (pc & 3) != 0) ? 2 : 0), buf, buflen, info); if (status != 0) { (*info->memory_error_func) (status, pc, info); return -1; } /* 32 bit insn? */ x = (big_p ? &buf[0] : &buf[3]); if ((pc & 3) == 0 && (*x & 0x80) != 0) return print_insn (cd, pc, info, buf, buflen); /* Print the first insn. */ if ((pc & 3) == 0) { buf += (big_p ? 0 : 2); if (print_insn (cd, pc, info, buf, 2) == 0) (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); buf += (big_p ? 2 : -2); } x = (big_p ? &buf[0] : &buf[1]); if (*x & 0x80) { /* Parallel. */ (*info->fprintf_func) (info->stream, " || "); *x &= 0x7f; } else (*info->fprintf_func) (info->stream, " -> "); /* The "& 3" is to pass a consistent address. Parallel insns arguably both begin on the word boundary. Also, branch insns are calculated relative to the word boundary. */ if (print_insn (cd, pc & ~ (bfd_vma) 3, info, buf, 2) == 0) (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); return (pc & 3) ? 2 : 4; } I replaced it with the stuff from fr30-dis.c : /* Default value for CGEN_PRINT_INSN. The result is the size of the insn in bytes or zero for an unknown insn or -1 if an error occured fetching bytes. */ #ifndef CGEN_PRINT_INSN #define CGEN_PRINT_INSN default_print_insn #endif static int default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) { bfd_byte buf[CGEN_MAX_INSN_SIZE]; int buflen; int status; /* Attempt to read the base part of the insn. */ buflen = cd->base_insn_bitsize / 8; status = (*info->read_memory_func) (pc, buf, buflen, info); /* Try again with the minimum part, if min < base. */ if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize)) { buflen = cd->min_insn_bitsize / 8; status = (*info->read_memory_func) (pc, buf, buflen, info); } if (status != 0) { (*info->memory_error_func) (status, pc, info); return -1; } return print_insn (cd, pc, info, buf, buflen); } This works for me. So the bug seems to be in the generation of -dis.c Best Regards Ronald *