From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25106 invoked by alias); 6 Jan 2010 08:18:49 -0000 Received: (qmail 25090 invoked by uid 22791); 6 Jan 2010 08:18:48 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from p12018-ipbffx02marunouchi.tokyo.ocn.ne.jp (HELO mail.pizzafactory.jp) (222.147.75.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Jan 2010 08:18:44 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.pizzafactory.jp (Postfix) with ESMTP id 4CA5259053A3; Wed, 6 Jan 2010 16:53:46 +0900 (JST) Received: from mail.pizzafactory.jp ([127.0.0.1]) by localhost (ldap.monami-software.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X-QzXsR76ekR; Wed, 6 Jan 2010 16:53:45 +0900 (JST) Received: from [192.168.0.9] (unknown [192.168.0.9]) by mail.pizzafactory.jp (Postfix) with ESMTP id 64EB15905399; Wed, 6 Jan 2010 16:53:45 +0900 (JST) Subject: [patch] Re: Can't set architecture to m32c on m32c-elf-gdb. Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: multipart/mixed; boundary=Apple-Mail-36-989374944 From: Masaki Muranaka In-Reply-To: <21F11493-3DE3-41FA-97D5-B539B54259A2@monami-software.com> Date: Wed, 06 Jan 2010 08:18:00 -0000 Cc: Nick Clifton , Daniel Jacobowitz , gdb-patches@sourceware.org, binutils@sourceware.org Message-Id: <1515B7CA-B0B2-491A-8C74-E959C381C072@monami-software.com> References: <20081203140802.GA6965@caradoc.them.org> <50B2818F-7217-4D63-ABE8-19E444FE9A40@monami-software.com> <4B3C9784.1040309@redhat.com> <21F11493-3DE3-41FA-97D5-B539B54259A2@monami-software.com> To: Masaki Muranaka X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00103.txt.bz2 --Apple-Mail-36-989374944 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Content-length: 2309 Hello maintainers, This is another plan to fix the issue. I think it is better than in the past because it is similar to cpu-arm.c. I attach the patch. I made sure If this issue is fixed by my patch. - - -=20 This GDB was configured as "--host=3Dx86_64-apple-darwin10.2.0 --target=3Dm= 32c-elf". For bug reporting instructions, please see: . (gdb) show architecture The target architecture is set automatically (currently m16c) (gdb) print $dma0 $1 =3D void (gdb) set architecture m32c The target architecture is assumed to be m32c (gdb) print $dma0 No registers. (gdb) set architecture m16c The target architecture is assumed to be m16c (gdb) print $dma0 $2 =3D void (gdb)=20 - - - ChangeLog: 2010-01-05 Masaki Muranaka * cpu-m32c.c (scan): New function. (arch_info_struct): Use scan() instead of bfd_default_scan(). (bfd_m32c_arch): Ditto. On 2010/01/03, at 9:00, Masaki Muranaka wrote: > Hello Nick, >=20 > Really did you try them? Here is a log of my GDB. >=20 > (gdb) show architecture > The target architecture is set automatically (currently m16c) > (gdb) set architecture m32c:m32c > Undefined item: "m32c:m32c". > (gdb) set architecture m32c:m16c > Undefined item: "m32c:m16c". >=20 > I got their sources via official git repository. >=20 > Thanks, >=20 > On 2009/12/31, at 21:22, Nick Clifton wrote: >=20 >> Hi Masaki, >>=20 >>> I figured out the reason about this issue. >>> This is caused by a bug in bfd/cpu-m32c.c. >>> The condision is like this: >>> He expects to select arch_info_struct[0] when he puts "set architecture= m32c". >>> But bfd_m32c_arch is selected bfd_default_scan(). So he always gets >>> configuration for m16c instead of m32c. >>=20 >> But as Daniel pointed out, if the user enters the command: >>=20 >> set architecture m32c:m32c >>=20 >> then the code in bfd_default_scan() will select the m32c architecture an= d if the user enters: >>=20 >> set architecture m32c:m16c >>=20 >> then bfd_default_scan() will select the m16c architecture. >>=20 >>> I think printable names in bfd/cpu-m32.c should be changed to "m32c:m16= c", "m32c:m32c". >>=20 >> There is no need for this, and in fact it will stop bfd_default_scan fro= m working as intended. >>=20 >> Cheers >> Nick >>=20 >=20 >=20 --Apple-Mail-36-989374944 Content-Disposition: attachment; filename=m32c-set-architecture-fix.patch Content-Type: application/octet-stream; name="m32c-set-architecture-fix.patch" Content-Transfer-Encoding: 7bit Content-length: 1453 diff --git a/bfd/cpu-m32c.c b/bfd/cpu-m32c.c index aa2e28d..dde8c61 100644 --- a/bfd/cpu-m32c.c +++ b/bfd/cpu-m32c.c @@ -1,5 +1,5 @@ /* BFD support for the M16C/M32C processors. - Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -22,6 +22,16 @@ #include "bfd.h" #include "libbfd.h" +static bfd_boolean +scan (const struct bfd_arch_info *info, const char *string) +{ + /* First test for an exact match. */ + if (strcasecmp (string, info->printable_name) == 0) + return TRUE; + + return FALSE; +} + static const bfd_arch_info_type arch_info_struct[] = { { @@ -35,7 +45,7 @@ static const bfd_arch_info_type arch_info_struct[] = 3, /* section align power */ FALSE, /* the default ? */ bfd_default_compatible, /* architecture comparison fn */ - bfd_default_scan, /* string to architecture convert fn */ + scan, /* string to architecture convert fn */ NULL /* next in list */ }, }; @@ -52,6 +62,6 @@ const bfd_arch_info_type bfd_m32c_arch = 4, /* Section align power. */ TRUE, /* The default ? */ bfd_default_compatible, /* Architecture comparison fn. */ - bfd_default_scan, /* String to architecture convert fn. */ + scan, /* String to architecture convert fn. */ &arch_info_struct[0], /* Next in list. */ }; --Apple-Mail-36-989374944--